[nexuiz-commits] r7134 - in trunk/data: . qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Jun 30 14:28:34 EDT 2009


Author: div0
Date: 2009-06-30 14:28:33 -0400 (Tue, 30 Jun 2009)
New Revision: 7134

Modified:
   trunk/data/defaultNexuiz.cfg
   trunk/data/qcsrc/server/cl_client.qc
   trunk/data/qcsrc/server/cl_player.qc
   trunk/data/qcsrc/server/defs.qh
   trunk/data/qcsrc/server/miscfunctions.qc
   trunk/data/qcsrc/server/sv_main.qc
Log:
LOD (cl_playerdetailreduction) enabled now, master switch sv_loddistance1 (also turns off model forcing, though)


Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg	2009-06-30 17:33:35 UTC (rev 7133)
+++ trunk/data/defaultNexuiz.cfg	2009-06-30 18:28:33 UTC (rev 7134)
@@ -341,8 +341,6 @@
 seta cl_autoswitch 1 "automatically switch to newly picked up weapons if they are better than what you are carrying"
 alias autoswitch "set cl_autoswitch $1 ; cmd autoswitch $1"
 
-seta cl_playerdetailreduction 0	"the higher, the less detailed"
-
 set bot_config_file bots.txt "Name and path of the bot configuration file"
 set bot_number 0	"Minimum number of bots"
 seta bot_usemodelnames 0	"Use player model names for bot names"
@@ -1594,3 +1592,7 @@
 seta cl_forceplayermodels 0 "force all players to look like you; WARNING: animations can look very bad with this"
 seta cl_forceplayermodelsfromnexuiz 0 "force models coming from nexuiz; WARNING: animations can look very bad with this"
 set sv_clforceplayermodels 1 "allow clients to use cl_forcemodels"
+
+set sv_loddistance1 1024
+set sv_loddistance2 4096
+seta cl_playerdetailreduction 0	"the higher, the less detailed player models are displayed (LOD)"

Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc	2009-06-30 17:33:35 UTC (rev 7133)
+++ trunk/data/qcsrc/server/cl_client.qc	2009-06-30 18:28:33 UTC (rev 7134)
@@ -399,21 +399,29 @@
 	self.modelindex = self.modelindex_lod0;
 	self.skin = self.skinindex;
 }
+
 float Client_customizeentityforclient()
 {
 	entity modelsource;
-
+	
 	if(self.modelindex == 0)
 		return TRUE;
 
+	// forcemodel stuff
+
+#ifdef PROFILING
+	float t0;
+	t0 = gettime(GETTIME_HIRES); // reference
+#endif
+
 	modelsource = self;
 	if(other.cvar_cl_forceplayermodelsfromnexuiz)
 		if not(self.modelindex_lod0_from_nexuiz)
 			modelsource = other;
 	if(other.cvar_cl_forceplayermodels && sv_clforceplayermodels)
 		modelsource = other;
+	self.skin = modelsource.skinindex;
 
-	self.skin = modelsource.skinindex;
 #if 0
 	if(modelsource == self)
 		self.skin = modelsource.skinindex;
@@ -421,15 +429,11 @@
 		self.skin = mod(modelsource.skinindex, 3); // forbid the fbskins as forced skins
 #endif
 
-#ifdef ALLOW_VARIABLE_LOD
 	// self: me
 	// other: the player viewing me
 	float distance;
 	float f;
 
-	if(self.classname != "player")
-		return TRUE;
-
 	if(other.cvar_cl_playerdetailreduction <= 0)
 	{
 		if(other.cvar_cl_playerdetailreduction <= -2)
@@ -443,15 +447,18 @@
 	{
 		distance = vlen(self.origin - other.origin);
 		f = (distance + 100.0) * other.cvar_cl_playerdetailreduction;
-		if(f > 10000)
+		if(f > sv_loddistance2)
 			self.modelindex = modelsource.modelindex_lod2;
-		else if(f > 5000)
+		else if(f > sv_loddistance1)
 			self.modelindex = modelsource.modelindex_lod1;
 		else
 			self.modelindex = modelsource.modelindex_lod0;
 	}
-#else
-	self.modelindex = modelsource.modelindex_lod0;
+
+#ifdef PROFILING
+	float t1;
+	t1 = gettime(GETTIME_HIRES); // reference
+	client_cefc_accumulator += (t1 - t0);
 #endif
 
 	return TRUE;
@@ -460,47 +467,47 @@
 void UpdatePlayerSounds();
 void setmodel_lod(entity e, string modelname)
 {
-#ifdef ALLOW_VARIABLE_LOD
 	string s;
 
-	// FIXME: this only supports 3-letter extensions
-	s = strcat(substring(modelname, 0, -4), "_lod1", substring(modelname, -4, 4));
-	if(fexists(s))
+	if(sv_loddistance1)
 	{
-		precache_model(s);
-		setmodel(e, s); // players have high precision
-		self.modelindex_lod1 = self.modelindex;
+		// FIXME: this only supports 3-letter extensions
+		s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod1", substring(modelname, -4, 4));
+		if(fexists(s))
+		{
+			setmodel(e, s); // players have high precision
+			self.modelindex_lod1 = self.modelindex;
+		}
+		else
+			self.modelindex_lod1 = -1;
+
+		s = strcat(substring(modelname, 0, strlen(modelname)-4), "_lod2", substring(modelname, -4, 4));
+		if(fexists(s))
+		{
+			setmodel(e, s); // players have high precision
+			self.modelindex_lod2 = self.modelindex;
+		}
+		else
+			self.modelindex_lod2 = -1;
+
+		precache_model(modelname);
+		setmodel(e, modelname); // players have high precision
+		self.modelindex_lod0 = self.modelindex;
+
+		if(self.modelindex_lod1 < 0)
+			self.modelindex_lod1 = self.modelindex;
+
+		if(self.modelindex_lod2 < 0)
+			self.modelindex_lod2 = self.modelindex;
 	}
 	else
-		self.modelindex_lod1 = -1;
-
-	s = strcat(substring(modelname, 0, -4), "_lod2", substring(modelname, -4, 4));
-	if(fexists(s))
 	{
-		precache_model(s);
-		setmodel(e, s); // players have high precision
-		self.modelindex_lod2 = self.modelindex;
+		precache_model(modelname);
+		setmodel(e, modelname); // players have high precision
+		self.modelindex_lod0 = self.modelindex;
+			// save it for possible player model forcing
 	}
-	else
-		self.modelindex_lod2 = -1;
 
-	precache_model(modelname);
-	setmodel(e, modelname); // players have high precision
-	self.modelindex_lod0 = self.modelindex;
-
-	if(self.modelindex_lod1 < 0)
-		self.modelindex_lod1 = self.modelindex;
-
-	if(self.modelindex_lod2 < 0)
-		self.modelindex_lod2 = self.modelindex;
-#else
-	precache_model(modelname);
-	setmodel(e, modelname); // players have high precision
-	self.modelindex_lod0 = self.modelindex;
-		// save it for possible player model forcing
-#endif
-
-	string s;
 	s = whichpack(self.model);
 	self.modelindex_lod0_from_nexuiz = ((s == "") || (substring(s, 0, 4) == "data"));
 
@@ -616,8 +623,10 @@
 	self.punchangle = '0 0 0';
 	self.punchvector = '0 0 0';
 	self.oldvelocity = self.velocity;
-	SetCustomizer(self, Client_customizeentityforclient, Client_uncustomizeentityforclient);
 
+	if(sv_loddistance1)
+		SetCustomizer(self, Client_customizeentityforclient, Client_uncustomizeentityforclient);
+
 	self.team = -1;
 
 	if(g_arena)
@@ -888,7 +897,8 @@
 			WriteByte(MSG_ONE, TE_CSQC_SPAWN);
 		});
 
-		SetCustomizer(self, Client_customizeentityforclient, Client_uncustomizeentityforclient);
+		if(sv_loddistance1)
+			SetCustomizer(self, Client_customizeentityforclient, Client_uncustomizeentityforclient);
 
 		self.model = "";
 		FixPlayermodel();

Modified: trunk/data/qcsrc/server/cl_player.qc
===================================================================
--- trunk/data/qcsrc/server/cl_player.qc	2009-06-30 17:33:35 UTC (rev 7133)
+++ trunk/data/qcsrc/server/cl_player.qc	2009-06-30 18:28:33 UTC (rev 7134)
@@ -47,10 +47,8 @@
 	self.modelindex = oldself.modelindex;
 	self.modelindex_lod0 = oldself.modelindex_lod0;
 	self.modelindex_lod0_from_nexuiz = oldself.modelindex_lod0_from_nexuiz;
-#ifdef ALLOW_VARIABLE_LOD
 	self.modelindex_lod1 = oldself.modelindex_lod1;
 	self.modelindex_lod2 = oldself.modelindex_lod2;
-#endif
 	self.skinindex = oldself.skinindex;
 	self.species = oldself.species;
 	self.movetype = oldself.movetype;

Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh	2009-06-30 17:33:35 UTC (rev 7133)
+++ trunk/data/qcsrc/server/defs.qh	2009-06-30 18:28:33 UTC (rev 7134)
@@ -333,6 +333,8 @@
 .float cvar_cl_forceplayermodels;
 .float cvar_cl_forceplayermodelsfromnexuiz;
 float sv_clforceplayermodels;
+float sv_loddistance1;
+float sv_loddistance2;
 .float cvar_cl_gunalign;
 
 .float version_nagtime;
@@ -340,10 +342,8 @@
 .float modelindex_lod0;
 .float modelindex_lod0_from_nexuiz;
 .float skinindex;
-#ifdef ALLOW_VARIABLE_LOD
 .float modelindex_lod1;
 .float modelindex_lod2;
-#endif
 
 #define NUM_JUMPPADSUSED 3
 .float jumppadcount;
@@ -601,3 +601,8 @@
 .float stat_leadlimit;
 
 float radar_showennemies;
+
+#ifdef PROFILING
+float client_cefc_accumulator;
+float client_cefc_accumulatortime;
+#endif

Modified: trunk/data/qcsrc/server/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/server/miscfunctions.qc	2009-06-30 17:33:35 UTC (rev 7133)
+++ trunk/data/qcsrc/server/miscfunctions.qc	2009-06-30 18:28:33 UTC (rev 7134)
@@ -1017,6 +1017,10 @@
     g_touchexplode_force = cvar("g_touchexplode_force");
 
     sv_clforceplayermodels = cvar("sv_clforceplayermodels");
+    sv_loddistance1 = cvar("sv_loddistance1");
+    sv_loddistance2 = cvar("sv_loddistance2");
+	if(sv_loddistance2 <= sv_loddistance1)
+		sv_loddistance2 = 1073741824; // enough to turn off LOD 2 reliably
     sv_clones = cvar("sv_clones");
     sv_cheats = cvar("sv_cheats");
     sv_gentle = cvar("sv_gentle");
@@ -1343,19 +1347,17 @@
     n = search_getsize(globhandle);
     for (i = 0; i < n; ++i)
     {
-        //print(search_getfilename(globhandle, i), "\n");
-        f = search_getfilename(globhandle, i);
-#ifdef ALLOW_VARIABLE_LOD
-        precache_model(f);
-#endif
-	if(substring(f, -9,5) == "_lod1")
-		continue;
-	if(substring(f, -9,5) == "_lod2")
-		continue;
-#ifndef ALLOW_VARIABLE_LOD
-        precache_model(f);
-#endif
-        PrecachePlayerSounds(strcat(f, ".sounds"));
+		//print(search_getfilename(globhandle, i), "\n");
+		f = search_getfilename(globhandle, i);
+		if(sv_loddistance1)
+			precache_model(f);
+		if(substring(f, -9,5) == "_lod1")
+			continue;
+		if(substring(f, -9,5) == "_lod2")
+			continue;
+		if(!sv_loddistance1)
+			precache_model(f);
+		PrecachePlayerSounds(strcat(f, ".sounds"));
     }
     search_end(globhandle);
 }

Modified: trunk/data/qcsrc/server/sv_main.qc
===================================================================
--- trunk/data/qcsrc/server/sv_main.qc	2009-06-30 17:33:35 UTC (rev 7133)
+++ trunk/data/qcsrc/server/sv_main.qc	2009-06-30 18:28:33 UTC (rev 7134)
@@ -138,6 +138,30 @@
 	servertime = time;
 	serverframetime = frametime;
 
+#ifdef PROFILING
+	if(time > client_cefc_accumulatortime + 1)
+	{
+		float t, pp, c_seeing, c_seen;
+		entity cl;
+		t = client_cefc_accumulator / (time - client_cefc_accumulatortime);
+		print("CEFC time: ", ftos(t * 1000), "ms; ");
+		c_seeing = 0;
+		c_seen = 0;
+		FOR_EACH_CLIENT(cl)
+		{
+			if(clienttype(cl) == CLIENTTYPE_REAL)
+				++c_seeing;
+			if(cl.classname == "player")
+				++c_seen;
+		}
+		print("CEFC calls per second: ", ftos(c_seeing * (c_seen - 1) / t), "; ");
+		print("CEFC 100% load at: ", ftos(solve_quadratic(t, -t, -1) * '0 1 0'), "\n");
+
+		client_cefc_accumulatortime = time;
+		client_cefc_accumulator = 0;
+	}
+#endif
+
 	dprint_load(); // load dprint status from cvar
 
 	entity e;



More information about the nexuiz-commits mailing list