Browse Source

physics: fix a lot of problems

pull/26/head
nillerusr 3 years ago
parent
commit
dc2be1dcb4
  1. 2
      engine/cmodel.cpp
  2. 4
      engine/disp.cpp
  3. 4
      engine/disp_mapload.cpp
  4. 4
      engine/r_areaportal.cpp
  5. 4
      game/client/c_steamjet.cpp
  6. 2
      game/client/interpolatedvar.h
  7. 4
      game/client/particle_iterators.h
  8. 2
      game/client/tf2/c_obj_mcv_selection_panel.cpp
  9. 2
      game/client/tf2/c_ragdoll_shadow.cpp
  10. 28
      game/server/physics.cpp
  11. 2
      game/server/player.cpp
  12. 2
      game/server/tf2/order_heal.cpp
  13. 2
      game/server/tf2/order_helpers.cpp
  14. 2
      game/server/tf2/order_killmortarguy.cpp
  15. 2
      game/server/tf2/order_mortar_attack.cpp
  16. 4
      game/server/tf2/order_repair.cpp
  17. 2
      game/server/tf2/tf_obj_barbed_wire.cpp
  18. 2
      game/server/tf2/tf_playerclass.cpp
  19. 2
      game/server/tf2/tf_team.h
  20. 2
      game/shared/physics_shared.cpp
  21. 2
      inputsystem/inputsystem.h
  22. 3
      public/bspfile.h
  23. 4
      public/disp_common.cpp
  24. 2
      public/inputsystem/iinputsystem.h
  25. 2
      public/keyframe/keyframe.cpp
  26. 15
      studiorender/r_studiodraw.cpp
  27. 3
      vgui2/vgui_controls/TextEntry.cpp
  28. 5
      vgui2/vgui_controls/consoledialog.cpp
  29. 26
      vphysics/physics_object.cpp
  30. 2
      vphysics/physics_shadow.cpp
  31. 16
      vphysics/vcollide_parse.cpp

2
engine/cmodel.cpp

@ -2788,7 +2788,7 @@ int CFastPointLeafNum::GetLeaf( const Vector &vPos ) @@ -2788,7 +2788,7 @@ int CFastPointLeafNum::GetLeaf( const Vector &vPos )
m_vCachedPos = vPos;
CCollisionBSPData *pBSPData = GetCollisionBSPData();
m_flDistToExitLeafSqr = 1e16;
m_flDistToExitLeafSqr = 1e24;
m_iCachedLeaf = CM_PointLeafnumMinDistSqr_r( pBSPData, vPos, 0, m_flDistToExitLeafSqr );
}

4
engine/disp.cpp

@ -102,8 +102,8 @@ inline CVertIndex CDispInfo::IndexToVert( int index ) const @@ -102,8 +102,8 @@ inline CVertIndex CDispInfo::IndexToVert( int index ) const
void CDispInfo::UpdateBoundingBox()
{
m_BBoxMin.Init( 1e16, 1e16, 1e16 );
m_BBoxMax.Init( -1e16, -1e16, -1e16 );
m_BBoxMin.Init( 1e24, 1e24, 1e24 );
m_BBoxMax.Init( -1e24, -1e24, -1e24 );
for( int i=0; i < NumVerts(); i++ )
{

4
engine/disp_mapload.cpp

@ -793,7 +793,7 @@ CDispInfo::CDispInfo() @@ -793,7 +793,7 @@ CDispInfo::CDispInfo()
m_pPowerInfo = NULL;
m_ViewerSphereCenter.Init( 1e16, 1e16, 1e16 );
m_ViewerSphereCenter.Init( 1e24, 1e24, 1e24 );
m_bInUse = false;
@ -995,7 +995,7 @@ int FindNeighborCornerVert( CCoreDispInfo *pDisp, const Vector &vecPoint ) @@ -995,7 +995,7 @@ int FindNeighborCornerVert( CCoreDispInfo *pDisp, const Vector &vecPoint )
CDispUtilsHelper *pDispHelper = pDisp;
int iClosest = 0;
float flClosest = 1e16;
float flClosest = 1e24;
for ( int iCorner = 0; iCorner < 4; ++iCorner )
{

4
engine/r_areaportal.cpp

@ -122,8 +122,8 @@ struct portalclip_t @@ -122,8 +122,8 @@ struct portalclip_t
static inline bool GetPortalScreenExtents( dareaportal_t *pPortal,
portalclip_t * RESTRICT clip, CPortalRect &portalRect , float *pReflectionWaterHeight )
{
portalRect.left = portalRect.bottom = 1e16;
portalRect.right = portalRect.top = -1e16;
portalRect.left = portalRect.bottom = 1e24;
portalRect.right = portalRect.top = -1e24;
bool bValidExtents = false;
worldbrushdata_t *pBrushData = host_state.worldbrush;

4
game/client/c_steamjet.cpp

@ -150,8 +150,8 @@ C_SteamJet::C_SteamJet() @@ -150,8 +150,8 @@ C_SteamJet::C_SteamJet()
m_bFaceLeft = false;
m_ParticleEffect.SetAlwaysSimulate( false ); // Don't simulate outside the PVS or frustum.
m_vLastRampUpdatePos.Init( 1e16, 1e16, 1e16 );
m_vLastRampUpdateAngles.Init( 1e16, 1e16, 1e16 );
m_vLastRampUpdatePos.Init( 1e24, 1e24, 1e24 );
m_vLastRampUpdateAngles.Init( 1e24, 1e24, 1e24 );
}

2
game/client/interpolatedvar.h

@ -283,7 +283,7 @@ struct CInterpolatedVarEntryBase<Type, false> @@ -283,7 +283,7 @@ struct CInterpolatedVarEntryBase<Type, false>
{
Assert(maxCount==1);
}
Type *NewEntry( const Type *pValue, int maxCount, float time )
Type *NewEntry( Type *pValue, int maxCount, float time )
{
Assert(maxCount==1);
changetime = time;

4
game/client/particle_iterators.h

@ -125,8 +125,8 @@ inline CParticleRenderIterator::CParticleRenderIterator() @@ -125,8 +125,8 @@ inline CParticleRenderIterator::CParticleRenderIterator()
m_bGotFirst = false;
m_flPrevZ = 0;
m_nParticlesInCurrentBatch = 0;
m_MinZ = 1e16;
m_MaxZ = -1e16;
m_MinZ = 1e24;
m_MaxZ = -1e24;
m_nZCoords = 0;
}

2
game/client/tf2/c_obj_mcv_selection_panel.cpp

@ -173,7 +173,7 @@ void CMCVMinimapPanel::OnMousePressed( vgui::MouseCode code ) @@ -173,7 +173,7 @@ void CMCVMinimapPanel::OnMousePressed( vgui::MouseCode code )
// Find the closest MCV to their mouse press.
int iClosest = -1;
float flClosest = 1e16;
float flClosest = 1e24;
Vector2D curMousePos( m_LastX, m_LastY );
for ( int i=0; i < pPanel->m_DeployedTeleportStations.Count(); i++ )

2
game/client/tf2/c_ragdoll_shadow.cpp

@ -79,7 +79,7 @@ IPhysicsObject *PhysModelCreateCustom( C_BaseEntity *pEntity, const CPhysCollide @@ -79,7 +79,7 @@ IPhysicsObject *PhysModelCreateCustom( C_BaseEntity *pEntity, const CPhysCollide
solid_t solid;
solid.params = g_PhysDefaultObjectParams;
solid.params.mass = 85.0f;
solid.params.inertia = 1e16f;
solid.params.inertia = 1e24f;
int surfaceProp = -1;
if ( props && props[0] )
{

28
game/server/physics.cpp

@ -74,7 +74,7 @@ static float g_PhysAverageSimTime; @@ -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 ) @@ -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,28 @@ void PhysFrame( float deltaTime ) @@ -1709,10 +1710,28 @@ 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 );
physenv->GetActiveObjects( pActiveList );
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 );
@ -1721,6 +1740,7 @@ void PhysFrame( float deltaTime ) @@ -1721,6 +1740,7 @@ void PhysFrame( float deltaTime )
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 @@ -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,

2
game/server/player.cpp

@ -8014,7 +8014,7 @@ void CBasePlayer::SetupVPhysicsShadow( const Vector &vecAbsOrigin, const Vector @@ -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;

2
game/server/tf2/order_heal.cpp

@ -74,7 +74,7 @@ bool COrderHeal::CreateOrder( CPlayerClass *pClass ) @@ -74,7 +74,7 @@ bool COrderHeal::CreateOrder( CPlayerClass *pClass )
ORDER_HEAL,
pTeam->GetPlayer( sorted[0] ),
pClass->GetPlayer(),
1e16,
1e24,
60,
pOrder );

2
game/server/tf2/order_helpers.cpp

@ -157,7 +157,7 @@ bool OrderCreator_ResourceZoneObject( @@ -157,7 +157,7 @@ bool OrderCreator_ResourceZoneObject(
ORDER_BUILD,
pClosest,
pPlayer,
1e16,
1e24,
60,
pOrder
);

2
game/server/tf2/order_killmortarguy.cpp

@ -95,7 +95,7 @@ bool COrderKillMortarGuy::CreateOrder( CPlayerClass *pClass ) @@ -95,7 +95,7 @@ bool COrderKillMortarGuy::CreateOrder( CPlayerClass *pClass )
ORDER_KILL,
pBrian,
pClass->GetPlayer(),
1e16,
1e24,
60,
pOrder
);

2
game/server/tf2/order_mortar_attack.cpp

@ -61,7 +61,7 @@ bool COrderMortarAttack::CreateOrder( CPlayerClass *pClass ) @@ -61,7 +61,7 @@ bool COrderMortarAttack::CreateOrder( CPlayerClass *pClass )
ORDER_MORTAR_ATTACK,
pEnt,
pPlayer,
1e16,
1e24,
40,
pOrder
);

4
game/server/tf2/order_repair.cpp

@ -91,7 +91,7 @@ bool COrderRepair::CreateOrder_RepairFriendlyObjects( CPlayerClassDefender *pCla @@ -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 ) @@ -130,7 +130,7 @@ bool COrderRepair::CreateOrder_RepairOwnObjects( CPlayerClass *pClass )
ORDER_REPAIR,
pObj,
info.m_pPlayer,
1e16,
1e24,
60,
pOrder
);

2
game/server/tf2/tf_obj_barbed_wire.cpp

@ -177,7 +177,7 @@ void CObjectBarbedWire::StartPlacement( CBaseTFPlayer *pPlayer ) @@ -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();

2
game/server/tf2/tf_playerclass.cpp

@ -1041,7 +1041,7 @@ void CPlayerClass::InitVCollision( void ) @@ -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;

2
game/server/tf2/tf_team.h

@ -145,7 +145,7 @@ public: @@ -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.

2
game/shared/physics_shared.cpp

@ -478,7 +478,7 @@ void PhysGetDefaultAABBSolid( solid_t &solid ) @@ -478,7 +478,7 @@ void PhysGetDefaultAABBSolid( solid_t &solid )
{
solid.params = g_PhysDefaultObjectParams;
solid.params.mass = 85.0f;
solid.params.inertia = 1e16f;
solid.params.inertia = 1e24f;
Q_strncpy( solid.surfaceprop, "default", sizeof( solid.surfaceprop ) );
}

2
inputsystem/inputsystem.h

@ -374,7 +374,7 @@ public: @@ -374,7 +374,7 @@ public:
m_bSkipControllerInitialization = bSkip;
}
void StartTextInput();
virtual void StartTextInput();
#if defined( USE_SDL )
void PollInputState_Platform();

3
public/bspfile.h

@ -794,7 +794,10 @@ struct dfaceid_t @@ -794,7 +794,10 @@ struct dfaceid_t
#if defined( _X360 )
#pragma bitfield_order( push, lsb_to_msb )
#endif
#ifdef WIN32
#pragma warning( disable:4201 ) // C4201: nonstandard extension used: nameless struct/union
#endif
struct dleaf_version_0_t
{
DECLARE_BYTESWAP_DATADESC();

4
public/disp_common.cpp

@ -770,8 +770,8 @@ void ClearNeighborData( CCoreDispInfo *pDisp ) @@ -770,8 +770,8 @@ void ClearNeighborData( CCoreDispInfo *pDisp )
void GetDispBox( CCoreDispInfo *pDisp, CDispBox &box )
{
// Calculate the bbox for this displacement.
Vector vMin( 1e16, 1e16, 1e16 );
Vector vMax( -1e16, -1e16, -1e16 );
Vector vMin( 1e24, 1e24, 1e24 );
Vector vMax( -1e24, -1e24, -1e24 );
for ( int iVert = 0; iVert < 4; ++iVert )
{

2
public/inputsystem/iinputsystem.h

@ -156,6 +156,8 @@ public: @@ -156,6 +156,8 @@ public:
void ActivateSteamControllerActionSet( GameActionSet_t eActionSet ) {
ActivateSteamControllerActionSetForSlot( 0xffffffffffffffff, eActionSet );
}
virtual void StartTextInput() = 0;
};

2
public/keyframe/keyframe.cpp

@ -311,7 +311,7 @@ CPositionInterpolator_Rope::CPositionInterpolator_Rope() @@ -311,7 +311,7 @@ CPositionInterpolator_Rope::CPositionInterpolator_Rope()
m_nSegments = 5;
for( int i=0; i < 2; i++ )
m_Delegate.m_CurEndPoints[i] = Vector( 1e16, 1e16, 1e16 );
m_Delegate.m_CurEndPoints[i] = Vector( 1e24, 1e24, 1e24 );
}
void CPositionInterpolator_Rope::Release()

15
studiorender/r_studiodraw.cpp

@ -1236,12 +1236,13 @@ public: @@ -1236,12 +1236,13 @@ public:
#if !defined( _X360 )
Assert( dstVertex.m_vecUserData.w == -1.0f || dstVertex.m_vecUserData.w == 1.0f );
// TODO(nillerusr): uncomment when i remove -mfpmath=387 from compiler options
//if ( nHasSIMD )
//{
// meshBuilder.FastVertexSSE( dstVertex );
//}
//else
#if 0 // FIXME(nillerusr): causing a crash, reason: misalign?
if ( nHasSIMD )
{
meshBuilder.FastVertexSSE( dstVertex );
}
else
#endif
{
meshBuilder.FastVertex( dstVertex );
}
@ -1251,11 +1252,13 @@ public: @@ -1251,11 +1252,13 @@ public:
}
else
{
#if 0 // FIXME(nillerusr): causing a crash, reason: misalign?
if ( nHasSIMD )
{
meshBuilder.FastVertexSSE( *(ModelVertexDX7_t*)&dstVertex );
}
else
#endif
{
meshBuilder.FastVertex( *(ModelVertexDX7_t*)&dstVertex );
}

3
vgui2/vgui_controls/TextEntry.cpp

@ -1484,7 +1484,8 @@ void TextEntry::OnMousePressed(MouseCode code) @@ -1484,7 +1484,8 @@ void TextEntry::OnMousePressed(MouseCode code)
return;
}
g_pInputSystem->StartTextInput();
if( IsEnabled() )
g_pInputSystem->StartTextInput();
// move the cursor to where the mouse was pressed
int x, y;

5
vgui2/vgui_controls/consoledialog.cpp

@ -652,6 +652,9 @@ void CConsolePanel::OnTextChanged(Panel *panel) @@ -652,6 +652,9 @@ void CConsolePanel::OnTextChanged(Panel *panel)
// see if they've hit the tilde key (which opens & closes the console)
int len = Q_strlen(m_szPartialText);
if( !len )
return;
bool hitTilde = ( m_szPartialText[len - 1] == '~' || m_szPartialText[len - 1] == '`' ) ? true : false;
bool altKeyDown = ( vgui::input()->IsKeyDown( KEY_LALT ) || vgui::input()->IsKeyDown( KEY_RALT ) ) ? true : false;
@ -1253,4 +1256,4 @@ void CConsoleDialog::OnKeyCodePressed( vgui::KeyCode code ) @@ -1253,4 +1256,4 @@ void CConsoleDialog::OnKeyCodePressed( vgui::KeyCode code )
{
BaseClass::OnKeyCodePressed(code);
}
}
}

26
vphysics/physics_object.cpp

@ -592,7 +592,8 @@ void CPhysicsObject::SetMass( float mass ) @@ -592,7 +592,8 @@ void CPhysicsObject::SetMass( float mass )
}
Assert( mass > 0 );
mass = clamp( mass, 0, VPHYSICS_MAX_MASS ); // NOTE: Allow zero procedurally, but not by initialization
mass = clamp( mass, 1.f, VPHYSICS_MAX_MASS );
m_pObject->change_mass( mass );
SetVolume( m_volume );
RecomputeDragBases();
@ -633,13 +634,17 @@ Vector CPhysicsObject::GetInvInertia( void ) const @@ -633,13 +634,17 @@ Vector CPhysicsObject::GetInvInertia( void ) const
}
void CPhysicsObject::SetInertia( const Vector &inertia )
{
IVP_U_Float_Point ri;
ConvertDirectionToIVP( inertia, ri );
IVP_U_Float_Point ri; ConvertDirectionToIVP( inertia, ri );
ri.k[0] = IVP_Inline_Math::fabsd(ri.k[0]);
ri.k[1] = IVP_Inline_Math::fabsd(ri.k[1]);
ri.k[2] = IVP_Inline_Math::fabsd(ri.k[2]);
if( ri.k[0] > 1e14f ) ri.k[0] = 1e14f; if( ri.k[1] > 1e14f ) ri.k[1] = 1e14f; if( ri.k[2] > 1e14f ) ri.k[2] = 1e14f;
if( ri.k[0] <= 0 ) ri.k[0] = 1.f; if( ri.k[1] <= 0 ) ri.k[1] = 1.f; if( ri.k[2] <= 0 ) ri.k[2] = 1.f;
m_pObject->get_core()->set_rotation_inertia( &ri );
}
@ -1358,6 +1363,7 @@ bool CPhysicsObject::IsFluid() const @@ -1358,6 +1363,7 @@ bool CPhysicsObject::IsFluid() const
// sets the object to be hinged. Fixed it place, but able to rotate around one axis.
void CPhysicsObject::BecomeHinged( int localAxis )
{
if ( IsMoveable() )
{
float savedMass = GetMass();
@ -1370,6 +1376,7 @@ void CPhysicsObject::BecomeHinged( int localAxis ) @@ -1370,6 +1376,7 @@ void CPhysicsObject::BecomeHinged( int localAxis )
SetMass( VPHYSICS_MAX_MASS );
IVP_U_Float_Hesse tmp = *iri;
#if 0
for ( i = 0; i < 3; i++ )
tmp.k[i] = savedRI[i];
@ -1394,10 +1401,10 @@ void CPhysicsObject::RemoveHinged() @@ -1394,10 +1401,10 @@ void CPhysicsObject::RemoveHinged()
void CPhysicsObject::OutputDebugInfo() const
{
Msg("-----------------\nObject: %s\n", m_pObject->get_name());
Msg("Mass: %.1f (inv %.3f)\n", GetMass(), GetInvMass() );
Msg("Mass: %.3e (inv %.3e)\n", GetMass(), GetInvMass() );
Vector inertia = GetInertia();
Vector invInertia = GetInvInertia();
Msg("Inertia: %.2f, %.2f, %.2f (inv %.3f, %.3f, %.3f)\n", inertia.x, inertia.y, inertia.z, invInertia.x, invInertia.y, invInertia.z );
Msg("Inertia: %.3e, %.3e, %.3e (inv %.3e, %.3e, %.3e)\n", inertia.x, inertia.y, inertia.z, invInertia.x, invInertia.y, invInertia.z );
Vector speed, angSpeed;
GetVelocity( &speed, &angSpeed );
@ -1406,7 +1413,7 @@ void CPhysicsObject::OutputDebugInfo() const @@ -1406,7 +1413,7 @@ void CPhysicsObject::OutputDebugInfo() const
float damp, angDamp;
GetDamping( &damp, &angDamp );
Msg("Damping %.2f linear, %.2f angular\n", damp, angDamp );
Msg("Damping %.3e linear, %.3e angular\n", damp, angDamp );
Msg("Linear Drag: %.2f, %.2f, %.2f (factor %.2f)\n", m_dragBasis.x, m_dragBasis.y, m_dragBasis.z, m_dragCoefficient );
Msg("Angular Drag: %.2f, %.2f, %.2f (factor %.2f)\n", m_angDragBasis.x, m_angDragBasis.y, m_angDragBasis.z, m_angDragCoefficient );
@ -1462,8 +1469,7 @@ bool CPhysicsObject::IsAttachedToConstraint( bool bExternalOnly ) const @@ -1462,8 +1469,7 @@ bool CPhysicsObject::IsAttachedToConstraint( bool bExternalOnly ) const
static void InitObjectTemplate( IVP_Template_Real_Object &objectTemplate, int materialIndex, objectparams_t *pParams, bool isStatic )
{
objectTemplate.mass = pParams->mass;
objectTemplate.mass = clamp( objectTemplate.mass, VPHYSICS_MIN_MASS, VPHYSICS_MAX_MASS );
objectTemplate.mass = clamp( pParams->mass, VPHYSICS_MIN_MASS, VPHYSICS_MAX_MASS );
if ( materialIndex >= 0 )
{
@ -1495,8 +1501,8 @@ static void InitObjectTemplate( IVP_Template_Real_Object &objectTemplate, int ma @@ -1495,8 +1501,8 @@ static void InitObjectTemplate( IVP_Template_Real_Object &objectTemplate, int ma
if ( inertia <= 0 )
inertia = 1.0;
if ( inertia > 1e18f )
inertia = 1e18f;
if ( inertia > 1e14f )
inertia = 1e14f;
objectTemplate.rot_inertia.set(inertia, inertia, inertia);
objectTemplate.rot_speed_damp_factor.set(pParams->rotdamping, pParams->rotdamping, pParams->rotdamping);

2
vphysics/physics_shadow.cpp

@ -1052,7 +1052,7 @@ void CShadowController::AttachObject( void ) @@ -1052,7 +1052,7 @@ void CShadowController::AttachObject( void )
if ( !m_allowsRotation )
{
IVP_U_Float_Point ri( 1e15f, 1e15f, 1e15f );
IVP_U_Float_Point ri( 1e14f, 1e14f, 1e14f );
pCore->set_rotation_inertia( &ri );
}
if ( !m_allowsTranslation )

16
vphysics/vcollide_parse.cpp

@ -174,7 +174,13 @@ void CVPhysicsParse::ParseSolid( solid_t *pSolid, IVPhysicsKeyHandler *unknownKe @@ -174,7 +174,13 @@ void CVPhysicsParse::ParseSolid( solid_t *pSolid, IVPhysicsKeyHandler *unknownKe
}
else if ( !Q_stricmp( key, "inertia" ) )
{
pSolid->params.inertia = atof(value);
float inertia = atof(value);
if( inertia > 1e14f )
pSolid->params.inertia = 1e14f;
else if( inertia <= 0 )
pSolid->params.inertia = 1.f;
else
pSolid->params.inertia = inertia;
}
else if ( !Q_stricmp( key, "damping" ) )
{
@ -468,7 +474,13 @@ void CVPhysicsParse::ParseVehicleWheel( vehicle_wheelparams_t &wheel ) @@ -468,7 +474,13 @@ void CVPhysicsParse::ParseVehicleWheel( vehicle_wheelparams_t &wheel )
}
else if ( !Q_stricmp( key, "inertia" ) )
{
wheel.inertia = atof( value );
float inertia = atof(value);
if( inertia > 1e14f )
wheel.inertia = 1e14f;
else if( inertia <= 0 )
wheel.inertia = 1.f;
else
wheel.inertia = inertia;
}
else if ( !Q_stricmp( key, "damping" ) )
{

Loading…
Cancel
Save