Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
Changed CL_CalcPartVelocity() signature to avoid unnecessary pass-by-…
Browse files Browse the repository at this point in the history
…pointer.
  • Loading branch information
m-x-d committed Jul 16, 2019
1 parent 4f19f11 commit 3a88e74
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/cl_effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ CL_ParticleBloodDropThink
*/
void CL_ParticleBloodDropThink (cparticle_t *p, vec3_t org, vec3_t angle, float *alpha, float *size, int *image, float *time)
{
CL_CalcPartVelocity(p, 0.2, time, angle);
CL_CalcPartVelocity(p, 0.2f, *time, angle);

float length = VectorNormalize(angle);
if (length > MAXBLEEDSIZE) length = MAXBLEEDSIZE;
Expand Down
11 changes: 5 additions & 6 deletions client/cl_particle.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,15 +523,14 @@ void CL_ClearParticles (void)
CL_CalcPartVelocity
===============
*/
void CL_CalcPartVelocity (cparticle_t *p, float scale, float *time, vec3_t velocity)
void CL_CalcPartVelocity(cparticle_t *p, const float scale, const float time, vec3_t velocity)
{
const float time1 = *time;
const float time2 = time1 * time1;
const float timesq = time * time;
const int gravity = (p->flags & PART_GRAVITY ? PARTICLE_GRAVITY : 0); //mxd

for (int i = 0; i < 2; i++)
velocity[i] = scale * (p->vel[i] * time1 + p->accel[i] * time2);
velocity[2] = scale * (p->vel[2] * time1 + (p->accel[2] - gravity) * time2);
velocity[i] = scale * (p->vel[i] * time + p->accel[i] * timesq);
velocity[2] = scale * (p->vel[2] * time + (p->accel[2] - gravity) * timesq);
}

/*
Expand Down Expand Up @@ -565,7 +564,7 @@ void CL_ParticleBounceThink (cparticle_t *p, vec3_t org, vec3_t angle, float *al
if (tr.fraction < 1)
{
vec3_t velocity;
CL_CalcPartVelocity(p, 1, time, velocity);
CL_CalcPartVelocity(p, 1.0f, *time, velocity);
CL_ClipParticleVelocity(velocity, tr.plane.normal, p->vel);

VectorCopy(vec3_origin, p->accel);
Expand Down
2 changes: 1 addition & 1 deletion client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ cparticle_t *CL_SetupParticle (

void CL_AddParticleLight(cparticle_t *p, float light, float lightvel, float lcol0, float lcol1, float lcol2);

void CL_CalcPartVelocity(cparticle_t *p, float scale, float *time, vec3_t velocity);
void CL_CalcPartVelocity(cparticle_t *p, const float scale, const float time, vec3_t velocity);
void CL_ParticleBounceThink(cparticle_t *p, vec3_t org, vec3_t angle, float *alpha, float *size, int *image, float *time);
void CL_ParticleRotateThink(cparticle_t *p, vec3_t org, vec3_t angle, float *alpha, float *size, int *image, float *time);
void CL_DecalAlphaThink(cparticle_t *p, vec3_t org, vec3_t angle, float *alpha, float *size, int *image, float *time);
Expand Down

0 comments on commit 3a88e74

Please sign in to comment.