Use standard library functions for llisnan and replace obvious NaN checks that don't work using /fp:fast floating point behavior under MSVC

master
Ansariel 2025-04-17 18:44:09 +02:00
parent 293462d8ff
commit d65de99052
3 changed files with 16 additions and 27 deletions

View File

@ -550,12 +550,12 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
mLastSex = avatar_sex;
// Check for NaN condition (NaN is detected if a variable doesn't equal itself.
if (mCurWeight != mCurWeight)
// Check for NaN condition
if (llisnan(mCurWeight))
{
mCurWeight = 0.0;
mCurWeight = 0.f;
}
if (mLastWeight != mLastWeight)
if (llisnan(mLastWeight))
{
mLastWeight = mCurWeight+.001f;
}

View File

@ -39,18 +39,8 @@
// llcommon depend on llmath.
#include "is_approx_equal_fraction.h"
// work around for Windows & older gcc non-standard function names.
#if LL_WINDOWS
#include <float.h>
#define llisnan(val) _isnan(val)
#define llfinite(val) _finite(val)
#elif (LL_LINUX && __GNUC__ <= 2)
#define llisnan(val) isnan(val)
#define llfinite(val) isfinite(val)
#else
#define llisnan(val) std::isnan(val)
#define llfinite(val) std::isfinite(val)
#endif
#define llisnan(val) std::isnan(val)
#define llfinite(val) std::isfinite(val)
// Single Precision Floating Point Routines
// (There used to be more defined here, but they appeared to be redundant and

View File

@ -646,18 +646,17 @@ bool LLPhysicsMotion::onUpdate(F32 time)
velocity_new_local = 0;
}
// Check for NaN values. A NaN value is detected if the variables doesn't equal itself.
// If NaN, then reset everything.
if ((mPosition_local != mPosition_local) ||
(mVelocity_local != mVelocity_local) ||
(position_new_local != position_new_local))
// Check for NaN values. If NaN, then reset everything.
if (llisnan(mPosition_local) ||
llisnan(mVelocity_local) ||
llisnan(position_new_local))
{
position_new_local = 0;
mVelocity_local = 0;
mVelocityJoint_local = 0;
mAccelerationJoint_local = 0;
mPosition_local = 0;
mPosition_world = LLVector3(0,0,0);
position_new_local = 0.f;
mVelocity_local = 0.f;
mVelocityJoint_local = 0.f;
mAccelerationJoint_local = 0.f;
mPosition_local = 0.f;
mPosition_world = LLVector3(0.f,0.f,0.f);
}
const F32 position_new_local_clamped = llclamp(position_new_local,