Skip to content

Commit

Permalink
Fix collision with ir-relevant to player/movements
Browse files Browse the repository at this point in the history
  • Loading branch information
nullsystem committed Oct 10, 2024
1 parent 68ffa08 commit b36724c
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ class CNEOTraceFilterCollisionGroupDelta : public CTraceFilterEntitiesOnly
int m_newCollisionGroup;
};

#endif // NEO_TRACEFILTER_COLLISIONGROUPDELTA_H
#endif // NEO_TRACEFILTER_COLLISIONGROUPDELTA_H
1 change: 0 additions & 1 deletion mp/src/game/server/physics_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ class CTraceFilterPushFinal : public CTraceFilterSimple
CTraceFilterPushFinal( CBaseEntity *pEntity, int nCollisionGroup )
: CTraceFilterSimple( pEntity, nCollisionGroup )
{

}

bool ShouldHitEntity( IHandleEntity *pHandleEntity, int contentsMask )
Expand Down
2 changes: 1 addition & 1 deletion mp/src/game/server/pushentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ class CTraceFilterPushMove : public CTraceFilterSimple

extern CPhysicsPushedEntities *g_pPushedEntities;

#endif // PUSHENTITY_H
#endif // PUSHENTITY_H
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 );
}

15 changes: 11 additions & 4 deletions mp/src/game/shared/neo/neo_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,20 @@ 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();
// ent0Group == COLLISION_GROUP_PLAYER_MOVEMENT || COLLISION_GROUP_PLAYER ||
// ent1Group == COLLISION_GROUP_PLAYER_MOVEMENT || COLLISION_GROUP_PLAYER ||
if (iNeoCol != NEOCOLLISION_ALL &&
(ent0Group == COLLISION_GROUP_PLAYER || ent0Group == COLLISION_GROUP_PLAYER_MOVEMENT) &&
(ent1Group == COLLISION_GROUP_PLAYER || ent1Group == COLLISION_GROUP_PLAYER_MOVEMENT))
(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()) :
auto *ent0Player = dynamic_cast<const CNEO_Player *>(ent0);
auto *ent1Player = dynamic_cast<const CNEO_Player *>(ent1);
if (ent0Player && ent1Player)
{
return (iNeoCol == NEOCOLLISION_TEAM) ?
(ent0Player->GetTeamNumber() != ent1Player->GetTeamNumber()) :
false;
}
}
return const_cast<CNEORules *>(this)->CTeamplayRules::ShouldCollide(ent0Group, ent1Group);
}
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

0 comments on commit b36724c

Please sign in to comment.