Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions code/cgame/cg_cvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ CG_CVAR( cg_crosshairY, "cg_crosshairY", "0", CVAR_ARCHIVE )
CG_CVAR( cg_brassTime, "cg_brassTime", "2500", CVAR_ARCHIVE )
CG_CVAR( cg_simpleItems, "cg_simpleItems", "0", CVAR_ARCHIVE )
CG_CVAR( cg_addMarks, "cg_marks", "1", CVAR_ARCHIVE )
// Note that ~290 corresponds to a free fall with no bounce from player height.
CG_CVAR( cg_bounceMarksMinImpactSpeed, "cg_bounceMarksMinImpactSpeed", "350", CVAR_ARCHIVE )
CG_CVAR( cg_bounceSoundMinImpactSpeed, "cg_bounceSoundMinImpactSpeed", "450", CVAR_ARCHIVE )
CG_CVAR( cg_lagometer, "cg_lagometer", "1", CVAR_ARCHIVE )
CG_CVAR( cg_railTrailTime, "cg_railTrailTime", "400", CVAR_ARCHIVE )
CG_CVAR( cg_railTrailRadius, "cg_railTrailRadius", "0", CVAR_ARCHIVE )
Expand Down
42 changes: 28 additions & 14 deletions code/cgame/cg_localents.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ void CG_FragmentBounceMark( localEntity_t *le, trace_t *trace ) {
}


// don't allow a fragment to make multiple marks, or they
// pile up while settling
le->leMarkType = LEMT_NONE;
// This is no longer needed, because we now decide whether to leave a mark
// purely based on impact velocity.
// // don't allow a fragment to make multiple marks, or they
// // pile up while settling
// le->leMarkType = LEMT_NONE;
}

/*
Expand Down Expand Up @@ -179,18 +181,22 @@ void CG_FragmentBounceSound( localEntity_t *le, trace_t *trace ) {

}

// don't allow a fragment to make multiple bounce sounds,
// or it gets too noisy as they settle
le->leBounceSoundType = LEBS_NONE;
// This is no longer needed, because we now decide whether to play a sound
// purely based on impact velocity.
// // don't allow a fragment to make multiple bounce sounds,
// // or it gets too noisy as they settle
// le->leBounceSoundType = LEBS_NONE;
}


/*
================
CG_ReflectVelocity

Modifies velocity of `le` and writes the difference to `velocityDifference`
================
*/
void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) {
void CG_ReflectVelocity( localEntity_t *le, trace_t *trace, vec3_t velocityDifference ) {
vec3_t velocity;
float dot;
int hitTime;
Expand All @@ -203,6 +209,10 @@ void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) {

VectorScale( le->pos.trDelta, le->bounceFactor, le->pos.trDelta );

if (velocityDifference) {
VectorSubtract( le->pos.trDelta, velocity, velocityDifference );
}

VectorCopy( trace->endpos, le->pos.trBase );
le->pos.trTime = cg.time;

Expand All @@ -223,7 +233,7 @@ CG_AddFragment
================
*/
static void CG_AddFragment( localEntity_t *le ) {
vec3_t newOrigin;
vec3_t newOrigin, impactVelocityDiff;
trace_t trace;

if ( le->pos.trType == TR_STATIONARY ) {
Expand Down Expand Up @@ -283,14 +293,18 @@ static void CG_AddFragment( localEntity_t *le ) {
return;
}

// leave a mark
CG_FragmentBounceMark( le, &trace );
// reflect the velocity on the trace plane
CG_ReflectVelocity( le, &trace, impactVelocityDiff );

// do a bouncy sound
CG_FragmentBounceSound( le, &trace );
if ( VectorLengthSquared( impactVelocityDiff ) >= Square( cg_bounceMarksMinImpactSpeed.value ) ) {
// leave a mark
CG_FragmentBounceMark( le, &trace );
}

// reflect the velocity on the trace plane
CG_ReflectVelocity( le, &trace );
if ( VectorLengthSquared( impactVelocityDiff ) >= Square( cg_bounceSoundMinImpactSpeed.value ) ) {
// do a bouncy sound
CG_FragmentBounceSound( le, &trace );
}

trap_R_AddRefEntityToScene( &le->refEntity );
}
Expand Down