Skip to content

Commit

Permalink
cgame: Fix antigrav particles falling on the slopes and simplify slop…
Browse files Browse the repository at this point in the history
…e detection check on debris particles
  • Loading branch information
LegendaryGuard committed Nov 14, 2024
1 parent 748e76e commit 16c823a
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions source/cgame/cg_particles.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,17 +440,40 @@ void CG_AddParticleToScene (cparticle_t *p, vec3_t org, float alpha)
}
else // bouncing
{
// if the particle is touching a mover and moves down, so keep bouncing
if ( trace.fraction <= 0 ) {
p->roll = 6;
if ( trace.plane.normal[2] > 0.1
&& trace.plane.normal[2] < 0.95 ) { // detect position on the slopes
VectorCopy (org, p->org);
// if the particle is touching a mover and moves down, so keep bouncing
if ( p->roll > 0 ) {
p->vel[2] = 50 * p->roll;
p->accel[2] = 50 * p->roll;
p->roll--; // that decreases bounces
}
if ( p->roll <= 0 ) { // stop
p->vel[2] = 0;
p->accel[2] = 0;
} else { // keep detecting the position
VectorCopy (trace.endpos, p->org);
}
} else {
p->vel[2] = p->accel[2] = (p->roll > 0) ? 50 * p->roll : 0;
p->roll--; // that decreases bounces
if ( trace.plane.normal[2] < 0.95 ) { // for slopes
VectorCopy (org, p->org);
}
// if the particle is touching a mover and moves down, so keep bouncing
if ( trace.fraction <= 0 ) {
p->roll = 6;
} else {
if ( p->roll > 0 ) {
p->vel[2] = 50 * p->roll;
p->accel[2] = 50 * p->roll;
p->roll--; // that decreases bounces
}
}
if ( p->roll <= 0 ) { // keep detecting the position
VectorCopy (trace.endpos, p->org);
}
}
}
if ( p->roll <= 0 ) { // keep detecting the position
VectorCopy (trace.endpos, p->org);
}
}

// BFP - When reaching into this top, remove the particle!
Expand All @@ -465,7 +488,6 @@ void CG_AddParticleToScene (cparticle_t *p, vec3_t org, float alpha)
// BFP - To detect if there is something solid
trace_t trace;
vec3_t debrisMins = {0, 0, -1}; // place a bit above
vec3_t up = {0, 0, 1};
int contents;
// contents should be CONTENTS_SOLID, so the particles don't touch any entity like the player
CG_Trace( &trace, p->org, debrisMins, debrisMins, org, -1, CONTENTS_SOLID );
Expand All @@ -491,8 +513,7 @@ void CG_AddParticleToScene (cparticle_t *p, vec3_t org, float alpha)
}
else // bouncing
{
// if it's on a slope
if ( DotProduct( trace.plane.normal, up ) < 0.7 ) {
if ( trace.plane.normal[2] < 0.7 ) { // if it's on a slope
if ( fabs( p->vel[2] ) < 1 ) {
VectorClear( p->accel );
VectorClear( p->vel );
Expand Down

0 comments on commit 16c823a

Please sign in to comment.