mirror of
https://github.com/nillerusr/source-engine.git
synced 2024-12-22 14:16:50 +00:00
physics: fix a lot of problems
This commit is contained in:
parent
cb04a1e451
commit
dc2be1dcb4
@ -2788,7 +2788,7 @@ int CFastPointLeafNum::GetLeaf( const Vector &vPos )
|
|||||||
m_vCachedPos = vPos;
|
m_vCachedPos = vPos;
|
||||||
|
|
||||||
CCollisionBSPData *pBSPData = GetCollisionBSPData();
|
CCollisionBSPData *pBSPData = GetCollisionBSPData();
|
||||||
m_flDistToExitLeafSqr = 1e16;
|
m_flDistToExitLeafSqr = 1e24;
|
||||||
m_iCachedLeaf = CM_PointLeafnumMinDistSqr_r( pBSPData, vPos, 0, m_flDistToExitLeafSqr );
|
m_iCachedLeaf = CM_PointLeafnumMinDistSqr_r( pBSPData, vPos, 0, m_flDistToExitLeafSqr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,8 +102,8 @@ inline CVertIndex CDispInfo::IndexToVert( int index ) const
|
|||||||
|
|
||||||
void CDispInfo::UpdateBoundingBox()
|
void CDispInfo::UpdateBoundingBox()
|
||||||
{
|
{
|
||||||
m_BBoxMin.Init( 1e16, 1e16, 1e16 );
|
m_BBoxMin.Init( 1e24, 1e24, 1e24 );
|
||||||
m_BBoxMax.Init( -1e16, -1e16, -1e16 );
|
m_BBoxMax.Init( -1e24, -1e24, -1e24 );
|
||||||
|
|
||||||
for( int i=0; i < NumVerts(); i++ )
|
for( int i=0; i < NumVerts(); i++ )
|
||||||
{
|
{
|
||||||
|
@ -793,7 +793,7 @@ CDispInfo::CDispInfo()
|
|||||||
|
|
||||||
m_pPowerInfo = NULL;
|
m_pPowerInfo = NULL;
|
||||||
|
|
||||||
m_ViewerSphereCenter.Init( 1e16, 1e16, 1e16 );
|
m_ViewerSphereCenter.Init( 1e24, 1e24, 1e24 );
|
||||||
|
|
||||||
m_bInUse = false;
|
m_bInUse = false;
|
||||||
|
|
||||||
@ -995,7 +995,7 @@ int FindNeighborCornerVert( CCoreDispInfo *pDisp, const Vector &vecPoint )
|
|||||||
CDispUtilsHelper *pDispHelper = pDisp;
|
CDispUtilsHelper *pDispHelper = pDisp;
|
||||||
|
|
||||||
int iClosest = 0;
|
int iClosest = 0;
|
||||||
float flClosest = 1e16;
|
float flClosest = 1e24;
|
||||||
for ( int iCorner = 0; iCorner < 4; ++iCorner )
|
for ( int iCorner = 0; iCorner < 4; ++iCorner )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ struct portalclip_t
|
|||||||
static inline bool GetPortalScreenExtents( dareaportal_t *pPortal,
|
static inline bool GetPortalScreenExtents( dareaportal_t *pPortal,
|
||||||
portalclip_t * RESTRICT clip, CPortalRect &portalRect , float *pReflectionWaterHeight )
|
portalclip_t * RESTRICT clip, CPortalRect &portalRect , float *pReflectionWaterHeight )
|
||||||
{
|
{
|
||||||
portalRect.left = portalRect.bottom = 1e16;
|
portalRect.left = portalRect.bottom = 1e24;
|
||||||
portalRect.right = portalRect.top = -1e16;
|
portalRect.right = portalRect.top = -1e24;
|
||||||
bool bValidExtents = false;
|
bool bValidExtents = false;
|
||||||
worldbrushdata_t *pBrushData = host_state.worldbrush;
|
worldbrushdata_t *pBrushData = host_state.worldbrush;
|
||||||
|
|
||||||
|
@ -150,8 +150,8 @@ C_SteamJet::C_SteamJet()
|
|||||||
m_bFaceLeft = false;
|
m_bFaceLeft = false;
|
||||||
m_ParticleEffect.SetAlwaysSimulate( false ); // Don't simulate outside the PVS or frustum.
|
m_ParticleEffect.SetAlwaysSimulate( false ); // Don't simulate outside the PVS or frustum.
|
||||||
|
|
||||||
m_vLastRampUpdatePos.Init( 1e16, 1e16, 1e16 );
|
m_vLastRampUpdatePos.Init( 1e24, 1e24, 1e24 );
|
||||||
m_vLastRampUpdateAngles.Init( 1e16, 1e16, 1e16 );
|
m_vLastRampUpdateAngles.Init( 1e24, 1e24, 1e24 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ struct CInterpolatedVarEntryBase<Type, false>
|
|||||||
{
|
{
|
||||||
Assert(maxCount==1);
|
Assert(maxCount==1);
|
||||||
}
|
}
|
||||||
Type *NewEntry( const Type *pValue, int maxCount, float time )
|
Type *NewEntry( Type *pValue, int maxCount, float time )
|
||||||
{
|
{
|
||||||
Assert(maxCount==1);
|
Assert(maxCount==1);
|
||||||
changetime = time;
|
changetime = time;
|
||||||
|
@ -125,8 +125,8 @@ inline CParticleRenderIterator::CParticleRenderIterator()
|
|||||||
m_bGotFirst = false;
|
m_bGotFirst = false;
|
||||||
m_flPrevZ = 0;
|
m_flPrevZ = 0;
|
||||||
m_nParticlesInCurrentBatch = 0;
|
m_nParticlesInCurrentBatch = 0;
|
||||||
m_MinZ = 1e16;
|
m_MinZ = 1e24;
|
||||||
m_MaxZ = -1e16;
|
m_MaxZ = -1e24;
|
||||||
m_nZCoords = 0;
|
m_nZCoords = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ void CMCVMinimapPanel::OnMousePressed( vgui::MouseCode code )
|
|||||||
|
|
||||||
// Find the closest MCV to their mouse press.
|
// Find the closest MCV to their mouse press.
|
||||||
int iClosest = -1;
|
int iClosest = -1;
|
||||||
float flClosest = 1e16;
|
float flClosest = 1e24;
|
||||||
Vector2D curMousePos( m_LastX, m_LastY );
|
Vector2D curMousePos( m_LastX, m_LastY );
|
||||||
|
|
||||||
for ( int i=0; i < pPanel->m_DeployedTeleportStations.Count(); i++ )
|
for ( int i=0; i < pPanel->m_DeployedTeleportStations.Count(); i++ )
|
||||||
|
@ -79,7 +79,7 @@ IPhysicsObject *PhysModelCreateCustom( C_BaseEntity *pEntity, const CPhysCollide
|
|||||||
solid_t solid;
|
solid_t solid;
|
||||||
solid.params = g_PhysDefaultObjectParams;
|
solid.params = g_PhysDefaultObjectParams;
|
||||||
solid.params.mass = 85.0f;
|
solid.params.mass = 85.0f;
|
||||||
solid.params.inertia = 1e16f;
|
solid.params.inertia = 1e24f;
|
||||||
int surfaceProp = -1;
|
int surfaceProp = -1;
|
||||||
if ( props && props[0] )
|
if ( props && props[0] )
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,7 @@ static float g_PhysAverageSimTime;
|
|||||||
CCallQueue g_PostSimulationQueue;
|
CCallQueue g_PostSimulationQueue;
|
||||||
|
|
||||||
|
|
||||||
// local routines
|
// local roeutines
|
||||||
static IPhysicsObject *PhysCreateWorld( CBaseEntity *pWorld );
|
static IPhysicsObject *PhysCreateWorld( CBaseEntity *pWorld );
|
||||||
static void PhysFrame( float deltaTime );
|
static void PhysFrame( float deltaTime );
|
||||||
static bool IsDebris( int collisionGroup );
|
static bool IsDebris( int collisionGroup );
|
||||||
@ -1689,6 +1689,7 @@ void PhysFrame( float deltaTime )
|
|||||||
float simRealTime = 0;
|
float simRealTime = 0;
|
||||||
|
|
||||||
deltaTime *= phys_timescale.GetFloat();
|
deltaTime *= phys_timescale.GetFloat();
|
||||||
|
|
||||||
// !!!HACKHACK -- hard limit scaled time to avoid spending too much time in here
|
// !!!HACKHACK -- hard limit scaled time to avoid spending too much time in here
|
||||||
// Limit to 100 ms
|
// Limit to 100 ms
|
||||||
if ( deltaTime > 0.100f )
|
if ( deltaTime > 0.100f )
|
||||||
@ -1709,10 +1710,9 @@ void PhysFrame( float deltaTime )
|
|||||||
g_Collisions.BufferTouchEvents( true );
|
g_Collisions.BufferTouchEvents( true );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
physenv->Simulate( deltaTime );
|
|
||||||
|
|
||||||
int activeCount = physenv->GetActiveObjectCount();
|
int activeCount = physenv->GetActiveObjectCount();
|
||||||
IPhysicsObject **pActiveList = NULL;
|
IPhysicsObject **pActiveList = NULL;
|
||||||
|
#if 0
|
||||||
if ( activeCount )
|
if ( activeCount )
|
||||||
{
|
{
|
||||||
pActiveList = (IPhysicsObject **)stackalloc( sizeof(IPhysicsObject *)*activeCount );
|
pActiveList = (IPhysicsObject **)stackalloc( sizeof(IPhysicsObject *)*activeCount );
|
||||||
@ -1721,6 +1721,26 @@ void PhysFrame( float deltaTime )
|
|||||||
for ( int i = 0; i < activeCount; i++ )
|
for ( int i = 0; i < activeCount; i++ )
|
||||||
{
|
{
|
||||||
CBaseEntity *pEntity = reinterpret_cast<CBaseEntity *>(pActiveList[i]->GetGameData());
|
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 )
|
||||||
{
|
{
|
||||||
if ( pEntity->CollisionProp()->DoesVPhysicsInvalidateSurroundingBox() )
|
if ( pEntity->CollisionProp()->DoesVPhysicsInvalidateSurroundingBox() )
|
||||||
@ -1948,7 +1968,7 @@ void CCollisionEvent::Friction( IPhysicsObject *pObject, float energy, int surfa
|
|||||||
if ( pEntity )
|
if ( pEntity )
|
||||||
{
|
{
|
||||||
friction_t *pFriction = g_Collisions.FindFriction( pEntity );
|
friction_t *pFriction = g_Collisions.FindFriction( pEntity );
|
||||||
|
|
||||||
if ( pFriction && pFriction->pObject)
|
if ( pFriction && pFriction->pObject)
|
||||||
{
|
{
|
||||||
// in MP mode play sound and effects once every 500 msecs,
|
// in MP mode play sound and effects once every 500 msecs,
|
||||||
|
@ -8014,7 +8014,7 @@ void CBasePlayer::SetupVPhysicsShadow( const Vector &vecAbsOrigin, const Vector
|
|||||||
Q_strncpy( solid.surfaceprop, "player", sizeof(solid.surfaceprop) );
|
Q_strncpy( solid.surfaceprop, "player", sizeof(solid.surfaceprop) );
|
||||||
solid.params = g_PhysDefaultObjectParams;
|
solid.params = g_PhysDefaultObjectParams;
|
||||||
solid.params.mass = 85.0f;
|
solid.params.mass = 85.0f;
|
||||||
solid.params.inertia = 1e16f;
|
solid.params.inertia = 1e24f;
|
||||||
solid.params.enableCollisions = false;
|
solid.params.enableCollisions = false;
|
||||||
//disable drag
|
//disable drag
|
||||||
solid.params.dragCoefficient = 0;
|
solid.params.dragCoefficient = 0;
|
||||||
|
@ -74,7 +74,7 @@ bool COrderHeal::CreateOrder( CPlayerClass *pClass )
|
|||||||
ORDER_HEAL,
|
ORDER_HEAL,
|
||||||
pTeam->GetPlayer( sorted[0] ),
|
pTeam->GetPlayer( sorted[0] ),
|
||||||
pClass->GetPlayer(),
|
pClass->GetPlayer(),
|
||||||
1e16,
|
1e24,
|
||||||
60,
|
60,
|
||||||
pOrder );
|
pOrder );
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ bool OrderCreator_ResourceZoneObject(
|
|||||||
ORDER_BUILD,
|
ORDER_BUILD,
|
||||||
pClosest,
|
pClosest,
|
||||||
pPlayer,
|
pPlayer,
|
||||||
1e16,
|
1e24,
|
||||||
60,
|
60,
|
||||||
pOrder
|
pOrder
|
||||||
);
|
);
|
||||||
|
@ -95,7 +95,7 @@ bool COrderKillMortarGuy::CreateOrder( CPlayerClass *pClass )
|
|||||||
ORDER_KILL,
|
ORDER_KILL,
|
||||||
pBrian,
|
pBrian,
|
||||||
pClass->GetPlayer(),
|
pClass->GetPlayer(),
|
||||||
1e16,
|
1e24,
|
||||||
60,
|
60,
|
||||||
pOrder
|
pOrder
|
||||||
);
|
);
|
||||||
|
@ -61,7 +61,7 @@ bool COrderMortarAttack::CreateOrder( CPlayerClass *pClass )
|
|||||||
ORDER_MORTAR_ATTACK,
|
ORDER_MORTAR_ATTACK,
|
||||||
pEnt,
|
pEnt,
|
||||||
pPlayer,
|
pPlayer,
|
||||||
1e16,
|
1e24,
|
||||||
40,
|
40,
|
||||||
pOrder
|
pOrder
|
||||||
);
|
);
|
||||||
|
@ -91,7 +91,7 @@ bool COrderRepair::CreateOrder_RepairFriendlyObjects( CPlayerClassDefender *pCla
|
|||||||
ORDER_REPAIR,
|
ORDER_REPAIR,
|
||||||
pObjToHeal,
|
pObjToHeal,
|
||||||
pPlayer,
|
pPlayer,
|
||||||
1e16,
|
1e24,
|
||||||
60,
|
60,
|
||||||
pOrder
|
pOrder
|
||||||
);
|
);
|
||||||
@ -130,7 +130,7 @@ bool COrderRepair::CreateOrder_RepairOwnObjects( CPlayerClass *pClass )
|
|||||||
ORDER_REPAIR,
|
ORDER_REPAIR,
|
||||||
pObj,
|
pObj,
|
||||||
info.m_pPlayer,
|
info.m_pPlayer,
|
||||||
1e16,
|
1e24,
|
||||||
60,
|
60,
|
||||||
pOrder
|
pOrder
|
||||||
);
|
);
|
||||||
|
@ -177,7 +177,7 @@ void CObjectBarbedWire::StartPlacement( CBaseTFPlayer *pPlayer )
|
|||||||
if ( pPlayer && !m_hConnectedTo )
|
if ( pPlayer && !m_hConnectedTo )
|
||||||
{
|
{
|
||||||
// Automatically connect to the nearest barbed wire on our team.
|
// Automatically connect to the nearest barbed wire on our team.
|
||||||
float flClosest = 1e16;
|
float flClosest = 1e24;
|
||||||
CObjectBarbedWire *pClosest = NULL;
|
CObjectBarbedWire *pClosest = NULL;
|
||||||
|
|
||||||
CBaseEntity *pCur = gEntList.FirstEnt();
|
CBaseEntity *pCur = gEntList.FirstEnt();
|
||||||
|
@ -1041,7 +1041,7 @@ void CPlayerClass::InitVCollision( void )
|
|||||||
solid_t solid;
|
solid_t solid;
|
||||||
solid.params = g_PhysDefaultObjectParams;
|
solid.params = g_PhysDefaultObjectParams;
|
||||||
solid.params.mass = 85.0f;
|
solid.params.mass = 85.0f;
|
||||||
solid.params.inertia = 1e16f;
|
solid.params.inertia = 1e24f;
|
||||||
solid.params.enableCollisions = false;
|
solid.params.enableCollisions = false;
|
||||||
//disable drag
|
//disable drag
|
||||||
solid.params.dragCoefficient = 0;
|
solid.params.dragCoefficient = 0;
|
||||||
|
@ -145,7 +145,7 @@ public:
|
|||||||
int iOrderType,
|
int iOrderType,
|
||||||
CBaseEntity *pTarget,
|
CBaseEntity *pTarget,
|
||||||
CBaseTFPlayer *pPlayer = NULL,
|
CBaseTFPlayer *pPlayer = NULL,
|
||||||
float flDistanceToRemove = 1e16,
|
float flDistanceToRemove = 1e24,
|
||||||
float flLifetime = 60,
|
float flLifetime = 60,
|
||||||
COrder *pDefaultOrder = NULL // If this is specified, then it is used instead of
|
COrder *pDefaultOrder = NULL // If this is specified, then it is used instead of
|
||||||
// asking COrder to allocate an order.
|
// asking COrder to allocate an order.
|
||||||
|
@ -478,7 +478,7 @@ void PhysGetDefaultAABBSolid( solid_t &solid )
|
|||||||
{
|
{
|
||||||
solid.params = g_PhysDefaultObjectParams;
|
solid.params = g_PhysDefaultObjectParams;
|
||||||
solid.params.mass = 85.0f;
|
solid.params.mass = 85.0f;
|
||||||
solid.params.inertia = 1e16f;
|
solid.params.inertia = 1e24f;
|
||||||
Q_strncpy( solid.surfaceprop, "default", sizeof( solid.surfaceprop ) );
|
Q_strncpy( solid.surfaceprop, "default", sizeof( solid.surfaceprop ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ public:
|
|||||||
m_bSkipControllerInitialization = bSkip;
|
m_bSkipControllerInitialization = bSkip;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartTextInput();
|
virtual void StartTextInput();
|
||||||
|
|
||||||
#if defined( USE_SDL )
|
#if defined( USE_SDL )
|
||||||
void PollInputState_Platform();
|
void PollInputState_Platform();
|
||||||
|
@ -794,7 +794,10 @@ struct dfaceid_t
|
|||||||
#if defined( _X360 )
|
#if defined( _X360 )
|
||||||
#pragma bitfield_order( push, lsb_to_msb )
|
#pragma bitfield_order( push, lsb_to_msb )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
#pragma warning( disable:4201 ) // C4201: nonstandard extension used: nameless struct/union
|
#pragma warning( disable:4201 ) // C4201: nonstandard extension used: nameless struct/union
|
||||||
|
#endif
|
||||||
struct dleaf_version_0_t
|
struct dleaf_version_0_t
|
||||||
{
|
{
|
||||||
DECLARE_BYTESWAP_DATADESC();
|
DECLARE_BYTESWAP_DATADESC();
|
||||||
|
@ -770,8 +770,8 @@ void ClearNeighborData( CCoreDispInfo *pDisp )
|
|||||||
void GetDispBox( CCoreDispInfo *pDisp, CDispBox &box )
|
void GetDispBox( CCoreDispInfo *pDisp, CDispBox &box )
|
||||||
{
|
{
|
||||||
// Calculate the bbox for this displacement.
|
// Calculate the bbox for this displacement.
|
||||||
Vector vMin( 1e16, 1e16, 1e16 );
|
Vector vMin( 1e24, 1e24, 1e24 );
|
||||||
Vector vMax( -1e16, -1e16, -1e16 );
|
Vector vMax( -1e24, -1e24, -1e24 );
|
||||||
|
|
||||||
for ( int iVert = 0; iVert < 4; ++iVert )
|
for ( int iVert = 0; iVert < 4; ++iVert )
|
||||||
{
|
{
|
||||||
|
@ -156,6 +156,8 @@ public:
|
|||||||
void ActivateSteamControllerActionSet( GameActionSet_t eActionSet ) {
|
void ActivateSteamControllerActionSet( GameActionSet_t eActionSet ) {
|
||||||
ActivateSteamControllerActionSetForSlot( 0xffffffffffffffff, eActionSet );
|
ActivateSteamControllerActionSetForSlot( 0xffffffffffffffff, eActionSet );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void StartTextInput() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ CPositionInterpolator_Rope::CPositionInterpolator_Rope()
|
|||||||
m_nSegments = 5;
|
m_nSegments = 5;
|
||||||
|
|
||||||
for( int i=0; i < 2; i++ )
|
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()
|
void CPositionInterpolator_Rope::Release()
|
||||||
|
@ -1236,12 +1236,13 @@ public:
|
|||||||
#if !defined( _X360 )
|
#if !defined( _X360 )
|
||||||
Assert( dstVertex.m_vecUserData.w == -1.0f || dstVertex.m_vecUserData.w == 1.0f );
|
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 0 // FIXME(nillerusr): causing a crash, reason: misalign?
|
||||||
//if ( nHasSIMD )
|
if ( nHasSIMD )
|
||||||
//{
|
{
|
||||||
// meshBuilder.FastVertexSSE( dstVertex );
|
meshBuilder.FastVertexSSE( dstVertex );
|
||||||
//}
|
}
|
||||||
//else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
meshBuilder.FastVertex( dstVertex );
|
meshBuilder.FastVertex( dstVertex );
|
||||||
}
|
}
|
||||||
@ -1251,11 +1252,13 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if 0 // FIXME(nillerusr): causing a crash, reason: misalign?
|
||||||
if ( nHasSIMD )
|
if ( nHasSIMD )
|
||||||
{
|
{
|
||||||
meshBuilder.FastVertexSSE( *(ModelVertexDX7_t*)&dstVertex );
|
meshBuilder.FastVertexSSE( *(ModelVertexDX7_t*)&dstVertex );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
meshBuilder.FastVertex( *(ModelVertexDX7_t*)&dstVertex );
|
meshBuilder.FastVertex( *(ModelVertexDX7_t*)&dstVertex );
|
||||||
}
|
}
|
||||||
|
@ -1484,7 +1484,8 @@ void TextEntry::OnMousePressed(MouseCode code)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pInputSystem->StartTextInput();
|
if( IsEnabled() )
|
||||||
|
g_pInputSystem->StartTextInput();
|
||||||
|
|
||||||
// move the cursor to where the mouse was pressed
|
// move the cursor to where the mouse was pressed
|
||||||
int x, y;
|
int x, y;
|
||||||
|
@ -652,6 +652,9 @@ void CConsolePanel::OnTextChanged(Panel *panel)
|
|||||||
// see if they've hit the tilde key (which opens & closes the console)
|
// see if they've hit the tilde key (which opens & closes the console)
|
||||||
int len = Q_strlen(m_szPartialText);
|
int len = Q_strlen(m_szPartialText);
|
||||||
|
|
||||||
|
if( !len )
|
||||||
|
return;
|
||||||
|
|
||||||
bool hitTilde = ( m_szPartialText[len - 1] == '~' || m_szPartialText[len - 1] == '`' ) ? true : false;
|
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;
|
bool altKeyDown = ( vgui::input()->IsKeyDown( KEY_LALT ) || vgui::input()->IsKeyDown( KEY_RALT ) ) ? true : false;
|
||||||
@ -1253,4 +1256,4 @@ void CConsoleDialog::OnKeyCodePressed( vgui::KeyCode code )
|
|||||||
{
|
{
|
||||||
BaseClass::OnKeyCodePressed(code);
|
BaseClass::OnKeyCodePressed(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,8 @@ void CPhysicsObject::SetMass( float mass )
|
|||||||
}
|
}
|
||||||
|
|
||||||
Assert( mass > 0 );
|
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 );
|
m_pObject->change_mass( mass );
|
||||||
SetVolume( m_volume );
|
SetVolume( m_volume );
|
||||||
RecomputeDragBases();
|
RecomputeDragBases();
|
||||||
@ -633,13 +634,17 @@ Vector CPhysicsObject::GetInvInertia( void ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CPhysicsObject::SetInertia( const Vector &inertia )
|
void CPhysicsObject::SetInertia( const Vector &inertia )
|
||||||
{
|
{
|
||||||
IVP_U_Float_Point ri;
|
IVP_U_Float_Point ri; ConvertDirectionToIVP( inertia, ri );
|
||||||
ConvertDirectionToIVP( inertia, ri );
|
|
||||||
ri.k[0] = IVP_Inline_Math::fabsd(ri.k[0]);
|
ri.k[0] = IVP_Inline_Math::fabsd(ri.k[0]);
|
||||||
ri.k[1] = IVP_Inline_Math::fabsd(ri.k[1]);
|
ri.k[1] = IVP_Inline_Math::fabsd(ri.k[1]);
|
||||||
ri.k[2] = IVP_Inline_Math::fabsd(ri.k[2]);
|
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 );
|
m_pObject->get_core()->set_rotation_inertia( &ri );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1358,6 +1363,7 @@ bool CPhysicsObject::IsFluid() const
|
|||||||
// sets the object to be hinged. Fixed it place, but able to rotate around one axis.
|
// sets the object to be hinged. Fixed it place, but able to rotate around one axis.
|
||||||
void CPhysicsObject::BecomeHinged( int localAxis )
|
void CPhysicsObject::BecomeHinged( int localAxis )
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( IsMoveable() )
|
if ( IsMoveable() )
|
||||||
{
|
{
|
||||||
float savedMass = GetMass();
|
float savedMass = GetMass();
|
||||||
@ -1370,6 +1376,7 @@ void CPhysicsObject::BecomeHinged( int localAxis )
|
|||||||
|
|
||||||
SetMass( VPHYSICS_MAX_MASS );
|
SetMass( VPHYSICS_MAX_MASS );
|
||||||
IVP_U_Float_Hesse tmp = *iri;
|
IVP_U_Float_Hesse tmp = *iri;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
for ( i = 0; i < 3; i++ )
|
for ( i = 0; i < 3; i++ )
|
||||||
tmp.k[i] = savedRI[i];
|
tmp.k[i] = savedRI[i];
|
||||||
@ -1394,10 +1401,10 @@ void CPhysicsObject::RemoveHinged()
|
|||||||
void CPhysicsObject::OutputDebugInfo() const
|
void CPhysicsObject::OutputDebugInfo() const
|
||||||
{
|
{
|
||||||
Msg("-----------------\nObject: %s\n", m_pObject->get_name());
|
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 inertia = GetInertia();
|
||||||
Vector invInertia = GetInvInertia();
|
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;
|
Vector speed, angSpeed;
|
||||||
GetVelocity( &speed, &angSpeed );
|
GetVelocity( &speed, &angSpeed );
|
||||||
@ -1406,7 +1413,7 @@ void CPhysicsObject::OutputDebugInfo() const
|
|||||||
|
|
||||||
float damp, angDamp;
|
float damp, angDamp;
|
||||||
GetDamping( &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("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 );
|
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
|
|||||||
|
|
||||||
static void InitObjectTemplate( IVP_Template_Real_Object &objectTemplate, int materialIndex, objectparams_t *pParams, bool isStatic )
|
static void InitObjectTemplate( IVP_Template_Real_Object &objectTemplate, int materialIndex, objectparams_t *pParams, bool isStatic )
|
||||||
{
|
{
|
||||||
objectTemplate.mass = pParams->mass;
|
objectTemplate.mass = clamp( pParams->mass, VPHYSICS_MIN_MASS, VPHYSICS_MAX_MASS );
|
||||||
objectTemplate.mass = clamp( objectTemplate.mass, VPHYSICS_MIN_MASS, VPHYSICS_MAX_MASS );
|
|
||||||
|
|
||||||
if ( materialIndex >= 0 )
|
if ( materialIndex >= 0 )
|
||||||
{
|
{
|
||||||
@ -1495,8 +1501,8 @@ static void InitObjectTemplate( IVP_Template_Real_Object &objectTemplate, int ma
|
|||||||
if ( inertia <= 0 )
|
if ( inertia <= 0 )
|
||||||
inertia = 1.0;
|
inertia = 1.0;
|
||||||
|
|
||||||
if ( inertia > 1e18f )
|
if ( inertia > 1e14f )
|
||||||
inertia = 1e18f;
|
inertia = 1e14f;
|
||||||
|
|
||||||
objectTemplate.rot_inertia.set(inertia, inertia, inertia);
|
objectTemplate.rot_inertia.set(inertia, inertia, inertia);
|
||||||
objectTemplate.rot_speed_damp_factor.set(pParams->rotdamping, pParams->rotdamping, pParams->rotdamping);
|
objectTemplate.rot_speed_damp_factor.set(pParams->rotdamping, pParams->rotdamping, pParams->rotdamping);
|
||||||
|
@ -1052,7 +1052,7 @@ void CShadowController::AttachObject( void )
|
|||||||
|
|
||||||
if ( !m_allowsRotation )
|
if ( !m_allowsRotation )
|
||||||
{
|
{
|
||||||
IVP_U_Float_Point ri( 1e15f, 1e15f, 1e15f );
|
IVP_U_Float_Point ri( 1e14f, 1e14f, 1e14f );
|
||||||
pCore->set_rotation_inertia( &ri );
|
pCore->set_rotation_inertia( &ri );
|
||||||
}
|
}
|
||||||
if ( !m_allowsTranslation )
|
if ( !m_allowsTranslation )
|
||||||
|
@ -174,7 +174,13 @@ void CVPhysicsParse::ParseSolid( solid_t *pSolid, IVPhysicsKeyHandler *unknownKe
|
|||||||
}
|
}
|
||||||
else if ( !Q_stricmp( key, "inertia" ) )
|
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" ) )
|
else if ( !Q_stricmp( key, "damping" ) )
|
||||||
{
|
{
|
||||||
@ -468,7 +474,13 @@ void CVPhysicsParse::ParseVehicleWheel( vehicle_wheelparams_t &wheel )
|
|||||||
}
|
}
|
||||||
else if ( !Q_stricmp( key, "inertia" ) )
|
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" ) )
|
else if ( !Q_stricmp( key, "damping" ) )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user