From: divverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Date: Wed, 3 Dec 2008 13:12:31 +0000 (+0000)
Subject: Q3BSP: only generate the shadow mesh if on a client. Skip that part on the dedicated... 
X-Git-Tag: xonotic-v0.1.0preview~2026
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8042e27aa7a0da652a96d6bc203a45e5a2d5a2df;p=xonotic%2Fdarkplaces.git

Q3BSP: only generate the shadow mesh if on a client. Skip that part on the dedicated server. Reduces load time of redstarrepublic4.bsp from 21.6s to 12.3s on a dedicated server.


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

diff --git a/model_brush.c b/model_brush.c
index 648af660..465844e9 100644
--- a/model_brush.c
+++ b/model_brush.c
@@ -5858,17 +5858,20 @@ void Mod_Q3BSP_Load(dp_model_t *mod, void *buffer, void *bufferend)
 
 	// make a single combined shadow mesh to allow optimized shadow volume creation
 	numshadowmeshtriangles = 0;
-	for (j = 0, surface = loadmodel->data_surfaces;j < loadmodel->num_surfaces;j++, surface++)
+	if (cls.state != ca_dedicated)
 	{
-		surface->num_firstshadowmeshtriangle = numshadowmeshtriangles;
-		numshadowmeshtriangles += surface->num_triangles;
+		for (j = 0, surface = loadmodel->data_surfaces;j < loadmodel->num_surfaces;j++, surface++)
+		{
+			surface->num_firstshadowmeshtriangle = numshadowmeshtriangles;
+			numshadowmeshtriangles += surface->num_triangles;
+		}
+		loadmodel->brush.shadowmesh = Mod_ShadowMesh_Begin(loadmodel->mempool, numshadowmeshtriangles * 3, numshadowmeshtriangles, NULL, NULL, NULL, false, false, true);
+		for (j = 0, surface = loadmodel->data_surfaces;j < loadmodel->num_surfaces;j++, surface++)
+			if (surface->num_triangles > 0)
+				Mod_ShadowMesh_AddMesh(loadmodel->mempool, loadmodel->brush.shadowmesh, NULL, NULL, NULL, loadmodel->surfmesh.data_vertex3f, NULL, NULL, NULL, NULL, surface->num_triangles, (loadmodel->surfmesh.data_element3i + 3 * surface->num_firsttriangle));
+		loadmodel->brush.shadowmesh = Mod_ShadowMesh_Finish(loadmodel->mempool, loadmodel->brush.shadowmesh, false, true, false);
+		Mod_BuildTriangleNeighbors(loadmodel->brush.shadowmesh->neighbor3i, loadmodel->brush.shadowmesh->element3i, loadmodel->brush.shadowmesh->numtriangles);
 	}
-	loadmodel->brush.shadowmesh = Mod_ShadowMesh_Begin(loadmodel->mempool, numshadowmeshtriangles * 3, numshadowmeshtriangles, NULL, NULL, NULL, false, false, true);
-	for (j = 0, surface = loadmodel->data_surfaces;j < loadmodel->num_surfaces;j++, surface++)
-		if (surface->num_triangles > 0)
-			Mod_ShadowMesh_AddMesh(loadmodel->mempool, loadmodel->brush.shadowmesh, NULL, NULL, NULL, loadmodel->surfmesh.data_vertex3f, NULL, NULL, NULL, NULL, surface->num_triangles, (loadmodel->surfmesh.data_element3i + 3 * surface->num_firsttriangle));
-	loadmodel->brush.shadowmesh = Mod_ShadowMesh_Finish(loadmodel->mempool, loadmodel->brush.shadowmesh, false, true, false);
-	Mod_BuildTriangleNeighbors(loadmodel->brush.shadowmesh->neighbor3i, loadmodel->brush.shadowmesh->element3i, loadmodel->brush.shadowmesh->numtriangles);
 
 	loadmodel->brush.num_leafs = 0;
 	Mod_Q3BSP_RecursiveFindNumLeafs(loadmodel->brush.data_nodes);