Contribution to add optional double precision floating point support. Define BT_USE_DOUBLE_PRECISION for all involved libraries/apps.
This commit is contained in:
@@ -73,8 +73,8 @@ SIMD_FORCE_INLINE bool btRayAabb(const btVector3& rayFrom,
|
||||
const btVector3& aabbMax,
|
||||
btScalar& param, btVector3& normal)
|
||||
{
|
||||
btVector3 aabbHalfExtent = (aabbMax-aabbMin)* 0.5f;
|
||||
btVector3 aabbCenter = (aabbMax+aabbMin)* 0.5f;
|
||||
btVector3 aabbHalfExtent = (aabbMax-aabbMin)* btScalar(0.5);
|
||||
btVector3 aabbCenter = (aabbMax+aabbMin)* btScalar(0.5);
|
||||
btVector3 source = rayFrom - aabbCenter;
|
||||
btVector3 target = rayTo - aabbCenter;
|
||||
int sourceOutcode = btOutcode(source,aabbHalfExtent);
|
||||
@@ -110,7 +110,7 @@ SIMD_FORCE_INLINE bool btRayAabb(const btVector3& rayFrom,
|
||||
}
|
||||
bit<<=1;
|
||||
}
|
||||
normSign = -1.f;
|
||||
normSign = btScalar(-1.);
|
||||
}
|
||||
if (lambda_enter <= lambda_exit)
|
||||
{
|
||||
|
||||
@@ -16,14 +16,14 @@ subject to the following restrictions:
|
||||
|
||||
#include "btGeometryUtil.h"
|
||||
|
||||
bool btGeometryUtil::isPointInsidePlanes(const btAlignedObjectArray<btVector3>& planeEquations, const btVector3& point, float margin)
|
||||
bool btGeometryUtil::isPointInsidePlanes(const btAlignedObjectArray<btVector3>& planeEquations, const btVector3& point, btScalar margin)
|
||||
{
|
||||
int numbrushes = planeEquations.size();
|
||||
for (int i=0;i<numbrushes;i++)
|
||||
{
|
||||
const btVector3& N1 = planeEquations[i];
|
||||
float dist = float(N1.dot(point))+float(N1[3])-margin;
|
||||
if (dist>0.f)
|
||||
btScalar dist = btScalar(N1.dot(point))+btScalar(N1[3])-margin;
|
||||
if (dist>btScalar(0.))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -33,14 +33,14 @@ bool btGeometryUtil::isPointInsidePlanes(const btAlignedObjectArray<btVector3>&
|
||||
}
|
||||
|
||||
|
||||
bool btGeometryUtil::areVerticesBehindPlane(const btVector3& planeNormal, const btAlignedObjectArray<btVector3>& vertices, float margin)
|
||||
bool btGeometryUtil::areVerticesBehindPlane(const btVector3& planeNormal, const btAlignedObjectArray<btVector3>& vertices, btScalar margin)
|
||||
{
|
||||
int numvertices = vertices.size();
|
||||
for (int i=0;i<numvertices;i++)
|
||||
{
|
||||
const btVector3& N1 = vertices[i];
|
||||
float dist = float(planeNormal.dot(N1))+float(planeNormal[3])-margin;
|
||||
if (dist>0.f)
|
||||
btScalar dist = btScalar(planeNormal.dot(N1))+btScalar(planeNormal[3])-margin;
|
||||
if (dist>btScalar(0.))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ bool notExist(const btVector3& planeEquation,const btAlignedObjectArray<btVector
|
||||
for (int i=0;i<numbrushes;i++)
|
||||
{
|
||||
const btVector3& N1 = planeEquations[i];
|
||||
if (planeEquation.dot(N1) > 0.999f)
|
||||
if (planeEquation.dot(N1) > btScalar(0.999))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -83,11 +83,11 @@ void btGeometryUtil::getPlaneEquationsFromVertices(btAlignedObjectArray<btVector
|
||||
btVector3 planeEquation,edge0,edge1;
|
||||
edge0 = N2-N1;
|
||||
edge1 = N3-N1;
|
||||
float normalSign = 1.f;
|
||||
btScalar normalSign = btScalar(1.);
|
||||
for (int ww=0;ww<2;ww++)
|
||||
{
|
||||
planeEquation = normalSign * edge0.cross(edge1);
|
||||
if (planeEquation.length2() > 0.0001f)
|
||||
if (planeEquation.length2() > btScalar(0.0001))
|
||||
{
|
||||
planeEquation.normalize();
|
||||
if (notExist(planeEquation,planeEquationsOut))
|
||||
@@ -95,13 +95,13 @@ void btGeometryUtil::getPlaneEquationsFromVertices(btAlignedObjectArray<btVector
|
||||
planeEquation[3] = -planeEquation.dot(N1);
|
||||
|
||||
//check if inside, and replace supportingVertexOut if needed
|
||||
if (areVerticesBehindPlane(planeEquation,vertices,0.01f))
|
||||
if (areVerticesBehindPlane(planeEquation,vertices,btScalar(0.01)))
|
||||
{
|
||||
planeEquationsOut.push_back(planeEquation);
|
||||
}
|
||||
}
|
||||
}
|
||||
normalSign = -1.f;
|
||||
normalSign = btScalar(-1.);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -132,9 +132,9 @@ void btGeometryUtil::getVerticesFromPlaneEquations(const btAlignedObjectArray<bt
|
||||
btVector3 n3n1; n3n1 = N3.cross(N1);
|
||||
btVector3 n1n2; n1n2 = N1.cross(N2);
|
||||
|
||||
if ( ( n2n3.length2() > 0.0001f ) &&
|
||||
( n3n1.length2() > 0.0001f ) &&
|
||||
( n1n2.length2() > 0.0001f ) )
|
||||
if ( ( n2n3.length2() > btScalar(0.0001) ) &&
|
||||
( n3n1.length2() > btScalar(0.0001) ) &&
|
||||
( n1n2.length2() > btScalar(0.0001) ) )
|
||||
{
|
||||
//point P out of 3 plane equations:
|
||||
|
||||
@@ -143,10 +143,10 @@ void btGeometryUtil::getVerticesFromPlaneEquations(const btAlignedObjectArray<bt
|
||||
// N1 . ( N2 * N3 )
|
||||
|
||||
|
||||
float quotient = (N1.dot(n2n3));
|
||||
if (btFabs(quotient) > 0.000001f)
|
||||
btScalar quotient = (N1.dot(n2n3));
|
||||
if (btFabs(quotient) > btScalar(0.000001))
|
||||
{
|
||||
quotient = -1.f / quotient;
|
||||
quotient = btScalar(-1.) / quotient;
|
||||
n2n3 *= N1[3];
|
||||
n3n1 *= N2[3];
|
||||
n1n2 *= N3[3];
|
||||
@@ -156,7 +156,7 @@ void btGeometryUtil::getVerticesFromPlaneEquations(const btAlignedObjectArray<bt
|
||||
potentialVertex *= quotient;
|
||||
|
||||
//check if inside, and replace supportingVertexOut if needed
|
||||
if (isPointInsidePlanes(planeEquations,potentialVertex,0.01f))
|
||||
if (isPointInsidePlanes(planeEquations,potentialVertex,btScalar(0.01)))
|
||||
{
|
||||
verticesOut.push_back(potentialVertex);
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ class btGeometryUtil
|
||||
|
||||
static void getVerticesFromPlaneEquations(const btAlignedObjectArray<btVector3>& planeEquations , btAlignedObjectArray<btVector3>& verticesOut );
|
||||
|
||||
static bool isInside(const btAlignedObjectArray<btVector3>& vertices, const btVector3& planeNormal, float margin);
|
||||
static bool isInside(const btAlignedObjectArray<btVector3>& vertices, const btVector3& planeNormal, btScalar margin);
|
||||
|
||||
static bool isPointInsidePlanes(const btAlignedObjectArray<btVector3>& planeEquations, const btVector3& point, float margin);
|
||||
static bool isPointInsidePlanes(const btAlignedObjectArray<btVector3>& planeEquations, const btVector3& point, btScalar margin);
|
||||
|
||||
static bool areVerticesBehindPlane(const btVector3& planeNormal, const btAlignedObjectArray<btVector3>& vertices, float margin);
|
||||
static bool areVerticesBehindPlane(const btVector3& planeNormal, const btAlignedObjectArray<btVector3>& vertices, btScalar margin);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class btIDebugDraw
|
||||
|
||||
virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color)=0;
|
||||
|
||||
virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color)=0;
|
||||
virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color)=0;
|
||||
|
||||
virtual void setDebugMode(int debugMode) =0;
|
||||
|
||||
|
||||
@@ -323,8 +323,8 @@ class btMatrix3x3 {
|
||||
{
|
||||
btVector3 co(cofac(1, 1, 2, 2), cofac(1, 2, 2, 0), cofac(1, 0, 2, 1));
|
||||
btScalar det = (*this)[0].dot(co);
|
||||
assert(det != btScalar(0.0f));
|
||||
btScalar s = btScalar(1.0f) / det;
|
||||
assert(det != btScalar(0.0));
|
||||
btScalar s = btScalar(1.0) / det;
|
||||
return btMatrix3x3(co[0] * s, cofac(0, 2, 2, 1) * s, cofac(0, 1, 1, 2) * s,
|
||||
co[1] * s, cofac(0, 0, 2, 2) * s, cofac(0, 2, 1, 0) * s,
|
||||
co[2] * s, cofac(0, 1, 2, 0) * s, cofac(0, 0, 1, 1) * s);
|
||||
|
||||
@@ -40,11 +40,11 @@ ATTRIBUTE_ALIGNED16 (class btQuadWord)
|
||||
|
||||
SIMD_FORCE_INLINE const btScalar& getZ() const { return m_z; }
|
||||
|
||||
SIMD_FORCE_INLINE void setX(float x) { m_x = x;};
|
||||
SIMD_FORCE_INLINE void setX(btScalar x) { m_x = x;};
|
||||
|
||||
SIMD_FORCE_INLINE void setY(float y) { m_y = y;};
|
||||
SIMD_FORCE_INLINE void setY(btScalar y) { m_y = y;};
|
||||
|
||||
SIMD_FORCE_INLINE void setZ(float z) { m_z = z;};
|
||||
SIMD_FORCE_INLINE void setZ(btScalar z) { m_z = z;};
|
||||
|
||||
SIMD_FORCE_INLINE const btScalar& x() const { return m_x; }
|
||||
|
||||
@@ -79,14 +79,14 @@ ATTRIBUTE_ALIGNED16 (class btQuadWord)
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE btQuadWord() :
|
||||
m_x(0.f),m_y(0.f),m_z(0.f),m_unusedW(0.f)
|
||||
m_x(btScalar(0.)),m_y(btScalar(0.)),m_z(btScalar(0.)),m_unusedW(btScalar(0.))
|
||||
{
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE btQuadWord(const btScalar& x, const btScalar& y, const btScalar& z)
|
||||
:m_x(x),m_y(y),m_z(z)
|
||||
//todo, remove this in release/simd ?
|
||||
,m_unusedW(0.f)
|
||||
,m_unusedW(btScalar(0.))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
|
||||
btScalar getAngle() const
|
||||
{
|
||||
btScalar s = 2.f * btAcos(m_unusedW);
|
||||
btScalar s = btScalar(2.) * btAcos(m_unusedW);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,14 +50,23 @@ subject to the following restrictions:
|
||||
#define btAssert assert
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef float btScalar;
|
||||
|
||||
///older compilers (gcc 3.x) and Sun needs double versions of srqt etc.
|
||||
///exclude Apple Intel (it's assumed to be a Macbook or newer Intel Dual Core processor)
|
||||
/// older compilers (gcc 3.x) and Sun needs double version of sqrt etc.
|
||||
/// exclude Apple Intel (i's assumed to be a Macbook or new Intel Dual Core Processor)
|
||||
#if defined (__sun) || defined (__sun__) || defined (__sparc) || (defined (__APPLE__) && ! defined (__i386__))
|
||||
//use slow double float precision operation on those platforms
|
||||
#ifndef BT_USE_DOUBLE_PRECISION
|
||||
#define BT_FORCE_DOUBLE_FUNCTIONS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BT_USE_DOUBLE_PRECISION)
|
||||
typedef double btScalar;
|
||||
#else
|
||||
typedef float btScalar;
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(BT_USE_DOUBLE_PRECISION) || defined(BT_FORCE_DOUBLE_FUNCTIONS)
|
||||
|
||||
SIMD_FORCE_INLINE btScalar btSqrt(btScalar x) { return sqrt(x); }
|
||||
SIMD_FORCE_INLINE btScalar btFabs(btScalar x) { return fabs(x); }
|
||||
@@ -90,11 +99,11 @@ SIMD_FORCE_INLINE btScalar btPow(btScalar x,btScalar y) { return powf(x,y); }
|
||||
#endif
|
||||
|
||||
|
||||
#define SIMD_2_PI 6.283185307179586232f
|
||||
#define SIMD_PI (SIMD_2_PI * btScalar(0.5f))
|
||||
#define SIMD_HALF_PI (SIMD_2_PI * btScalar(0.25f))
|
||||
#define SIMD_RADS_PER_DEG (SIMD_2_PI / btScalar(360.0f))
|
||||
#define SIMD_DEGS_PER_RAD (btScalar(360.0f) / SIMD_2_PI)
|
||||
#define SIMD_2_PI btScalar(6.283185307179586232)
|
||||
#define SIMD_PI (SIMD_2_PI * btScalar(0.5))
|
||||
#define SIMD_HALF_PI (SIMD_2_PI * btScalar(0.25))
|
||||
#define SIMD_RADS_PER_DEG (SIMD_2_PI / btScalar(360.0))
|
||||
#define SIMD_DEGS_PER_RAD (btScalar(360.0) / SIMD_2_PI)
|
||||
#define SIMD_EPSILON FLT_EPSILON
|
||||
#define SIMD_INFINITY FLT_MAX
|
||||
|
||||
@@ -117,7 +126,7 @@ SIMD_FORCE_INLINE btScalar btAtan2(btScalar x, btScalar y) { return atan2f(x, y)
|
||||
*/
|
||||
|
||||
SIMD_FORCE_INLINE int btIsNegative(btScalar x) {
|
||||
return x < 0.0f ? 1 : 0;
|
||||
return x < btScalar(0.0) ? 1 : 0;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE btScalar btRadians(btScalar x) { return x * SIMD_RADS_PER_DEG; }
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
m[12] = m_origin[0];
|
||||
m[13] = m_origin[1];
|
||||
m[14] = m_origin[2];
|
||||
m[15] = btScalar(1.0f);
|
||||
m[15] = btScalar(1.0);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE void setOrigin(const btVector3& origin)
|
||||
|
||||
@@ -17,19 +17,19 @@ subject to the following restrictions:
|
||||
#define SIMD_TRANSFORM_UTIL_H
|
||||
|
||||
#include "LinearMath/btTransform.h"
|
||||
#define ANGULAR_MOTION_THRESHOLD 0.5f*SIMD_HALF_PI
|
||||
#define ANGULAR_MOTION_THRESHOLD btScalar(0.5)*SIMD_HALF_PI
|
||||
|
||||
|
||||
|
||||
#define SIMDSQRT12 btScalar(0.7071067811865475244008443621048490)
|
||||
|
||||
#define btRecipSqrt(x) ((float)(1.0f/btSqrt(float(x)))) /* reciprocal square root */
|
||||
#define btRecipSqrt(x) ((btScalar)(btScalar(1.0)/btSqrt(btScalar(x)))) /* reciprocal square root */
|
||||
|
||||
inline btVector3 btAabbSupport(const btVector3& halfExtents,const btVector3& supportDir)
|
||||
{
|
||||
return btVector3(supportDir.x() < btScalar(0.0f) ? -halfExtents.x() : halfExtents.x(),
|
||||
supportDir.y() < btScalar(0.0f) ? -halfExtents.y() : halfExtents.y(),
|
||||
supportDir.z() < btScalar(0.0f) ? -halfExtents.z() : halfExtents.z());
|
||||
return btVector3(supportDir.x() < btScalar(0.0) ? -halfExtents.x() : halfExtents.x(),
|
||||
supportDir.y() < btScalar(0.0) ? -halfExtents.y() : halfExtents.y(),
|
||||
supportDir.z() < btScalar(0.0) ? -halfExtents.z() : halfExtents.z());
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
// #define QUATERNION_DERIVATIVE
|
||||
#ifdef QUATERNION_DERIVATIVE
|
||||
btQuaternion orn = curTrans.getRotation();
|
||||
orn += (angvel * orn) * (timeStep * 0.5f);
|
||||
orn += (angvel * orn) * (timeStep * btScalar(0.5));
|
||||
orn.normalize();
|
||||
#else
|
||||
//exponential map
|
||||
@@ -87,17 +87,17 @@ public:
|
||||
fAngle = ANGULAR_MOTION_THRESHOLD / timeStep;
|
||||
}
|
||||
|
||||
if ( fAngle < 0.001f )
|
||||
if ( fAngle < btScalar(0.001) )
|
||||
{
|
||||
// use Taylor's expansions of sync function
|
||||
axis = angvel*( 0.5f*timeStep-(timeStep*timeStep*timeStep)*(0.020833333333f)*fAngle*fAngle );
|
||||
axis = angvel*( btScalar(0.5)*timeStep-(timeStep*timeStep*timeStep)*(btScalar(0.020833333333))*fAngle*fAngle );
|
||||
}
|
||||
else
|
||||
{
|
||||
// sync(fAngle) = sin(c*fAngle)/t
|
||||
axis = angvel*( btSin(0.5f*fAngle*timeStep)/fAngle );
|
||||
axis = angvel*( btSin(btScalar(0.5)*fAngle*timeStep)/fAngle );
|
||||
}
|
||||
btQuaternion dorn (axis.x(),axis.y(),axis.z(),btCos( fAngle*timeStep*0.5f ));
|
||||
btQuaternion dorn (axis.x(),axis.y(),axis.z(),btCos( fAngle*timeStep*btScalar(0.5) ));
|
||||
btQuaternion orn0 = curTrans.getRotation();
|
||||
|
||||
btQuaternion predictedOrn = dorn * orn0;
|
||||
@@ -130,11 +130,11 @@ public:
|
||||
|
||||
angle = dorn.getAngle();
|
||||
axis = btVector3(dorn.x(),dorn.y(),dorn.z());
|
||||
axis[3] = 0.f;
|
||||
axis[3] = btScalar(0.);
|
||||
//check for axis length
|
||||
btScalar len = axis.length2();
|
||||
if (len < SIMD_EPSILON*SIMD_EPSILON)
|
||||
axis = btVector3(1.f,0.f,0.f);
|
||||
axis = btVector3(btScalar(1.),btScalar(0.),btScalar(0.));
|
||||
else
|
||||
axis /= btSqrt(len);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE btVector3(const btScalar& x, const btScalar& y, const btScalar& z)
|
||||
:btQuadWord(x,y,z,0.f)
|
||||
:btQuadWord(x,y,z,btScalar(0.))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public:
|
||||
|
||||
SIMD_FORCE_INLINE void setInterpolate3(const btVector3& v0, const btVector3& v1, btScalar rt)
|
||||
{
|
||||
btScalar s = 1.0f - rt;
|
||||
btScalar s = btScalar(1.0) - rt;
|
||||
m_x = s * v0[0] + rt * v1.x();
|
||||
m_y = s * v0[1] + rt * v1.y();
|
||||
m_z = s * v0[2] + rt * v1.z();
|
||||
@@ -327,13 +327,13 @@ public:
|
||||
|
||||
|
||||
|
||||
float getW() const { return m_unusedW;}
|
||||
btScalar getW() const { return m_unusedW;}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE int maxAxis4() const
|
||||
{
|
||||
int maxIndex = -1;
|
||||
float maxVal = -1e30f;
|
||||
btScalar maxVal = btScalar(-1e30);
|
||||
if (m_x > maxVal)
|
||||
{
|
||||
maxIndex = 0;
|
||||
@@ -366,7 +366,7 @@ public:
|
||||
SIMD_FORCE_INLINE int minAxis4() const
|
||||
{
|
||||
int minIndex = -1;
|
||||
float minVal = 1e30f;
|
||||
btScalar minVal = btScalar(1e30);
|
||||
if (m_x < minVal)
|
||||
{
|
||||
minIndex = 0;
|
||||
|
||||
Reference in New Issue
Block a user