From 9d4586b532f259a0764f84c570509651670c8f9d Mon Sep 17 00:00:00 2001 From: TimeServ Date: Sat, 18 Jun 2011 12:25:36 +0000 Subject: [PATCH] delink particle states on r_particlesystem change, correctly use default trails on models git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3822 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_ents.c | 16 ++++++++++++---- engine/client/cl_tent.c | 11 +++++++++++ engine/client/client.h | 2 ++ engine/client/pr_csqc.c | 7 ++++--- engine/client/r_part.c | 6 ++++++ 5 files changed, 35 insertions(+), 7 deletions(-) diff --git a/engine/client/cl_ents.c b/engine/client/cl_ents.c index 04bd3c5d2..e29ffafd5 100644 --- a/engine/client/cl_ents.c +++ b/engine/client/cl_ents.c @@ -1590,6 +1590,16 @@ static void CL_UpdateNetFrameLerpState(qboolean force, unsigned int curframe, le } } +void CL_ClearLerpEntsParticleState(void) +{ + int i; + for (i = 0; i < cl.maxlerpents; i++) + { + pe->DelinkTrailstate(&(cl.lerpents[i].trailstate)); + pe->DelinkTrailstate(&(cl.lerpents[i].emitstate)); + } +} + void CL_LinkStaticEntities(void *pvs) { int i; @@ -2198,11 +2208,9 @@ void CL_LinkPacketEntities (void) } } - if (model->particletrail >= 0) - { - if (pe->ParticleTrail (old_origin, ent->origin, model->particletrail, &(le->trailstate))) + if (model->particletrail == P_INVALID || pe->ParticleTrail (old_origin, ent->origin, model->particletrail, &(le->trailstate))) + if (model->traildefaultindex >= 0) pe->ParticleTrailIndex(old_origin, ent->origin, model->traildefaultindex, 0, &(le->trailstate)); - } { extern cvar_t gl_part_flame; diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index a97aa87d4..efed486e3 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -346,6 +346,17 @@ void CL_ShutdownTEnts (void) BZ_Free(ae); } } + +void CL_ClearTEntParticleState (void) +{ + int i; + for (i = 0; i < beams_running; i++) + { + pe->DelinkTrailstate(&(cl_beams[i].trailstate)); + pe->DelinkTrailstate(&(cl_beams[i].emitstate)); + } +} + void P_LoadedModel(model_t *mod) { struct associatedeffect *ae; diff --git a/engine/client/client.h b/engine/client/client.h index 926a318be..69c73f9fb 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -973,6 +973,7 @@ void DropPunchAngle (int pnum); void CL_RegisterParticles(void); void CL_InitTEnts (void); void CL_ClearTEnts (void); +void CL_ClearTEntParticleState (void); void CL_ClearCustomTEnts(void); void CL_ParseCustomTEnt(void); void CL_ParseEffect (qboolean effect2); @@ -1005,6 +1006,7 @@ void CL_LinkViewModel(void); void CL_LinkPlayers (void); void CL_LinkPacketEntities (void); void CL_LinkProjectiles (void); +void CL_ClearLerpEntsParticleState (void); qboolean CL_MayLerp(void); // diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index badfaa45d..d0c4a9f1b 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -4048,10 +4048,11 @@ void CSQC_EntStateToCSQC(unsigned int flags, float lerptime, entity_state_t *src if (!(flags & RSES_NOTRAILS)) { //use entnum as a test to see if its new (if the old origin isn't usable) - if (ent->xv->entnum && model->particletrail >= 0) + if (ent->xv->entnum) { - if (pe->ParticleTrail (ent->v->origin, src->origin, model->particletrail, &(le->trailstate))) - pe->ParticleTrailIndex(ent->v->origin, src->origin, model->traildefaultindex, 0, &(le->trailstate)); + if (model->particletrail == P_INVALID || pe->ParticleTrail (ent->v->origin, src->origin, model->particletrail, &(le->trailstate))) + if (model->traildefaultindex >= 0) + pe->ParticleTrailIndex(ent->v->origin, src->origin, model->traildefaultindex, 0, &(le->trailstate)); } } diff --git a/engine/client/r_part.c b/engine/client/r_part.c index 92c9acc8c..b2842262b 100644 --- a/engine/client/r_part.c +++ b/engine/client/r_part.c @@ -82,6 +82,9 @@ void R_ParticleSystem_Callback(struct cvar_s *var, char *oldvalue) int i; if (pe) { + CL_ClearTEntParticleState(); + CL_ClearLerpEntsParticleState(); + pe->ShutdownParticles(); } @@ -444,5 +447,8 @@ void P_DefaultTrail (model_t *model) model->traildefaultindex = 254; } else + { model->particletrail = P_INVALID; + model->traildefaultindex = -1; + } }