From: divverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Date: Fri, 2 Jan 2009 14:03:51 +0000 (+0000)
Subject: made particle PVS culling only take the origin into account; that way, it actually... 
X-Git-Tag: xonotic-v0.1.0preview~1972
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0bad55fc268115cefba114e2c8e64f6eaac07d64;p=xonotic%2Fdarkplaces.git

made particle PVS culling only take the origin into account; that way, it actually is a minor performance gain without any visible quality loss


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

diff --git a/cl_particles.c b/cl_particles.c
index 48b26a9b..5c7e4460 100644
--- a/cl_particles.c
+++ b/cl_particles.c
@@ -192,7 +192,7 @@ cvar_t cl_particles_smoke_alpha = {CVAR_SAVE, "cl_particles_smoke_alpha", "0.5",
 cvar_t cl_particles_smoke_alphafade = {CVAR_SAVE, "cl_particles_smoke_alphafade", "0.55", "brightness fade per second"};
 cvar_t cl_particles_sparks = {CVAR_SAVE, "cl_particles_sparks", "1", "enables sparks (used by multiple effects)"};
 cvar_t cl_particles_bubbles = {CVAR_SAVE, "cl_particles_bubbles", "1", "enables bubbles (used by multiple effects)"};
-cvar_t cl_particles_novis = {CVAR_SAVE, "cl_particles_novis", "1", "when disabled, particles use vis data too (sometimes causes bad quality or missing effects)"};
+cvar_t cl_particles_novis = {CVAR_SAVE, "cl_particles_novis", "0", "turn off PVS culling of particles"};
 cvar_t cl_decals = {CVAR_SAVE, "cl_decals", "1", "enables decals (bullet holes, blood, etc)"};
 cvar_t cl_decals_time = {CVAR_SAVE, "cl_decals_time", "20", "how long before decals start to fade away"};
 cvar_t cl_decals_fadetime = {CVAR_SAVE, "cl_decals_fadetime", "1", "how long decals take to fade away"};
@@ -2065,14 +2065,12 @@ void R_DrawDecals (void)
 		{
 			if(!cl_particles_novis.integer)
 				if (!r_refdef.viewcache.world_novis)
-					if(r_refdef.scene.worldmodel->brush.BoxTouchingPVS)
+					if(r_refdef.scene.worldmodel->brush.PointInLeaf)
 					{
-						vec3_t mins, maxs, unit;
-						VectorSet(unit, 1, 1, 1);
-						VectorMA(decal->org, -decal->size, unit, mins);
-						VectorMA(decal->org, +decal->size, unit, maxs);
-						if(!r_refdef.scene.worldmodel->brush.BoxTouchingPVS(r_refdef.scene.worldmodel, r_refdef.viewcache.world_pvsbits, mins, maxs))
-							continue;
+						mleaf_t *leaf = r_refdef.scene.worldmodel->brush.PointInLeaf(r_refdef.scene.worldmodel, decal->org);
+						if(leaf)
+							if(!CHECKPVSBIT(r_refdef.viewcache.world_pvsbits, leaf->clusterindex))
+								continue;
 					}
 			R_MeshQueue_AddTransparent(decal->org, R_DrawDecal_TransparentCallback, NULL, i, NULL);
 		}
@@ -2468,14 +2466,12 @@ void R_DrawParticles (void)
 		default:
 			if(!cl_particles_novis.integer)
 				if (!r_refdef.viewcache.world_novis)
-					if(r_refdef.scene.worldmodel->brush.BoxTouchingPVS)
+					if(r_refdef.scene.worldmodel->brush.PointInLeaf)
 					{
-						vec3_t mins, maxs, unit;
-						VectorSet(unit, 1, 1, 1);
-						VectorMA(p->org, -p->size, unit, mins);
-						VectorMA(p->org, +p->size, unit, maxs);
-						if(!r_refdef.scene.worldmodel->brush.BoxTouchingPVS(r_refdef.scene.worldmodel, r_refdef.viewcache.world_pvsbits, mins, maxs))
-							continue;
+						mleaf_t *leaf = r_refdef.scene.worldmodel->brush.PointInLeaf(r_refdef.scene.worldmodel, p->org);
+						if(leaf)
+							if(!CHECKPVSBIT(r_refdef.viewcache.world_pvsbits, leaf->clusterindex))
+								continue;
 					}
 			// anything else just has to be in front of the viewer and visible at this distance
 			if (DotProduct(p->org, r_refdef.view.forward) >= minparticledist && VectorDistance2(p->org, r_refdef.view.origin) < drawdist2 * (p->size * p->size))