qbsp: switch to hardcoded MAX_MAP_PLANES. counting unique planes was slow
This commit is contained in:
parent
28e460be9a
commit
d77a7d768c
|
|
@ -30,6 +30,8 @@ typedef uint8_t byte;
|
||||||
#define BSP2RMQVERSION (('B' << 24) | ('S' << 16) | ('P' << 8) | '2')
|
#define BSP2RMQVERSION (('B' << 24) | ('S' << 16) | ('P' << 8) | '2')
|
||||||
#define BSP2VERSION ('B' | ('S' << 8) | ('P' << 16) | ('2' << 24))
|
#define BSP2VERSION ('B' | ('S' << 8) | ('P' << 16) | ('2' << 24))
|
||||||
|
|
||||||
|
#define MAX_MAP_PLANES 262144
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t fileofs;
|
int32_t fileofs;
|
||||||
int32_t filelen;
|
int32_t filelen;
|
||||||
|
|
|
||||||
43
qbsp/map.c
43
qbsp/map.c
|
|
@ -719,12 +719,10 @@ LoadMapFile(void)
|
||||||
{
|
{
|
||||||
parser_t parser;
|
parser_t parser;
|
||||||
char *buf;
|
char *buf;
|
||||||
int i, j, length, cAxis;
|
int length;
|
||||||
void *pTemp;
|
void *pTemp;
|
||||||
struct lumpdata *texinfo;
|
struct lumpdata *texinfo;
|
||||||
mapentity_t *entity;
|
mapentity_t *entity;
|
||||||
mapbrush_t *brush;
|
|
||||||
mapface_t *face, *face2;
|
|
||||||
|
|
||||||
Message(msgProgress, "LoadMapFile");
|
Message(msgProgress, "LoadMapFile");
|
||||||
|
|
||||||
|
|
@ -768,44 +766,7 @@ LoadMapFile(void)
|
||||||
FreeMem(pTemp, BSP_TEXINFO, texinfo->count);
|
FreeMem(pTemp, BSP_TEXINFO, texinfo->count);
|
||||||
texinfo->count = texinfo->index;
|
texinfo->count = texinfo->index;
|
||||||
}
|
}
|
||||||
// One plane per face + 6 for portals
|
map.maxplanes = MAX_MAP_PLANES;
|
||||||
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.planes = AllocMem(PLANE, map.maxplanes, true);
|
map.planes = AllocMem(PLANE, map.maxplanes, true);
|
||||||
|
|
||||||
Message(msgStat, "%8d faces", map.numfaces);
|
Message(msgStat, "%8d faces", map.numfaces);
|
||||||
|
|
|
||||||
|
|
@ -470,7 +470,6 @@ typedef struct epair_s {
|
||||||
typedef struct mapface_s {
|
typedef struct mapface_s {
|
||||||
plane_t plane;
|
plane_t plane;
|
||||||
int texinfo;
|
int texinfo;
|
||||||
int fUnique;
|
|
||||||
int linenum;
|
int linenum;
|
||||||
} mapface_t;
|
} mapface_t;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue