]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - model_brush.c
make getsurface* functions shared between VMs
[xonotic/darkplaces.git] / model_brush.c
index bf2389cbeb47540dabe0d10a72b73f66d2b4f1cc..7b965f450895a72e8e1fccb8b5b50c5537c97327 100644 (file)
@@ -1209,7 +1209,7 @@ loc0:
                        surface = model->data_surfaces + node->firstsurface;
                        for (i = 0;i < node->numsurfaces;i++, surface++)
                        {
-                               if (!(surface->texture->basematerialflags & MATERIALFLAG_WALL) || !surface->lightmapinfo->samples)
+                               if (!(surface->texture->basematerialflags & MATERIALFLAG_WALL) || !surface->lightmapinfo || !surface->lightmapinfo->samples)
                                        continue;       // no lightmaps
 
                                // location we want to sample in the lightmap
@@ -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);