qbsp: switch to hardcoded MAX_MAP_PLANES. counting unique planes was slow

This commit is contained in:
Eric Wasylishen 2015-04-24 01:21:48 -06:00
parent 28e460be9a
commit d77a7d768c
3 changed files with 4 additions and 42 deletions

View File

@ -30,6 +30,8 @@ typedef uint8_t byte;
#define BSP2RMQVERSION (('B' << 24) | ('S' << 16) | ('P' << 8) | '2')
#define BSP2VERSION ('B' | ('S' << 8) | ('P' << 16) | ('2' << 24))
#define MAX_MAP_PLANES 262144
typedef struct {
int32_t fileofs;
int32_t filelen;

View File

@ -719,12 +719,10 @@ LoadMapFile(void)
{
parser_t parser;
char *buf;
int i, j, length, cAxis;
int length;
void *pTemp;
struct lumpdata *texinfo;
mapentity_t *entity;
mapbrush_t *brush;
mapface_t *face, *face2;
Message(msgProgress, "LoadMapFile");
@ -768,44 +766,7 @@ LoadMapFile(void)
FreeMem(pTemp, BSP_TEXINFO, texinfo->count);
texinfo->count = texinfo->index;
}
// One plane per face + 6 for portals
map.maxplanes = map.numfaces + 6;
// Count # of unique planes in all of the faces
for (i = 0, face = map.faces; i < map.numfaces; i++, face++) {
face->fUnique = true;
for (j = 0, face2 = map.faces; j < i; j++, face2++) {
if (face2->fUnique &&
VectorCompare(face->plane.normal, face2->plane.normal) &&
fabs(face->plane.dist - face2->plane.dist) < EQUAL_EPSILON) {
face->fUnique = false;
map.maxplanes--;
break;
}
}
}
/*
* Now iterate through brushes, add one plane for each face below 6 axis
* aligned faces. This compensates for planes added in ExpandBrush.
*/
for (i = 0, brush = map.brushes; i < map.numbrushes; i++, brush++) {
cAxis = 0;
for (j = 0, face = brush->faces; j < brush->numfaces; j++, face++) {
if (fabs(face->plane.normal[0]) > 1 - NORMAL_EPSILON
|| fabs(face->plane.normal[1]) > 1 - NORMAL_EPSILON
|| fabs(face->plane.normal[2]) > 1 - NORMAL_EPSILON)
cAxis++;
}
if (6 - cAxis > 0)
map.maxplanes += 6 - cAxis;
}
/*
* map.maxplanes*3 because of 3 hulls, then add 20% as a fudge factor for
* hull edge bevel planes
*/
map.maxplanes = 3 * map.maxplanes + map.maxplanes / 5;
map.maxplanes = MAX_MAP_PLANES;
map.planes = AllocMem(PLANE, map.maxplanes, true);
Message(msgStat, "%8d faces", map.numfaces);

View File

@ -470,7 +470,6 @@ typedef struct epair_s {
typedef struct mapface_s {
plane_t plane;
int texinfo;
int fUnique;
int linenum;
} mapface_t;