]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix a bug where submodels are not uploaded in a VBO which can cause bad
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 25 Jan 2010 19:48:39 +0000 (19:48 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 25 Jan 2010 19:48:39 +0000 (19:48 +0000)
performance on some drivers

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9854 d7cf8633-e32d-0410-b094-e92efae38249

model_brush.c
model_shared.c
model_shared.h

index bf2389cbeb47540dabe0d10a72b73f66d2b4f1cc..052d365041115e73405f5ca908a1a0cefc9285db 100644 (file)
@@ -3720,11 +3720,15 @@ void Mod_Q1BSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
                        Con_Printf("warning: empty submodel *%i in %s\n", i+1, loadmodel->name);
                }
                //mod->brushq1.num_visleafs = bm->visleafs;
-       }
-
-       Mod_Q1BSP_LoadMapBrushes();
 
-       //Mod_Q1BSP_ProcessLightList();
+               // generate VBOs and other shared data before cloning submodels
+               if (i == 0)
+               {
+                       Mod_BuildVBOs();
+                       Mod_Q1BSP_LoadMapBrushes();
+                       //Mod_Q1BSP_ProcessLightList();
+               }
+       }
 
        Con_DPrintf("Stats for q1bsp model \"%s\": %i faces, %i nodes, %i leafs, %i visleafs, %i visleafportals, mesh: %i vertices, %i triangles, %i surfaces\n", loadmodel->name, loadmodel->num_surfaces, loadmodel->brush.num_nodes, loadmodel->brush.num_leafs, mod->brush.num_pvsclusters, loadmodel->brush.num_portals, loadmodel->surfmesh.num_vertices, loadmodel->surfmesh.num_triangles, loadmodel->num_surfaces);
 }
@@ -6272,6 +6276,10 @@ void Mod_Q3BSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
                                break;
                if (j < mod->nummodelsurfaces)
                        mod->DrawAddWaterPlanes = R_Q1BSP_DrawAddWaterPlanes;
+
+               // generate VBOs and other shared data before cloning submodels
+               if (i == 0)
+                       Mod_BuildVBOs();
        }
 
        Con_DPrintf("Stats for q3bsp model \"%s\": %i faces, %i nodes, %i leafs, %i clusters, %i clusterportals, mesh: %i vertices, %i triangles, %i surfaces\n", loadmodel->name, loadmodel->num_surfaces, loadmodel->brush.num_nodes, loadmodel->brush.num_leafs, mod->brush.num_pvsclusters, loadmodel->brush.num_portals, loadmodel->surfmesh.num_vertices, loadmodel->surfmesh.num_triangles, loadmodel->num_surfaces);
index 89087d7adf19c3eaac53e40fb9df97f9168d4ce9..c54375043d7bfbcb469df518c51fb4d3e2575c09 100644 (file)
@@ -148,7 +148,6 @@ Mod_Init
 static void Mod_Print(void);
 static void Mod_Precache (void);
 static void Mod_Decompile_f(void);
-static void Mod_BuildVBOs(void);
 static void Mod_GenerateLightmaps_f(void);
 void Mod_Init (void)
 {
@@ -1149,6 +1148,8 @@ static void Mod_ShadowMesh_CreateVBOs(shadowmesh_t *mesh)
 {
        if (!vid.support.arb_vertex_buffer_object)
                return;
+       if (mesh->vbo)
+               return;
 
        // element buffer is easy because it's just one array
        if (mesh->numtriangles)
@@ -2481,7 +2482,7 @@ void Mod_MakeSortedSurfaces(dp_model_t *mod)
        Mem_Free(numsurfacesfortexture);
 }
 
-static void Mod_BuildVBOs(void)
+void Mod_BuildVBOs(void)
 {
        if (gl_paranoid.integer && loadmodel->surfmesh.data_element3s && loadmodel->surfmesh.data_element3i)
        {
@@ -2498,6 +2499,9 @@ static void Mod_BuildVBOs(void)
 
        if (!vid.support.arb_vertex_buffer_object)
                return;
+       // only build a vbo if one has not already been created (this is important for brush models which load specially)
+       if (loadmodel->surfmesh.vbo)
+               return;
 
        // element buffer is easy because it's just one array
        if (loadmodel->surfmesh.num_triangles)
index d0d573693f06cca1ac880a40b16ed05a597dbaa8..c0e263f1ff57974493b2519a530730c3575ba9d8 100644 (file)
@@ -965,6 +965,10 @@ void Mod_BuildTextureVectorsFromNormals(int firstvertex, int numvertices, int nu
 void Mod_AllocSurfMesh(mempool_t *mempool, int numvertices, int numtriangles, qboolean lightmapoffsets, qboolean vertexcolors, qboolean neighbors);
 void Mod_MakeSortedSurfaces(dp_model_t *mod);
 
+// called specially by brush model loaders before generating submodels
+// automatically called after model loader returns
+void Mod_BuildVBOs(void);
+
 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);
 int Mod_ShadowMesh_AddVertex(shadowmesh_t *mesh, float *vertex14f);