Browse Source

Replace 1e24 with 1e16 to avoid float overflow

pull/26/head
nillerusr 3 years ago
parent
commit
cb04a1e451
  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. 4
      game/client/particle_iterators.h
  7. 2
      game/client/tf2/c_obj_mcv_selection_panel.cpp
  8. 2
      game/client/tf2/c_ragdoll_shadow.cpp
  9. 2
      game/server/player.cpp
  10. 2
      game/server/tf2/order_heal.cpp
  11. 2
      game/server/tf2/order_helpers.cpp
  12. 2
      game/server/tf2/order_killmortarguy.cpp
  13. 2
      game/server/tf2/order_mortar_attack.cpp
  14. 4
      game/server/tf2/order_repair.cpp
  15. 2
      game/server/tf2/tf_obj_barbed_wire.cpp
  16. 2
      game/server/tf2/tf_playerclass.cpp
  17. 2
      game/server/tf2/tf_team.h
  18. 2
      game/shared/physics_shared.cpp
  19. 4
      public/disp_common.cpp
  20. 2
      public/keyframe/keyframe.cpp
  21. 2
      vphysics/ledgewriter.cpp
  22. 6
      vphysics/trace.cpp

2
engine/cmodel.cpp

@ -2788,7 +2788,7 @@ int CFastPointLeafNum::GetLeaf( const Vector &vPos )
m_vCachedPos = vPos; m_vCachedPos = vPos;
CCollisionBSPData *pBSPData = GetCollisionBSPData(); CCollisionBSPData *pBSPData = GetCollisionBSPData();
m_flDistToExitLeafSqr = 1e24; m_flDistToExitLeafSqr = 1e16;
m_iCachedLeaf = CM_PointLeafnumMinDistSqr_r( pBSPData, vPos, 0, m_flDistToExitLeafSqr ); 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
void CDispInfo::UpdateBoundingBox() void CDispInfo::UpdateBoundingBox()
{ {
m_BBoxMin.Init( 1e24, 1e24, 1e24 ); m_BBoxMin.Init( 1e16, 1e16, 1e16 );
m_BBoxMax.Init( -1e24, -1e24, -1e24 ); m_BBoxMax.Init( -1e16, -1e16, -1e16 );
for( int i=0; i < NumVerts(); i++ ) for( int i=0; i < NumVerts(); i++ )
{ {

4
engine/disp_mapload.cpp

@ -793,7 +793,7 @@ CDispInfo::CDispInfo()
m_pPowerInfo = NULL; m_pPowerInfo = NULL;
m_ViewerSphereCenter.Init( 1e24, 1e24, 1e24 ); m_ViewerSphereCenter.Init( 1e16, 1e16, 1e16 );
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 = 1e24; float flClosest = 1e16;
for ( int iCorner = 0; iCorner < 4; ++iCorner ) for ( int iCorner = 0; iCorner < 4; ++iCorner )
{ {

4
engine/r_areaportal.cpp

@ -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 = 1e24; portalRect.left = portalRect.bottom = 1e16;
portalRect.right = portalRect.top = -1e24; portalRect.right = portalRect.top = -1e16;
bool bValidExtents = false; bool bValidExtents = false;
worldbrushdata_t *pBrushData = host_state.worldbrush; worldbrushdata_t *pBrushData = host_state.worldbrush;

4
game/client/c_steamjet.cpp

@ -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( 1e24, 1e24, 1e24 ); m_vLastRampUpdatePos.Init( 1e16, 1e16, 1e16 );
m_vLastRampUpdateAngles.Init( 1e24, 1e24, 1e24 ); m_vLastRampUpdateAngles.Init( 1e16, 1e16, 1e16 );
} }

4
game/client/particle_iterators.h

@ -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 = 1e24; m_MinZ = 1e16;
m_MaxZ = -1e24; m_MaxZ = -1e16;
m_nZCoords = 0; m_nZCoords = 0;
} }

2
game/client/tf2/c_obj_mcv_selection_panel.cpp

@ -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 = 1e24; float flClosest = 1e16;
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++ )

2
game/client/tf2/c_ragdoll_shadow.cpp

@ -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 = 1e24f; solid.params.inertia = 1e16f;
int surfaceProp = -1; int surfaceProp = -1;
if ( props && props[0] ) if ( props && props[0] )
{ {

2
game/server/player.cpp

@ -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 = 1e24f; solid.params.inertia = 1e16f;
solid.params.enableCollisions = false; solid.params.enableCollisions = false;
//disable drag //disable drag
solid.params.dragCoefficient = 0; solid.params.dragCoefficient = 0;

2
game/server/tf2/order_heal.cpp

@ -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(),
1e24, 1e16,
60, 60,
pOrder ); pOrder );

2
game/server/tf2/order_helpers.cpp

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

2
game/server/tf2/order_killmortarguy.cpp

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

2
game/server/tf2/order_mortar_attack.cpp

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

4
game/server/tf2/order_repair.cpp

@ -91,7 +91,7 @@ bool COrderRepair::CreateOrder_RepairFriendlyObjects( CPlayerClassDefender *pCla
ORDER_REPAIR, ORDER_REPAIR,
pObjToHeal, pObjToHeal,
pPlayer, pPlayer,
1e24, 1e16,
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,
1e24, 1e16,
60, 60,
pOrder pOrder
); );

2
game/server/tf2/tf_obj_barbed_wire.cpp

@ -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 = 1e24; float flClosest = 1e16;
CObjectBarbedWire *pClosest = NULL; CObjectBarbedWire *pClosest = NULL;
CBaseEntity *pCur = gEntList.FirstEnt(); CBaseEntity *pCur = gEntList.FirstEnt();

2
game/server/tf2/tf_playerclass.cpp

@ -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 = 1e24f; solid.params.inertia = 1e16f;
solid.params.enableCollisions = false; solid.params.enableCollisions = false;
//disable drag //disable drag
solid.params.dragCoefficient = 0; solid.params.dragCoefficient = 0;

2
game/server/tf2/tf_team.h

@ -145,7 +145,7 @@ public:
int iOrderType, int iOrderType,
CBaseEntity *pTarget, CBaseEntity *pTarget,
CBaseTFPlayer *pPlayer = NULL, CBaseTFPlayer *pPlayer = NULL,
float flDistanceToRemove = 1e24, float flDistanceToRemove = 1e16,
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.

2
game/shared/physics_shared.cpp

@ -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 = 1e24f; solid.params.inertia = 1e16f;
Q_strncpy( solid.surfaceprop, "default", sizeof( solid.surfaceprop ) ); Q_strncpy( solid.surfaceprop, "default", sizeof( solid.surfaceprop ) );
} }

4
public/disp_common.cpp

@ -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( 1e24, 1e24, 1e24 ); Vector vMin( 1e16, 1e16, 1e16 );
Vector vMax( -1e24, -1e24, -1e24 ); Vector vMax( -1e16, -1e16, -1e16 );
for ( int iVert = 0; iVert < 4; ++iVert ) for ( int iVert = 0; iVert < 4; ++iVert )
{ {

2
public/keyframe/keyframe.cpp

@ -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( 1e24, 1e24, 1e24 ); m_Delegate.m_CurEndPoints[i] = Vector( 1e16, 1e16, 1e16 );
} }
void CPositionInterpolator_Rope::Release() void CPositionInterpolator_Rope::Release()

2
vphysics/ledgewriter.cpp

@ -65,7 +65,7 @@ static void BuildVertMap( vertmap_t &out, const Vector *pVerts, int vertexCount,
int index = -1; int index = -1;
Vector tmp; Vector tmp;
ConvertPositionToHL( &pVertList[ivpIndex], tmp); ConvertPositionToHL( &pVertList[ivpIndex], tmp);
float minDist = 1e24; float minDist = 1e16;
for ( int k = 0; k < vertexCount; k++ ) for ( int k = 0; k < vertexCount; k++ )
{ {
float dist = (tmp-pVerts[k]).Length(); float dist = (tmp-pVerts[k]).Length();

6
vphysics/trace.cpp

@ -1231,7 +1231,7 @@ loop_without_store:
const IVP_Compact_Ledgetree_Node *node0 = node->left_son(); const IVP_Compact_Ledgetree_Node *node0 = node->left_son();
center.set(node0->center.k); center.set(node0->center.k);
// if we don't insert, this is larger than any quad distance // if we don't insert, this is larger than any quad distance
float lastDist = 1e24f; float lastDist = 1e16f;
if ( SweepHitsSphereOS( &center, node0->radius ) ) if ( SweepHitsSphereOS( &center, node0->radius ) )
{ {
lastDist = m_rayStartOS.quad_distance_to(&center); lastDist = m_rayStartOS.quad_distance_to(&center);
@ -2073,7 +2073,7 @@ inline float Clip( const Vector &dir, const Vector &pos, const Vector &normal )
return dist / cosTheta; return dist / cosTheta;
// parallel or not facing the plane // parallel or not facing the plane
return 1e24f; return 1e16f;
} }
// This is the first iteration of solving time of intersection. // This is the first iteration of solving time of intersection.
@ -2258,7 +2258,7 @@ float simplex_t::ClipRayToTriangle( const Vector &dir, float epsilon )
} }
float dot = DotProduct( dir, *normals[best] ); float dot = DotProduct( dir, *normals[best] );
if ( dot <= 0 ) if ( dot <= 0 )
return 1e24f; return 1e16f;
dmin += epsilon/dot; dmin += epsilon/dot;
return dmin; return dmin;

Loading…
Cancel
Save