From f2274c41c0efb722b47722c07c9e90091aa9a7e3 Mon Sep 17 00:00:00 2001
From: divverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Date: Thu, 9 Sep 2010 06:55:01 +0000
Subject: [PATCH] remove sparks if slower than sqrt(0.03)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10450 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=a47d6d807b1b080ae1c56e6c17c2fec217cd8e89
---
 cl_particles.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/cl_particles.c b/cl_particles.c
index 5fdde506..34489597 100644
--- a/cl_particles.c
+++ b/cl_particles.c
@@ -2795,7 +2795,7 @@ void R_DrawParticles (void)
 				VectorCopy(p->org, oldorg);
 				VectorMA(p->org, frametime, p->vel, p->org);
 //				if (p->bounce && cl.time >= p->delayedcollisions)
-				if (p->bounce && cl_particles_collisions.integer)
+				if (p->bounce && cl_particles_collisions.integer && VectorLength(p->vel))
 				{
 					trace = CL_TraceLine(oldorg, p->org, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | ((p->typeindex == pt_rain || p->typeindex == pt_snow) ? SUPERCONTENTS_LIQUIDSMASK : 0), true, false, &hitent, false);
 					// if the trace started in or hit something of SUPERCONTENTS_NODROP
@@ -2852,11 +2852,16 @@ void R_DrawParticles (void)
 							// anything else - bounce off solid
 							dist = DotProduct(p->vel, trace.plane.normal) * -p->bounce;
 							VectorMA(p->vel, dist, trace.plane.normal, p->vel);
-							if (DotProduct(p->vel, p->vel) < 0.03)
-								VectorClear(p->vel);
 						}
 					}
 				}
+
+				if (VectorLength2(p->vel) < 0.03)
+				{
+					if(p->orientation == PARTICLE_SPARK) // sparks are virtually invisible if very slow, so rather let them go off
+						goto killparticle;
+					VectorClear(p->vel);
+				}
 			}
 
 			if (p->typeindex != pt_static)
-- 
2.39.5