add btVector3::safeNorm to avoid/workaround certain clang/g++ issue or returning -INF
when taking sqrtf(0.0000000000000000000000000000000000000108333558)
This commit is contained in:
@@ -267,10 +267,20 @@ public:
|
||||
|
||||
/**@brief Return the norm (length) of the vector */
|
||||
SIMD_FORCE_INLINE btScalar norm() const
|
||||
{
|
||||
{
|
||||
return length();
|
||||
}
|
||||
|
||||
/**@brief Return the norm (length) of the vector */
|
||||
SIMD_FORCE_INLINE btScalar safeNorm() const
|
||||
{
|
||||
btScalar d = length2();
|
||||
//workaround for some clang/gcc issue of sqrtf(tiny number) = -INF
|
||||
if (d>SIMD_EPSILON)
|
||||
return btSqrt(d);
|
||||
return btScalar(0);
|
||||
}
|
||||
|
||||
/**@brief Return the distance squared between the ends of this and another vector
|
||||
* This is symantically treating the vector like a point */
|
||||
SIMD_FORCE_INLINE btScalar distance2(const btVector3& v) const;
|
||||
|
||||
Reference in New Issue
Block a user