Skip to content

Commit 52e62ee

Browse files
authored
Fix bullet penetration rendering multiple tracers (#1895)
* Draw at most 1 tracer per shot The bullet penetration logic is recursive, and this could cause bullets to render multiple tracers per one shot. Check that the current penetrating force of the shot equals the used weapon's original penetrating force, i.e. that no surfaces have yet been penetrated. This asserts that any penetrated surfaces will incur a non-zero penetration cost. * Remove dead code
1 parent b7e6a66 commit 52e62ee

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/game/shared/baseentity_shared.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1779,9 +1779,11 @@ void CBaseEntity::FireBullets( const FireBulletsInfo_t &info )
17791779
CShotManipulator Manipulator( info.m_vecDirShooting );
17801780
#endif
17811781

1782+
#ifndef NEO
17821783
bool bDoImpacts = false;
17831784
bool bDoTracers = false;
1784-
1785+
#endif
1786+
17851787
float flCumulativeDamage = 0.0f;
17861788

17871789
for (int iShot = 0; iShot < info.m_iShots; iShot++)
@@ -2050,10 +2052,12 @@ void CBaseEntity::FireBullets( const FireBulletsInfo_t &info )
20502052
{
20512053
DoImpactEffect( tr, nDamageType );
20522054
}
2055+
#ifndef NEO
20532056
else
20542057
{
20552058
bDoImpacts = true;
20562059
}
2060+
#endif
20572061
}
20582062
else
20592063
{
@@ -2107,6 +2111,19 @@ void CBaseEntity::FireBullets( const FireBulletsInfo_t &info )
21072111
}
21082112
#endif // NEO
21092113

2114+
#ifdef NEO
2115+
// The below penetration value check relies an all possible surfaces
2116+
// incurring a non-zero cost to m_flPenetration.
2117+
for (int i = 0; i < ARRAYSIZE(PENETRATION_RESISTANCE); ++i)
2118+
{
2119+
Assert(PENETRATION_RESISTANCE[i] > 0);
2120+
}
2121+
// Only draw tracers if we haven't yet penetrated, because the penetration logic is reentrant
2122+
// and would otherwise draw multiple tracers per shot.
2123+
Assert(neoWeapon);
2124+
if (neoWeapon->GetPenetration() == info.m_flPenetration)
2125+
{
2126+
#endif
21102127
if ( ( info.m_iTracerFreq != 0 ) && ( tracerCount++ % info.m_iTracerFreq ) == 0 && ( bHitGlass == false ) )
21112128
{
21122129
if ( bDoServerEffects == true )
@@ -2150,11 +2167,16 @@ void CBaseEntity::FireBullets( const FireBulletsInfo_t &info )
21502167
}
21512168
#endif //#ifdef PORTAL
21522169
}
2170+
#ifndef NEO
21532171
else
21542172
{
21552173
bDoTracers = true;
21562174
}
2175+
#endif
2176+
}
2177+
#ifdef NEO
21572178
}
2179+
#endif
21582180

21592181
//NOTENOTE: We could expand this to a more general solution for various material penetration types (wood, thin metal, etc)
21602182

0 commit comments

Comments
 (0)