// do trails
if (e->render.flags & RENDER_GLOWTRAIL)
trailtype = EFFECT_TR_GLOWTRAIL;
- // be sure to check for changes in e->state_previous.active and
- // modelindex so that entities which did not exist in the previous
- // frame don't create a trail from the start location
- if (trailtype && e->state_previous.active && e->state_previous.modelindex == e->state_current.modelindex)
+ // check if a trail is allowed (it is not after a teleport for example)
+ if (trailtype && e->persistent.trail_allowed)
{
float len;
vec3_t vel;
VectorScale(vel, len, vel);
CL_ParticleTrail(trailtype, 1, e->persistent.trail_origin, origin, vel, vel, e, e->state_current.glowcolor, false, true);
}
+ // now that the entity has survived one trail update it is allowed to
+ // leave a real trail on later frames
+ e->persistent.trail_allowed = true;
VectorCopy(origin, e->persistent.trail_origin);
}
// skip inactive entities and world
if (!e->state_current.active || e == cl.entities)
return;
- if (e->render.flags & RENDER_VIEWMODEL && !e->state_current.tagentity)
- {
- if (!r_drawviewmodel.integer || chase_active.integer || r_refdef.envmap)
- return;
- }
- else
+ if (e->state_current.tagentity)
{
// if the tag entity is currently impossible, skip it
if (e->state_current.tagentity >= cl.num_entities)
if (trailtype)
CL_ParticleTrail(trailtype, 0, origin, origin, vec3_origin, vec3_origin, NULL, e->state_current.glowcolor, true, false);
+ // don't show viewmodels in certain situations
+ if (e->render.flags & RENDER_VIEWMODEL)
+ if (!r_drawviewmodel.integer || chase_active.integer || r_refdef.envmap)
+ return;
// don't show entities with no modelindex (note: this still shows
// entities which have a modelindex that resolved to a NULL model)
if (e->render.model && !(e->render.effects & EF_NODRAW) && r_refdef.numentities < r_refdef.maxentities)
ent->render.framelerp = 1;
// reset various persistent stuff
ent->persistent.muzzleflash = 0;
+ ent->persistent.trail_allowed = false;
}
else if (DotProduct(odelta, odelta) > 1000*1000 || (cl.fixangle[0] && !cl.fixangle[1]))
{
VectorCopy(ent->state_current.angles, ent->persistent.oldangles);
VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
VectorCopy(ent->state_current.angles, ent->persistent.newangles);
+ ent->persistent.trail_allowed = false;
}
else if (ent->state_current.flags & RENDER_STEP)
{
part->time2 = 0;
part->airfriction = pairfriction;
part->liquidfriction = pliquidfriction;
+ part->delayedcollisions = 0;
return part;
}
int supercontents;
int tex;
particleeffectinfo_t *info;
+ particle_t *p;
vec3_t center;
vec3_t centervelocity;
vec3_t traildir;
vec_t traillen;
vec_t trailstep;
qboolean underwater;
+ trace_t trace;
// note this runs multiple effects with the same name, each one spawns only one kind of particle, so some effects need more than one
VectorLerp(originmins, 0.5, originmaxs, center);
VectorLerp(velocitymins, 0.5, velocitymaxs, centervelocity);
trailpos[2] = lhrandom(originmins[2], originmaxs[2]);
}
VectorRandom(rvec);
- particle(particletype + info->particletype, info->color[0], info->color[1], tex, lhrandom(info->size[0], info->size[1]), info->size[2], lhrandom(info->alpha[0], info->alpha[1]), info->alpha[2], info->gravity, info->bounce, trailpos[0] + info->originoffset[0] + info->originjitter[0] * rvec[0], trailpos[1] + info->originoffset[1] + info->originjitter[1] * rvec[1], trailpos[2] + info->originoffset[2] + info->originjitter[2] * rvec[2], lhrandom(velocitymins[0], velocitymaxs[0]) * info->velocitymultiplier + info->velocityoffset[0] + info->velocityjitter[0] * rvec[0], lhrandom(velocitymins[1], velocitymaxs[1]) * info->velocitymultiplier + info->velocityoffset[1] + info->velocityjitter[1] * rvec[1], lhrandom(velocitymins[2], velocitymaxs[2]) * info->velocitymultiplier + info->velocityoffset[2] + info->velocityjitter[2] * rvec[2], info->airfriction, info->liquidfriction, 0, 0);
+ p = particle(particletype + info->particletype, info->color[0], info->color[1], tex, lhrandom(info->size[0], info->size[1]), info->size[2], lhrandom(info->alpha[0], info->alpha[1]), info->alpha[2], info->gravity, info->bounce, trailpos[0] + info->originoffset[0] + info->originjitter[0] * rvec[0], trailpos[1] + info->originoffset[1] + info->originjitter[1] * rvec[1], trailpos[2] + info->originoffset[2] + info->originjitter[2] * rvec[2], lhrandom(velocitymins[0], velocitymaxs[0]) * info->velocitymultiplier + info->velocityoffset[0] + info->velocityjitter[0] * rvec[0], lhrandom(velocitymins[1], velocitymaxs[1]) * info->velocitymultiplier + info->velocityoffset[1] + info->velocityjitter[1] * rvec[1], lhrandom(velocitymins[2], velocitymaxs[2]) * info->velocitymultiplier + info->velocityoffset[2] + info->velocityjitter[2] * rvec[2], info->airfriction, info->liquidfriction, 0, 0);
+ // if it is rain or snow, trace ahead and shut off collisions until an actual collision event needs to occur to improve performance
+ if (info->bounce != 0 && info->gravity == 0)
+ {
+ float lifetime = p->alpha / (p->alphafade ? p->alphafade : 1);
+ VectorMA(p->org, lifetime, p->vel, rvec);
+ trace = CL_Move(p->org, vec3_origin, vec3_origin, rvec, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | ((info->particletype == pt_rain || info->particletype == pt_snow) ? SUPERCONTENTS_LIQUIDSMASK : 0), true, false, NULL, false);
+ p->delayedcollisions = cl.time + lifetime * trace.fraction - 0.1;
+ }
if (trailstep)
VectorMA(trailpos, trailstep, traildir, trailpos);
}
VectorCopy(p->org, oldorg);
VectorMA(p->org, frametime, p->vel, p->org);
VectorCopy(p->org, org);
- if (p->bounce)
+ if (p->bounce && cl.time >= p->delayedcollisions)
{
trace = CL_Move(oldorg, vec3_origin, vec3_origin, p->org, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID | SUPERCONTENTS_BODY | (p->type == particletype + pt_rain ? SUPERCONTENTS_LIQUIDSMASK : 0), true, false, &hitent, false);
// if the trace started in or hit something of SUPERCONTENTS_NODROP