numBSPModels = CopyLump_Allocate( (bspHeader_t*) header, LUMP_MODELS, (void **) &bspModels, sizeof( bspModel_t ), &allocatedBSPModels );
- numBSPPlanes = CopyLump( (bspHeader_t*) header, LUMP_PLANES, bspPlanes, sizeof( bspPlane_t ) );
+ numBSPPlanes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_PLANES, (void **) &bspPlanes, sizeof( bspPlane_t ), &allocatedBSPPlanes );
numBSPLeafs = CopyLump( (bspHeader_t*) header, LUMP_LEAFS, bspLeafs, sizeof( bspLeaf_t ) );
numBSPModels = CopyLump_Allocate( (bspHeader_t*) header, LUMP_MODELS, (void **) &bspModels, sizeof( bspModel_t ), &allocatedBSPModels );
- numBSPPlanes = CopyLump( (bspHeader_t*) header, LUMP_PLANES, bspPlanes, sizeof( bspPlane_t ) );
+ numBSPPlanes = CopyLump_Allocate( (bspHeader_t*) header, LUMP_PLANES, (void **) &bspPlanes, sizeof( bspPlane_t ), &allocatedBSPPlanes );
numBSPLeafs = CopyLump( (bspHeader_t*) header, LUMP_LEAFS, bspLeafs, sizeof( bspLeaf_t ) );
VectorCopy( bspPlanes[ i ].normal, mapplanes[ i ].normal );
mapplanes[ i ].dist = bspPlanes[ i ].dist;
mapplanes[ i ].type = PlaneTypeForNormal( mapplanes[ i ].normal );
- mapplanes[ i ].hash_chain = NULL;
+ mapplanes[ i ].hash_chain = 0;
}
/* allocate a build brush */
#define USE_HASHING
#define PLANE_HASHES 8192
-plane_t *planehash[ PLANE_HASHES ];
+int planehash[ PLANE_HASHES ];
int c_boxbevels;
int c_edgebevels;
hash = (PLANE_HASHES - 1) & (int) fabs( p->dist );
p->hash_chain = planehash[hash];
- planehash[hash] = p;
+ planehash[hash] = p - mapplanes + 1;
}
/*
}
// create a new plane
- if (nummapplanes+2 > MAX_MAP_PLANES)
- Error ("MAX_MAP_PLANES");
+ AUTOEXPAND_BY_REALLOC(mapplanes, nummapplanes+1, allocatedmapplanes, 1024);
p = &mapplanes[nummapplanes];
VectorCopy (normal, p->normal);
{
int i, j, hash, h;
+ int pidx;
plane_t *p;
vec_t d;
vec3_t centerofweight;
for( i = -1; i <= 1; i++ )
{
h = (hash + i) & (PLANE_HASHES - 1);
- for( p = planehash[ h ]; p != NULL; p = p->hash_chain )
+ for( pidx = planehash[ h ] - 1; pidx != -1; pidx = mapplanes[pidx].hash_chain - 1 )
{
+ p = &mapplanes[pidx];
+
/* do standard plane compare */
if( !PlaneEqual( p, normal, dist ) )
continue;
((si->compileFlags & C_TRANSLUCENT) || !(si->compileFlags & C_SOLID)) )
continue;
- /* overflow check */
- if( (nummapplanes + 64) >= (MAX_MAP_PLANES >> 1) )
- continue;
-
/* walk triangle list */
for( i = 0; i < ds->numIndexes; i += 3 )
{
/* overflow hack */
- if( (nummapplanes + 64) >= (MAX_MAP_PLANES >> 1) )
- {
- Sys_Printf( "WARNING: MAX_MAP_PLANES (%d) hit generating clip brushes for model %s.\n",
- MAX_MAP_PLANES, name );
- break;
- }
+ AUTOEXPAND_BY_REALLOC(mapplanes, (nummapplanes+64) << 1, allocatedmapplanes, 1024);
/* make points and back points */
for( j = 0; j < 3; j++ )
#define MAX_MAP_AREAS 0x100 /* MAX_MAP_AREA_BYTES in q_shared must match! */
#define MAX_MAP_FOGS 30 //& 0x100 /* RBSP (32 - world fog - goggles) */
-#define MAX_MAP_PLANES 0x200000 //% 0x20000 /* ydnar for md */
#define MAX_MAP_LEAFS 0x20000
#define MAX_MAP_PORTALS 0x20000
#define MAX_MAP_LIGHTING 0x800000
vec3_t normal;
vec_t dist;
int type;
- struct plane_s *hash_chain;
+ int hash_chain;
}
plane_t;
Q_EXTERN int entitySourceBrushes;
-Q_EXTERN plane_t mapplanes[ MAX_MAP_PLANES ]; /* mapplanes[ num ^ 1 ] will always be the mirror or mapplanes[ num ] */
-Q_EXTERN int nummapplanes; /* nummapplanes will always be even */
+Q_EXTERN plane_t *mapplanes Q_ASSIGN(NULL); /* mapplanes[ num ^ 1 ] will always be the mirror or mapplanes[ num ] */
+Q_EXTERN int nummapplanes Q_ASSIGN(0); /* nummapplanes will always be even */
+Q_EXTERN int allocatedmapplanes Q_ASSIGN(0);
Q_EXTERN int numMapPatches;
Q_EXTERN vec3_t mapMins, mapMaxs;
Q_EXTERN bspLeaf_t bspLeafs[ MAX_MAP_LEAFS ];
Q_EXTERN int numBSPPlanes Q_ASSIGN( 0 );
-Q_EXTERN bspPlane_t bspPlanes[ MAX_MAP_PLANES ];
+Q_EXTERN int allocatedBSPPlanes Q_ASSIGN(0);
+Q_EXTERN bspPlane_t *bspPlanes;
Q_EXTERN int numBSPNodes Q_ASSIGN( 0 );
Q_EXTERN int allocatedBSPNodes Q_ASSIGN( 0 );
mp = mapplanes;
for( i = 0; i < nummapplanes; i++, mp++ )
{
+ AUTOEXPAND_BY_REALLOC_BSP(Planes, 1024);
bp = &bspPlanes[ numBSPPlanes ];
VectorCopy( mp->normal, bp->normal );
bp->dist = mp->dist;