from: "sdks\hl2sdk-csgo\game\server\client.cpp"
Code: Select all
//------------------------------------------------------------------------------
// Searches along the direction ray in steps of "step" to see if
// the entity position is passible.
// Used for putting the player in valid space when toggling off noclip mode.
//------------------------------------------------------------------------------
static int FindPassableSpace( CBaseEntity *pEntity, unsigned int mask, const Vector& direction, float step, Vector& oldorigin )
{
int i;
for ( i = 0; i < 100; i++ )
{
Vector origin = pEntity->GetAbsOrigin();
VectorMA( origin, step, direction, origin );
pEntity->SetAbsOrigin( origin );
if ( TestEntityPosition( pEntity, mask ) )
{
VectorCopy( pEntity->GetAbsOrigin(), oldorigin );
return 1;
}
}
return 0;
}