physics: fix a lot of problems

This commit is contained in:
nillerusr
2021-10-23 14:41:59 +03:00
parent cb04a1e451
commit dc2be1dcb4
31 changed files with 104 additions and 54 deletions
+24 -4
View File
@@ -74,7 +74,7 @@ static float g_PhysAverageSimTime;
CCallQueue g_PostSimulationQueue;
// local routines
// local roeutines
static IPhysicsObject *PhysCreateWorld( CBaseEntity *pWorld );
static void PhysFrame( float deltaTime );
static bool IsDebris( int collisionGroup );
@@ -1689,6 +1689,7 @@ void PhysFrame( float deltaTime )
float simRealTime = 0;
deltaTime *= phys_timescale.GetFloat();
// !!!HACKHACK -- hard limit scaled time to avoid spending too much time in here
// Limit to 100 ms
if ( deltaTime > 0.100f )
@@ -1709,10 +1710,9 @@ void PhysFrame( float deltaTime )
g_Collisions.BufferTouchEvents( true );
#endif
physenv->Simulate( deltaTime );
int activeCount = physenv->GetActiveObjectCount();
IPhysicsObject **pActiveList = NULL;
#if 0
if ( activeCount )
{
pActiveList = (IPhysicsObject **)stackalloc( sizeof(IPhysicsObject *)*activeCount );
@@ -1721,6 +1721,26 @@ void PhysFrame( float deltaTime )
for ( int i = 0; i < activeCount; i++ )
{
CBaseEntity *pEntity = reinterpret_cast<CBaseEntity *>(pActiveList[i]->GetGameData());
OutputVPhysicsDebugInfo(pEntity);
}
stackfree( pActiveList );
}
#endif
physenv->Simulate( deltaTime );
activeCount = physenv->GetActiveObjectCount();
pActiveList = NULL;
if ( activeCount )
{
pActiveList = (IPhysicsObject **)stackalloc( sizeof(IPhysicsObject *)*activeCount );
physenv->GetActiveObjects( pActiveList );
for ( int i = 0; i < activeCount; i++ )
{
CBaseEntity *pEntity = reinterpret_cast<CBaseEntity *>(pActiveList[i]->GetGameData());
// OutputVPhysicsDebugInfo(pEntity);
if ( pEntity )
{
if ( pEntity->CollisionProp()->DoesVPhysicsInvalidateSurroundingBox() )
@@ -1948,7 +1968,7 @@ void CCollisionEvent::Friction( IPhysicsObject *pObject, float energy, int surfa
if ( pEntity )
{
friction_t *pFriction = g_Collisions.FindFriction( pEntity );
if ( pFriction && pFriction->pObject)
{
// in MP mode play sound and effects once every 500 msecs,
+1 -1
View File
@@ -8014,7 +8014,7 @@ void CBasePlayer::SetupVPhysicsShadow( const Vector &vecAbsOrigin, const Vector
Q_strncpy( solid.surfaceprop, "player", sizeof(solid.surfaceprop) );
solid.params = g_PhysDefaultObjectParams;
solid.params.mass = 85.0f;
solid.params.inertia = 1e16f;
solid.params.inertia = 1e24f;
solid.params.enableCollisions = false;
//disable drag
solid.params.dragCoefficient = 0;
+1 -1
View File
@@ -74,7 +74,7 @@ bool COrderHeal::CreateOrder( CPlayerClass *pClass )
ORDER_HEAL,
pTeam->GetPlayer( sorted[0] ),
pClass->GetPlayer(),
1e16,
1e24,
60,
pOrder );
+1 -1
View File
@@ -157,7 +157,7 @@ bool OrderCreator_ResourceZoneObject(
ORDER_BUILD,
pClosest,
pPlayer,
1e16,
1e24,
60,
pOrder
);
+1 -1
View File
@@ -95,7 +95,7 @@ bool COrderKillMortarGuy::CreateOrder( CPlayerClass *pClass )
ORDER_KILL,
pBrian,
pClass->GetPlayer(),
1e16,
1e24,
60,
pOrder
);
+1 -1
View File
@@ -61,7 +61,7 @@ bool COrderMortarAttack::CreateOrder( CPlayerClass *pClass )
ORDER_MORTAR_ATTACK,
pEnt,
pPlayer,
1e16,
1e24,
40,
pOrder
);
+2 -2
View File
@@ -91,7 +91,7 @@ bool COrderRepair::CreateOrder_RepairFriendlyObjects( CPlayerClassDefender *pCla
ORDER_REPAIR,
pObjToHeal,
pPlayer,
1e16,
1e24,
60,
pOrder
);
@@ -130,7 +130,7 @@ bool COrderRepair::CreateOrder_RepairOwnObjects( CPlayerClass *pClass )
ORDER_REPAIR,
pObj,
info.m_pPlayer,
1e16,
1e24,
60,
pOrder
);
+1 -1
View File
@@ -177,7 +177,7 @@ void CObjectBarbedWire::StartPlacement( CBaseTFPlayer *pPlayer )
if ( pPlayer && !m_hConnectedTo )
{
// Automatically connect to the nearest barbed wire on our team.
float flClosest = 1e16;
float flClosest = 1e24;
CObjectBarbedWire *pClosest = NULL;
CBaseEntity *pCur = gEntList.FirstEnt();
+1 -1
View File
@@ -1041,7 +1041,7 @@ void CPlayerClass::InitVCollision( void )
solid_t solid;
solid.params = g_PhysDefaultObjectParams;
solid.params.mass = 85.0f;
solid.params.inertia = 1e16f;
solid.params.inertia = 1e24f;
solid.params.enableCollisions = false;
//disable drag
solid.params.dragCoefficient = 0;
+1 -1
View File
@@ -145,7 +145,7 @@ public:
int iOrderType,
CBaseEntity *pTarget,
CBaseTFPlayer *pPlayer = NULL,
float flDistanceToRemove = 1e16,
float flDistanceToRemove = 1e24,
float flLifetime = 60,
COrder *pDefaultOrder = NULL // If this is specified, then it is used instead of
// asking COrder to allocate an order.