]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
try to eliminate MAX_MAP_PLANES limits
authordivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Wed, 25 Feb 2009 15:24:29 +0000 (15:24 +0000)
committerdivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Wed, 25 Feb 2009 15:24:29 +0000 (15:24 +0000)
git-svn-id: svn://svn.icculus.org/netradiant/trunk@198 61c419a2-8eb2-4b30-bcec-8cead039b335

tools/quake3/q3map2/bspfile_ibsp.c
tools/quake3/q3map2/bspfile_rbsp.c
tools/quake3/q3map2/convert_map.c
tools/quake3/q3map2/map.c
tools/quake3/q3map2/model.c
tools/quake3/q3map2/q3map2.h
tools/quake3/q3map2/writebsp.c

index 7874b922d02b86482ed0656cc80cdf8cfc4f05b1..591d4d14287378a8eae415a6b325fa090c3f2e2b 100644 (file)
@@ -481,7 +481,7 @@ void LoadIBSPFile( const char *filename )
        
        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 ) );
        
index c31da09e12edc101beed4a2f5077bad7f4bb85c8..6868f97467ba5f3e4574b5199384d5f13282d2d7 100644 (file)
@@ -233,7 +233,7 @@ void LoadRBSPFile( const char *filename )
        
        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 ) );
        
index 38fc738fd52c831636c679241fedf32efe8c8ce3..8e1a143ed6f8acf760be8c512d3d0c744802d24e 100644 (file)
@@ -482,7 +482,7 @@ static void ConvertModel( FILE *f, bspModel_t *model, int modelNum, vec3_t origi
                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 */
index 51d87afac744d5883cfc6854166e17d97f9a8e26..1bf1ddcde5eebccb767752acf82551425d67f472 100644 (file)
@@ -44,7 +44,7 @@ several games based on the Quake III Arena engine, in the form of "Q3Map2."
 #define        USE_HASHING
 #define        PLANE_HASHES    8192
 
-plane_t                                        *planehash[ PLANE_HASHES ];
+int                                            planehash[ PLANE_HASHES ];
 
 int                                            c_boxbevels;
 int                                            c_edgebevels;
@@ -96,7 +96,7 @@ void AddPlaneToHash( plane_t *p )
        hash = (PLANE_HASHES - 1) & (int) fabs( p->dist );
 
        p->hash_chain = planehash[hash];
-       planehash[hash] = p;
+       planehash[hash] = p - mapplanes + 1;
 }
 
 /*
@@ -115,8 +115,7 @@ int CreateNewFloatPlane (vec3_t normal, vec_t dist)
        }
 
        // 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);
@@ -219,6 +218,7 @@ int FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points ) /
 
 {
        int             i, j, hash, h;
+       int pidx;
        plane_t *p;
        vec_t   d;
        vec3_t centerofweight;
@@ -235,8 +235,10 @@ int FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points ) /
        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;
index f2a04c100ded074c257c371c856ca2f57661eaae..9847f6649338358489fe6ba231ac770029da68e1 100644 (file)
@@ -409,20 +409,11 @@ void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shade
                                ((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++ )
index 29e1c79101fc9cf2e5f725cae093630dbe219e3e..53ec4c54bfc3e6817fa9f0b806d90a543570e13d 100644 (file)
@@ -310,7 +310,6 @@ abstracted bsp file
 
 #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
@@ -791,7 +790,7 @@ typedef struct plane_s
        vec3_t                          normal;
        vec_t                           dist;
        int                                     type;
-       struct plane_s          *hash_chain;
+       int                                     hash_chain;
 }
 plane_t;
 
@@ -1961,8 +1960,9 @@ Q_EXTERN int                              mapEntityNum Q_ASSIGN( 0 );
 
 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;
 
@@ -2317,7 +2317,8 @@ Q_EXTERN int                              numBSPLeafs Q_ASSIGN( 0 );
 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 );
index 96e8ce29340b048a328a76c946f1eb8868a3e508..c9f5f7312a4d88b5ce57add8c182dc68fe99eb9d 100644 (file)
@@ -116,6 +116,7 @@ void EmitPlanes( void )
        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;