summaryrefslogtreecommitdiff
path: root/src/cgame/cg_particles.c
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2003-10-12 01:20:50 +0000
committerTim Angus <tim@ngus.net>2003-10-12 01:20:50 +0000
commit62b02963091831dbd7fb21800e36841680d63e98 (patch)
treed557ed06a6e41120c11fcd0ffe2e5ad96a1db869 /src/cgame/cg_particles.c
parenta5c56eb6cf0c0f8e3ec88f68861d79b6a0586b79 (diff)
* Added misc_particle_system entity
* Fixed depth sorting to sort in the correct direction * Particle system PVS garbage collection improved * cent validity is now computed before adding cents to scene
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 );
+ }
+}