Contribution to add optional double precision floating point support. Define BT_USE_DOUBLE_PRECISION for all involved libraries/apps.
This commit is contained in:
@@ -19,6 +19,7 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/NarrowPhaseCollision/btConvexCast.h"
|
||||
#include "LinearMath/btTransform.h"
|
||||
#include "GL_ShapeDrawer.h"
|
||||
#include "GlutStuff.h"
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
@@ -48,20 +49,20 @@ struct btDebugCastResult : public btConvexCast::CastResult
|
||||
|
||||
virtual void drawCoordSystem(const btTransform& tr)
|
||||
{
|
||||
float m[16];
|
||||
btScalar m[16];
|
||||
tr.getOpenGLMatrix(m);
|
||||
glPushMatrix();
|
||||
glLoadMatrixf(m);
|
||||
btglLoadMatrix(m);
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1, 0, 0);
|
||||
glVertex3d(0, 0, 0);
|
||||
glVertex3d(1, 0, 0);
|
||||
glColor3f(0, 1, 0);
|
||||
glVertex3d(0, 0, 0);
|
||||
glVertex3d(0, 1, 0);
|
||||
glColor3f(0, 0, 1);
|
||||
glVertex3d(0, 0, 0);
|
||||
glVertex3d(0, 0, 1);
|
||||
btglColor3(1, 0, 0);
|
||||
btglVertex3(0, 0, 0);
|
||||
btglVertex3(1, 0, 0);
|
||||
btglColor3(0, 1, 0);
|
||||
btglVertex3(0, 0, 0);
|
||||
btglVertex3(0, 1, 0);
|
||||
btglColor3(0, 0, 1);
|
||||
btglVertex3(0, 0, 0);
|
||||
btglVertex3(0, 0, 1);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
}
|
||||
@@ -69,7 +70,7 @@ struct btDebugCastResult : public btConvexCast::CastResult
|
||||
virtual void DebugDraw(btScalar fraction)
|
||||
{
|
||||
|
||||
float m[16];
|
||||
btScalar m[16];
|
||||
btTransform hitTrans;
|
||||
btTransformUtil::integrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans);
|
||||
hitTrans.getOpenGLMatrix(m);
|
||||
|
||||
@@ -708,7 +708,7 @@ void DemoApplication::renderme()
|
||||
{
|
||||
updateCamera();
|
||||
|
||||
float m[16];
|
||||
btScalar m[16];
|
||||
|
||||
if (m_dynamicsWorld)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ void GLDebugDrawer::setDebugMode(int debugMode)
|
||||
|
||||
}
|
||||
|
||||
void GLDebugDrawer::drawContactPoint(const btVector3& pointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color)
|
||||
void GLDebugDrawer::drawContactPoint(const btVector3& pointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color)
|
||||
{
|
||||
if (m_debugMode & btIDebugDraw::DBG_DrawContactPoints)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
|
||||
virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color);
|
||||
|
||||
virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color);
|
||||
virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color);
|
||||
|
||||
virtual void setDebugMode(int debugMode);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ subject to the following restrictions:
|
||||
#include <GL/glut.h>
|
||||
#endif
|
||||
|
||||
#include "GlutStuff.h"
|
||||
#include "GL_ShapeDrawer.h"
|
||||
#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btTriangleMeshShape.h"
|
||||
@@ -145,8 +146,8 @@ void OGL_displaylist_clean()
|
||||
|
||||
void OGL_displaylist_register_shape(btCollisionShape * shape)
|
||||
{
|
||||
btVector3 aabbMax(1e30f,1e30f,1e30f);
|
||||
btVector3 aabbMin(-1e30f,-1e30f,-1e30f);
|
||||
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
|
||||
GlDisplaylistDrawcallback drawCallback;
|
||||
TRIMESH_KEY dlist;
|
||||
|
||||
@@ -257,12 +258,12 @@ public:
|
||||
};
|
||||
|
||||
|
||||
void GL_ShapeDrawer::drawOpenGL(float* m, const btCollisionShape* shape, const btVector3& color,int debugMode)
|
||||
void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode)
|
||||
{
|
||||
|
||||
|
||||
glPushMatrix();
|
||||
glMultMatrixf(m);
|
||||
btglMultMatrix(m);
|
||||
|
||||
if (shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
|
||||
{
|
||||
@@ -271,7 +272,7 @@ void GL_ShapeDrawer::drawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
{
|
||||
btTransform childTrans = compoundShape->getChildTransform(i);
|
||||
const btCollisionShape* colShape = compoundShape->getChildShape(i);
|
||||
float childMat[16];
|
||||
btScalar childMat[16];
|
||||
childTrans.getOpenGLMatrix(childMat);
|
||||
drawOpenGL(childMat,colShape,color,debugMode);
|
||||
}
|
||||
@@ -471,12 +472,12 @@ void GL_ShapeDrawer::drawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
// if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||
{
|
||||
btConcaveShape* concaveMesh = (btTriangleMeshShape*) shape;
|
||||
//btVector3 aabbMax(1e30f,1e30f,1e30f);
|
||||
//btVector3 aabbMax(100,100,100);//1e30f,1e30f,1e30f);
|
||||
//btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||
//btVector3 aabbMax(100,100,100);//btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||
|
||||
//todo pass camera, for some culling
|
||||
btVector3 aabbMax(1e30f,1e30f,1e30f);
|
||||
btVector3 aabbMin(-1e30f,-1e30f,-1e30f);
|
||||
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
|
||||
|
||||
GlDrawcallback drawCallback;
|
||||
drawCallback.m_wireframe = (debugMode & btIDebugDraw::DBG_DrawWireframe)!=0;
|
||||
@@ -496,8 +497,8 @@ void GL_ShapeDrawer::drawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape;
|
||||
|
||||
//todo: pass camera for some culling
|
||||
btVector3 aabbMax(1e30f,1e30f,1e30f);
|
||||
btVector3 aabbMin(-1e30f,-1e30f,-1e30f);
|
||||
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
|
||||
TriangleGlDrawcallback drawCallback;
|
||||
convexMesh->getStridingMesh()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class GL_ShapeDrawer
|
||||
{
|
||||
public:
|
||||
|
||||
static void drawOpenGL(float* m, const btCollisionShape* shape, const btVector3& color,int debugMode);
|
||||
static void drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode);
|
||||
static void drawCoordSystem();
|
||||
|
||||
};
|
||||
|
||||
@@ -26,6 +26,7 @@ subject to the following restrictions:
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
#include "GlutStuff.h"
|
||||
#include "LinearMath/btTransform.h"
|
||||
|
||||
GL_Simplex1to4::GL_Simplex1to4()
|
||||
@@ -36,7 +37,7 @@ GL_Simplex1to4::GL_Simplex1to4()
|
||||
///
|
||||
/// Debugging method calcClosest calculates the closest point to the origin, using m_simplexSolver
|
||||
///
|
||||
void GL_Simplex1to4::calcClosest(float* m)
|
||||
void GL_Simplex1to4::calcClosest(btScalar* m)
|
||||
{
|
||||
btTransform tr;
|
||||
tr.setFromOpenGLMatrix(m);
|
||||
@@ -62,9 +63,9 @@ void GL_Simplex1to4::calcClosest(float* m)
|
||||
//draw v?
|
||||
glDisable(GL_LIGHTING);
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1.f, 0.f, 0.f);
|
||||
glVertex3f(0.f, 0.f, 0.f);
|
||||
glVertex3f(v.x(),v.y(),v.z());
|
||||
btglColor3(1.f, 0.f, 0.f);
|
||||
btglVertex3(0.f, 0.f, 0.f);
|
||||
btglVertex3(v.x(),v.y(),v.z());
|
||||
glEnd();
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
@@ -29,7 +29,7 @@ class GL_Simplex1to4 : public btBU_Simplex1to4
|
||||
|
||||
GL_Simplex1to4();
|
||||
|
||||
void calcClosest(float* m);
|
||||
void calcClosest(btScalar* m);
|
||||
|
||||
void setSimplexSolver(btSimplexSolverInterface* simplexSolver) {
|
||||
m_simplexSolver = simplexSolver;
|
||||
|
||||
@@ -19,4 +19,16 @@ class DemoApplication;
|
||||
|
||||
int glutmain(int argc, char **argv,int width,int height,const char* title,DemoApplication* demoApp);
|
||||
|
||||
#if defined(BT_USE_DOUBLE_PRECISION)
|
||||
#define btglLoadMatrix glLoadMatrixd
|
||||
#define btglMultMatrix glMultMatrixd
|
||||
#define btglColor3 glColor3d
|
||||
#define btglVertex3 glVertex3d
|
||||
#else
|
||||
#define btglLoadMatrix glLoadMatrixf
|
||||
#define btglMultMatrix glMultMatrixf
|
||||
#define btglColor3 glColor3f
|
||||
#define btglVertex3 glVertex3d
|
||||
#endif
|
||||
|
||||
#endif //GLUT_STUFF_H
|
||||
|
||||
Reference in New Issue
Block a user