]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
save some memory by not allocating neighbors for q1bsp and q3bsp meshlists
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Mar 2005 12:16:48 +0000 (12:16 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 28 Mar 2005 12:16:48 +0000 (12:16 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5131 d7cf8633-e32d-0410-b094-e92efae38249

model_brush.c
model_shared.c
model_shared.h

index 134c151aefbc35fa0e38699a815f2ee99b4b90b8..315c20309d1ea680537268322422deb9d781514b 100644 (file)
@@ -1789,7 +1789,7 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l)
        // vertex limit
        loadmodel->nummeshes = 1;
        loadmodel->meshlist = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t *));
-       loadmodel->meshlist[0] = Mod_AllocSurfMesh(loadmodel->mempool, totalverts, totaltris, true, true, false);
+       loadmodel->meshlist[0] = Mod_AllocSurfMesh(loadmodel->mempool, totalverts, totaltris, true, true, false, false);
 
        totalverts = 0;
        totaltris = 0;
@@ -4242,7 +4242,7 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l)
                i = oldi;
                in = oldin;
                out = oldout;
-               mesh = tempmeshlist[meshnum] = Mod_AllocSurfMesh(loadmodel->mempool, meshvertices, meshtriangles, false, false, true);
+               mesh = tempmeshlist[meshnum] = Mod_AllocSurfMesh(loadmodel->mempool, meshvertices, meshtriangles, false, false, true, false);
                meshvertices = 0;
                meshtriangles = 0;
                for (;i < count && meshvertices + out->num_vertices <= mesh->num_vertices;i++, in++, out++)
index 4c75e811ea58097fc445bb16b8ae594a70f309d5..9553daf6b843bbb857542b345388f3621c0b664b 100644 (file)
@@ -752,11 +752,11 @@ void Mod_BuildTextureVectorsAndNormals(int numverts, int numtriangles, const flo
                        VectorNormalize(v);
 }
 
-surfmesh_t *Mod_AllocSurfMesh(mempool_t *mempool, int numvertices, int numtriangles, qboolean detailtexcoords, qboolean lightmapoffsets, qboolean vertexcolors)
+surfmesh_t *Mod_AllocSurfMesh(mempool_t *mempool, int numvertices, int numtriangles, qboolean detailtexcoords, qboolean lightmapoffsets, qboolean vertexcolors, qboolean neighbors)
 {
        surfmesh_t *mesh;
        qbyte *data;
-       mesh = Mem_Alloc(mempool, sizeof(surfmesh_t) + numvertices * (3 + 3 + 3 + 3 + 2 + 2 + (detailtexcoords ? 2 : 0) + (vertexcolors ? 4 : 0)) * sizeof(float) + numvertices * (lightmapoffsets ? 1 : 0) * sizeof(int) + numtriangles * (3 + 3) * sizeof(int));
+       mesh = Mem_Alloc(mempool, sizeof(surfmesh_t) + numvertices * (3 + 3 + 3 + 3 + 2 + 2 + (detailtexcoords ? 2 : 0) + (vertexcolors ? 4 : 0)) * sizeof(float) + numvertices * (lightmapoffsets ? 1 : 0) * sizeof(int) + numtriangles * (3 + (neighbors ? 3 : 0)) * sizeof(int));
        mesh->num_vertices = numvertices;
        mesh->num_triangles = numtriangles;
        data = (qbyte *)(mesh + 1);
@@ -778,7 +778,8 @@ surfmesh_t *Mod_AllocSurfMesh(mempool_t *mempool, int numvertices, int numtriang
        if (mesh->num_triangles)
        {
                mesh->data_element3i = (int *)data, data += sizeof(int[3]) * mesh->num_triangles;
-               mesh->data_neighbor3i = (int *)data, data += sizeof(int[3]) * mesh->num_triangles;
+               if (neighbors)
+                       mesh->data_neighbor3i = (int *)data, data += sizeof(int[3]) * mesh->num_triangles;
        }
        return mesh;
 }
index 08925d8a0d4a24474b6e97e855087c3bb63baffd..bf7218e41e634095421a6df2f2f668dfa552a444 100644 (file)
@@ -465,7 +465,7 @@ void Mod_ValidateElements(const int *elements, int numtriangles, int numverts, c
 void Mod_BuildNormals(int numverts, int numtriangles, const float *vertex3f, const int *elements, float *normal3f);
 void Mod_BuildTextureVectorsAndNormals(int numverts, int numtriangles, const float *vertex, const float *texcoord, const int *elements, float *svectors, float *tvectors, float *normals);
 
-surfmesh_t *Mod_AllocSurfMesh(mempool_t *mempool, int numvertices, int numtriangles, qboolean detailtexcoords, qboolean lightmapoffsets, qboolean vertexcolors);
+surfmesh_t *Mod_AllocSurfMesh(mempool_t *mempool, int numvertices, int numtriangles, qboolean detailtexcoords, qboolean lightmapoffsets, qboolean vertexcolors, qboolean neighbors);
 
 shadowmesh_t *Mod_ShadowMesh_Alloc(mempool_t *mempool, int maxverts, int maxtriangles, rtexture_t *map_diffuse, rtexture_t *map_specular, rtexture_t *map_normal, int light, int neighbors, int expandable);
 shadowmesh_t *Mod_ShadowMesh_ReAlloc(mempool_t *mempool, shadowmesh_t *oldmesh, int light, int neighbors);