Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix collision (knife, bullet, blood) by limiting NT collide check to only movement #689

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
28 changes: 21 additions & 7 deletions mp/src/game/shared/gamemovement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,20 @@ Vector CGameMovement::GetPlayerViewOffset( bool ducked ) const
#endif
}

inline void UTIL_TraceRayMovement( const Ray_t &ray, unsigned int mask,
const IHandleEntity *ignore, int collisionGroup, trace_t *ptr, ShouldHitFunc_t pExtraShouldHitCheckFn = NULL )
{
CTraceFilterSimple traceFilter( ignore, collisionGroup, pExtraShouldHitCheckFn );
traceFilter.m_bIgnoreNeoCollide = false;

enginetrace->TraceRay( ray, mask, &traceFilter, ptr );

if( r_visualizetraces.GetBool() )
{
DebugDrawLine( ptr->startpos, ptr->endpos, 255, 0, 0, true, -1.0f );
}
}

#if 0
//-----------------------------------------------------------------------------
// Traces player movement + position
Expand All @@ -819,7 +833,7 @@ CBaseHandle CGameMovement::TestPlayerPosition( const Vector& pos, int collisionG
{
Ray_t ray;
ray.Init( pos, pos, GetPlayerMins(), GetPlayerMaxs() );
UTIL_TraceRay( ray, PlayerSolidMask(), mv->m_nPlayerHandle.Get(), collisionGroup, &pm );
UTIL_TraceRayMovement( ray, PlayerSolidMask(), mv->m_nPlayerHandle.Get(), collisionGroup, &pm );
if ( (pm.contents & PlayerSolidMask()) && pm.m_pEnt )
{
return pm.m_pEnt->GetRefEHandle();
Expand Down Expand Up @@ -3738,7 +3752,7 @@ void TracePlayerBBoxForGround( const Vector& start, const Vector& end, const Vec
mins = minsSrc;
maxs.Init( MIN( 0, maxsSrc.x ), MIN( 0, maxsSrc.y ), maxsSrc.z );
ray.Init( start, end, mins, maxs );
UTIL_TraceRay( ray, fMask, player, collisionGroup, &pm );
UTIL_TraceRayMovement( ray, fMask, player, collisionGroup, &pm );
if ( pm.m_pEnt && pm.plane.normal[2] >= 0.7)
{
pm.fraction = fraction;
Expand All @@ -3750,7 +3764,7 @@ void TracePlayerBBoxForGround( const Vector& start, const Vector& end, const Vec
mins.Init( MAX( 0, minsSrc.x ), MAX( 0, minsSrc.y ), minsSrc.z );
maxs = maxsSrc;
ray.Init( start, end, mins, maxs );
UTIL_TraceRay( ray, fMask, player, collisionGroup, &pm );
UTIL_TraceRayMovement( ray, fMask, player, collisionGroup, &pm );
if ( pm.m_pEnt && pm.plane.normal[2] >= 0.7)
{
pm.fraction = fraction;
Expand All @@ -3762,7 +3776,7 @@ void TracePlayerBBoxForGround( const Vector& start, const Vector& end, const Vec
mins.Init( minsSrc.x, MAX( 0, minsSrc.y ), minsSrc.z );
maxs.Init( MIN( 0, maxsSrc.x ), maxsSrc.y, maxsSrc.z );
ray.Init( start, end, mins, maxs );
UTIL_TraceRay( ray, fMask, player, collisionGroup, &pm );
UTIL_TraceRayMovement( ray, fMask, player, collisionGroup, &pm );
if ( pm.m_pEnt && pm.plane.normal[2] >= 0.7)
{
pm.fraction = fraction;
Expand All @@ -3774,7 +3788,7 @@ void TracePlayerBBoxForGround( const Vector& start, const Vector& end, const Vec
mins.Init( MAX( 0, minsSrc.x ), minsSrc.y, minsSrc.z );
maxs.Init( maxsSrc.x, MIN( 0, maxsSrc.y ), maxsSrc.z );
ray.Init( start, end, mins, maxs );
UTIL_TraceRay( ray, fMask, player, collisionGroup, &pm );
UTIL_TraceRayMovement( ray, fMask, player, collisionGroup, &pm );
if ( pm.m_pEnt && pm.plane.normal[2] >= 0.7)
{
pm.fraction = fraction;
Expand Down Expand Up @@ -5109,7 +5123,7 @@ void CGameMovement::TracePlayerBBox( const Vector& start, const Vector& end, uns

Ray_t ray;
ray.Init( start, end, GetPlayerMins(), GetPlayerMaxs() );
UTIL_TraceRay( ray, fMask, mv->m_nPlayerHandle.Get(), collisionGroup, &pm );
UTIL_TraceRayMovement( ray, fMask, mv->m_nPlayerHandle.Get(), collisionGroup, &pm );

}

Expand All @@ -5124,6 +5138,6 @@ void CGameMovement::TryTouchGround( const Vector& start, const Vector& end, con

Ray_t ray;
ray.Init( start, end, mins, maxs );
UTIL_TraceRay( ray, fMask, mv->m_nPlayerHandle.Get(), collisionGroup, &pm );
UTIL_TraceRayMovement( ray, fMask, mv->m_nPlayerHandle.Get(), collisionGroup, &pm );
}

4 changes: 1 addition & 3 deletions mp/src/game/shared/neo/neo_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,7 @@ bool CNEORules::ShouldCollide(const CBaseEntity *ent0, const CBaseEntity *ent1)
const int ent0Group = ent0->GetCollisionGroup();
const int ent1Group = ent1->GetCollisionGroup();
const int iNeoCol = neo_sv_collision.GetInt();
if (iNeoCol != NEOCOLLISION_ALL &&
(ent0Group == COLLISION_GROUP_PLAYER || ent0Group == COLLISION_GROUP_PLAYER_MOVEMENT) &&
(ent1Group == COLLISION_GROUP_PLAYER || ent1Group == COLLISION_GROUP_PLAYER_MOVEMENT))
if (iNeoCol != NEOCOLLISION_ALL && ent0Group == COLLISION_GROUP_PLAYER && ent1Group == COLLISION_GROUP_PLAYER)
{
return (iNeoCol == NEOCOLLISION_TEAM) ?
(static_cast<const CNEO_Player *>(ent0)->GetTeamNumber() != static_cast<const CNEO_Player *>(ent1)->GetTeamNumber()) :
Expand Down
5 changes: 4 additions & 1 deletion mp/src/game/shared/util_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ bool StandardFilterRules( IHandleEntity *pHandleEntity, int fContentsMask )
CTraceFilterSimple::CTraceFilterSimple( const IHandleEntity *passedict, int collisionGroup,
ShouldHitFunc_t pExtraShouldHitFunc )
{
#ifdef NEO
m_bIgnoreNeoCollide = true;
#endif
m_pPassEnt = passedict;
m_collisionGroup = collisionGroup;
m_pExtraShouldHitCheckFunction = pExtraShouldHitFunc;
Expand Down Expand Up @@ -306,7 +309,7 @@ bool CTraceFilterSimple::ShouldHitEntity( IHandleEntity *pHandleEntity, int cont
if ( !pEntity->ShouldCollide( m_collisionGroup, contentsMask ) )
return false;
#ifdef NEO
if (m_pPassEnt)
if (!m_bIgnoreNeoCollide && m_pPassEnt)
{
const CBaseEntity *pThisEntity = EntityFromEntityHandle(m_pPassEnt);
if (pEntity && pThisEntity && !static_cast<CNEORules *>(g_pGameRules)->ShouldCollide(pThisEntity, pEntity))
Expand Down
3 changes: 3 additions & 0 deletions mp/src/game/shared/util_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ class CTraceFilterSimple : public CTraceFilter
virtual void SetCollisionGroup( int iCollisionGroup ) { m_collisionGroup = iCollisionGroup; }

const IHandleEntity *GetPassEntity( void ){ return m_pPassEnt;}
#ifdef NEO
bool m_bIgnoreNeoCollide;
#endif

private:
const IHandleEntity *m_pPassEnt;
Expand Down