summaryrefslogtreecommitdiff
path: root/src/cgame/cg_particles.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgame/cg_particles.c')
-rw-r--r--src/cgame/cg_particles.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/cgame/cg_particles.c b/src/cgame/cg_particles.c
index 44a309ea..1e9ac1fe 100644
--- a/src/cgame/cg_particles.c
+++ b/src/cgame/cg_particles.c
@@ -1549,7 +1549,7 @@ static void CG_GarbageCollectParticleSystems( void )
//check systems where the parent cent has left the PVS
//( centNum 0 - player entity, is always valid )
- if( ps->attachType == PSA_CENT_ORIGIN && ps->attachment.centNum != 0 )
+ if( ps->attachment.centValid && ps->attachment.centNum != 0 )
{
if( !cg_entities[ ps->attachment.centNum ].valid )
ps->valid = qfalse;
@@ -1800,10 +1800,17 @@ static void CG_CompactAndSortParticles( void )
for( i = 0; i < numParticles; i++ )
{
VectorSubtract( particles[ i ].origin, cg.refdef.vieworg, delta );
- particles[ i ].sortKey = DotProduct( delta, delta );
+ particles[ i ].sortKey = (int)DotProduct( delta, delta );
}
CG_RadixSort( particles, sortParticles, numParticles );
+
+ //reverse order of particles array
+ for( i = 0; i < numParticles; i++ )
+ sortParticles[ i ] = particles[ numParticles - i - 1 ];
+
+ for( i = 0; i < numParticles; i++ )
+ particles[ i ] = sortParticles[ i ];
}
/*
@@ -1942,3 +1949,35 @@ void CG_AddParticles( void )
CG_Printf( "PS: %d PE: %d P: %d\n", numPS, numPE, numP );
}
}
+
+/*
+===============
+CG_ParticleSystemEntity
+
+Particle system entity client code
+===============
+*/
+void CG_ParticleSystemEntity( centity_t *cent )
+{
+ entityState_t *es;
+
+ es = &cent->currentState;
+
+ if( es->eFlags & EF_NODRAW )
+ {
+ if( cent->entityPS != NULL && CG_IsParticleSystemInfinite( cent->entityPS ) )
+ CG_DestroyParticleSystem( cent->entityPS );
+
+ cent->entityPS = NULL;
+
+ return;
+ }
+
+ if( cent->entityPS == NULL )
+ {
+ cent->entityPS = CG_SpawnNewParticleSystem( cgs.gameParticleSystems[ es->modelindex ] );
+ CG_SetParticleSystemOrigin( cent->entityPS, cent->lerpOrigin );
+ CG_SetParticleSystemCent( cent->entityPS, cent );
+ CG_AttachParticleSystemToOrigin( cent->entityPS );
+ }
+}