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,13 +19,13 @@ subject to the following restrictions:
|
|||||||
//#define CHECK_MEMORY_LEAKS 1
|
//#define CHECK_MEMORY_LEAKS 1
|
||||||
|
|
||||||
int gNumObjects = 120;
|
int gNumObjects = 120;
|
||||||
#define HALF_EXTENTS 1.f
|
#define HALF_EXTENTS btScalar(1.)
|
||||||
#include "btBulletDynamicsCommon.h"
|
#include "btBulletDynamicsCommon.h"
|
||||||
#include "LinearMath/btIDebugDraw.h"
|
#include "LinearMath/btIDebugDraw.h"
|
||||||
#include "GLDebugDrawer.h"
|
#include "GLDebugDrawer.h"
|
||||||
#include <stdio.h> //printf debugging
|
#include <stdio.h> //printf debugging
|
||||||
float deltaTime = 1.f/60.f;
|
btScalar deltaTime = btScalar(1./60.);
|
||||||
float gCollisionMargin = 0.05f;
|
btScalar gCollisionMargin = btScalar(0.05);
|
||||||
#include "BasicDemo.h"
|
#include "BasicDemo.h"
|
||||||
#include "GL_ShapeDrawer.h"
|
#include "GL_ShapeDrawer.h"
|
||||||
#include "GlutStuff.h"
|
#include "GlutStuff.h"
|
||||||
@@ -58,7 +58,7 @@ int main(int argc,char** argv)
|
|||||||
|
|
||||||
BasicDemo ccdDemo;
|
BasicDemo ccdDemo;
|
||||||
ccdDemo.initPhysics();
|
ccdDemo.initPhysics();
|
||||||
ccdDemo.setCameraDistance(50.f);
|
ccdDemo.setCameraDistance(btScalar(50.));
|
||||||
|
|
||||||
#ifdef CHECK_MEMORY_LEAKS
|
#ifdef CHECK_MEMORY_LEAKS
|
||||||
ccdDemo.exitPhysics();
|
ccdDemo.exitPhysics();
|
||||||
@@ -161,9 +161,9 @@ void BasicDemo::initPhysics()
|
|||||||
|
|
||||||
//static ground
|
//static ground
|
||||||
#ifdef USE_GROUND_BOX
|
#ifdef USE_GROUND_BOX
|
||||||
btCollisionShape* groundShape = new btBoxShape(btVector3(50.f,50.f,50.f));
|
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
||||||
#else
|
#else
|
||||||
btCollisionShape* groundShape = new btSphereShape(50.f);
|
btCollisionShape* groundShape = new btSphereShape(btScalar(50.));
|
||||||
#endif//USE_GROUND_BOX
|
#endif//USE_GROUND_BOX
|
||||||
|
|
||||||
m_collisionShapes.push_back(groundShape);
|
m_collisionShapes.push_back(groundShape);
|
||||||
@@ -171,10 +171,10 @@ void BasicDemo::initPhysics()
|
|||||||
btTransform groundTransform;
|
btTransform groundTransform;
|
||||||
groundTransform.setIdentity();
|
groundTransform.setIdentity();
|
||||||
groundTransform.setOrigin(btVector3(0,-50,0));
|
groundTransform.setOrigin(btVector3(0,-50,0));
|
||||||
localCreateRigidBody(0.f,groundTransform,groundShape);
|
localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
|
||||||
|
|
||||||
//create a few dynamic sphere rigidbodies (re-using the same sphere shape)
|
//create a few dynamic sphere rigidbodies (re-using the same sphere shape)
|
||||||
btCollisionShape* sphereShape = new btSphereShape(1.f);
|
btCollisionShape* sphereShape = new btSphereShape(btScalar(1.));
|
||||||
m_collisionShapes.push_back(sphereShape);
|
m_collisionShapes.push_back(sphereShape);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@@ -193,8 +193,8 @@ void BasicDemo::initPhysics()
|
|||||||
row*2*HALF_EXTENTS+HALF_EXTENTS,0);
|
row*2*HALF_EXTENTS+HALF_EXTENTS,0);
|
||||||
|
|
||||||
trans.setOrigin(pos);
|
trans.setOrigin(pos);
|
||||||
//btRigidBody* body = localCreateRigidBody(1.f,trans,sphereShape);
|
//btRigidBody* body = localCreateRigidBody(btScalar(1.),trans,sphereShape);
|
||||||
localCreateRigidBody(1.f,trans,sphereShape);
|
localCreateRigidBody(btScalar(1.),trans,sphereShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
clientResetScene();
|
clientResetScene();
|
||||||
|
|||||||
@@ -21,20 +21,24 @@ subject to the following restrictions:
|
|||||||
void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
|
void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
btVector3 playerStart (0.f, 0.f, 100.f);
|
|
||||||
|
|
||||||
if (bspLoader.findVectorByName(&playerStart[0],"info_player_start"))
|
float playstartf[3] = {0,0,100};
|
||||||
|
|
||||||
|
if (bspLoader.findVectorByName(&playstartf[0],"info_player_start"))
|
||||||
{
|
{
|
||||||
printf("found playerstart\n");
|
printf("found playerstart\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (bspLoader.findVectorByName(&playerStart[0],"info_player_deathmatch"))
|
if (bspLoader.findVectorByName(&playstartf[0],"info_player_deathmatch"))
|
||||||
{
|
{
|
||||||
printf("found deatchmatch start\n");
|
printf("found deatchmatch start\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btVector3 playerStart (playstartf[0],playstartf[1],playstartf[2]);
|
||||||
|
|
||||||
|
|
||||||
playerStart[2] += 20.f; //start a bit higher
|
playerStart[2] += 20.f; //start a bit higher
|
||||||
|
|
||||||
playerStart *= scaling;
|
playerStart *= scaling;
|
||||||
@@ -113,6 +117,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
|
|||||||
if ( strcmp( cl, "" ) ) {
|
if ( strcmp( cl, "" ) ) {
|
||||||
//its not empty so ...
|
//its not empty so ...
|
||||||
|
|
||||||
|
/*
|
||||||
//lookup the target position for the jumppad:
|
//lookup the target position for the jumppad:
|
||||||
const BSPEntity* targetentity = bspLoader.getEntityByValue( "targetname" , cl );
|
const BSPEntity* targetentity = bspLoader.getEntityByValue( "targetname" , cl );
|
||||||
if (targetentity)
|
if (targetentity)
|
||||||
@@ -122,6 +127,8 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
cl = bspLoader.getValueForKey(&entity,"model");
|
cl = bspLoader.getValueForKey(&entity,"model");
|
||||||
if ( strcmp( cl, "" ) ) {
|
if ( strcmp( cl, "" ) ) {
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ void customNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher&
|
|||||||
GLDebugDrawer debugDrawer;
|
GLDebugDrawer debugDrawer;
|
||||||
|
|
||||||
//experimental jitter damping (1 = no damping, 0 = total damping once motion below threshold)
|
//experimental jitter damping (1 = no damping, 0 = total damping once motion below threshold)
|
||||||
extern float gJitterVelocityDampingFactor;
|
extern btScalar gJitterVelocityDampingFactor;
|
||||||
|
|
||||||
int main(int argc,char** argv)
|
int main(int argc,char** argv)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ void CollisionDemo::displayCallback(void) {
|
|||||||
|
|
||||||
//GL_ShapeDrawer::drawCoordSystem();
|
//GL_ShapeDrawer::drawCoordSystem();
|
||||||
|
|
||||||
float m[16];
|
btScalar m[16];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// btGjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,0);
|
// btGjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,0);
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ void CollisionInterfaceDemo::displayCallback(void) {
|
|||||||
|
|
||||||
//GL_ShapeDrawer::drawCoordSystem();
|
//GL_ShapeDrawer::drawCoordSystem();
|
||||||
|
|
||||||
float m[16];
|
btScalar m[16];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ void ConcaveDemo::initPhysics()
|
|||||||
btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles,
|
btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles,
|
||||||
gIndices,
|
gIndices,
|
||||||
indexStride,
|
indexStride,
|
||||||
totalVerts,(float*) &gVertices[0].x(),vertStride);
|
totalVerts,(btScalar*) &gVertices[0].x(),vertStride);
|
||||||
|
|
||||||
btCollisionShape* trimeshShape = new btBvhTriangleMeshShape(indexVertexArrays);
|
btCollisionShape* trimeshShape = new btBvhTriangleMeshShape(indexVertexArrays);
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
|
|||||||
|
|
||||||
//GL_ShapeDrawer::drawCoordSystem();
|
//GL_ShapeDrawer::drawCoordSystem();
|
||||||
|
|
||||||
float m[16];
|
btScalar m[16];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*for (i=0;i<numObjects;i++)
|
/*for (i=0;i<numObjects;i++)
|
||||||
|
|||||||
@@ -70,7 +70,11 @@ static void DrawLine(const btVector3& p0, const btVector3& p1, const btVector3&
|
|||||||
glColor4f(color.x(), color.y(), color.z(), 1.0f);
|
glColor4f(color.x(), color.y(), color.z(), 1.0f);
|
||||||
btVector3 tmp[] = {p0, p1};
|
btVector3 tmp[] = {p0, p1};
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
#ifndef BT_USE_DOUBLE_PRECISION
|
||||||
glVertexPointer(3, GL_FLOAT, sizeof(btVector3), &tmp[0].x());
|
glVertexPointer(3, GL_FLOAT, sizeof(btVector3), &tmp[0].x());
|
||||||
|
#else
|
||||||
|
glVertexPointer(3, GL_DOUBLE, sizeof(btVector3), &tmp[0].x());
|
||||||
|
#endif
|
||||||
glDrawArrays(GL_LINES, 0, 2);
|
glDrawArrays(GL_LINES, 0, 2);
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
@@ -83,7 +87,11 @@ void DrawTriangle(const btVector3& p0, const btVector3& p1, const btVector3& p2,
|
|||||||
glColor4f(color.x(), color.y(), color.z(), 1.0f);
|
glColor4f(color.x(), color.y(), color.z(), 1.0f);
|
||||||
btVector3 tmp[] = {p0, p1, p2};
|
btVector3 tmp[] = {p0, p1, p2};
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
#ifndef BT_USE_DOUBLE_PRECISION
|
||||||
glVertexPointer(3, GL_FLOAT, sizeof(btVector3), &tmp[0].x());
|
glVertexPointer(3, GL_FLOAT, sizeof(btVector3), &tmp[0].x());
|
||||||
|
#else
|
||||||
|
glVertexPointer(3, GL_DOUBLE, sizeof(btVector3), &tmp[0].x());
|
||||||
|
#endif
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
// glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
// glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
@@ -199,10 +207,13 @@ void MyConvex::Render(bool only_wireframe, const btVector3& wire_color) const
|
|||||||
const float Scale = 1.0f;
|
const float Scale = 1.0f;
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
float glmat[16]; //4x4 column major matrix for OpenGL.
|
btScalar glmat[16]; //4x4 column major matrix for OpenGL.
|
||||||
mTransform.getOpenGLMatrix(glmat);
|
mTransform.getOpenGLMatrix(glmat);
|
||||||
|
#ifndef BT_USE_DOUBLE_PRECISION
|
||||||
glMultMatrixf(&(glmat[0]));
|
glMultMatrixf(&(glmat[0]));
|
||||||
|
#else
|
||||||
|
glMultMatrixd(&(glmat[0]));
|
||||||
|
#endif
|
||||||
if(!only_wireframe)
|
if(!only_wireframe)
|
||||||
{
|
{
|
||||||
btVector3 color(0.0f, 0.5f, 1.0f);
|
btVector3 color(0.0f, 0.5f, 1.0f);
|
||||||
@@ -273,7 +284,7 @@ static float gDepth;
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void addContactPoint(const btVector3& normalOnBInWorld, const btVector3& pointInWorld, float depth)
|
virtual void addContactPoint(const btVector3& normalOnBInWorld, const btVector3& pointInWorld, btScalar depth)
|
||||||
{
|
{
|
||||||
gNormal = normalOnBInWorld;
|
gNormal = normalOnBInWorld;
|
||||||
gPoint = pointInWorld;
|
gPoint = pointInWorld;
|
||||||
@@ -293,8 +304,8 @@ static bool TestEPA(const MyConvex& hull0, const MyConvex& hull1)
|
|||||||
|
|
||||||
simplexSolver.reset();
|
simplexSolver.reset();
|
||||||
|
|
||||||
btConvexHullShape convexA((float*)hull0.mVerts, hull0.mNbVerts, sizeof(btVector3));
|
btConvexHullShape convexA((btScalar*)hull0.mVerts, hull0.mNbVerts, sizeof(btVector3));
|
||||||
btConvexHullShape convexB((float*)hull1.mVerts, hull1.mNbVerts, sizeof(btVector3));
|
btConvexHullShape convexB((btScalar*)hull1.mVerts, hull1.mNbVerts, sizeof(btVector3));
|
||||||
|
|
||||||
static btGjkEpaPenetrationDepthSolver Solver0;
|
static btGjkEpaPenetrationDepthSolver Solver0;
|
||||||
static btMinkowskiPenetrationDepthSolver Solver1;
|
static btMinkowskiPenetrationDepthSolver Solver1;
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ void LinearConvexCastDemo::displayCallback(void)
|
|||||||
|
|
||||||
//GL_ShapeDrawer::drawCoordSystem();
|
//GL_ShapeDrawer::drawCoordSystem();
|
||||||
|
|
||||||
float m[16];
|
btScalar m[16];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0;i<numObjects;i++)
|
for (i=0;i<numObjects;i++)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ GLDebugDrawer debugDrawer;
|
|||||||
|
|
||||||
//***************************THE FAMOUS BUNNY TRIMESH********************************************//
|
//***************************THE FAMOUS BUNNY TRIMESH********************************************//
|
||||||
|
|
||||||
#define REAL float
|
#define REAL btScalar
|
||||||
const int NUM_TRIANGLES =902;
|
const int NUM_TRIANGLES =902;
|
||||||
const int NUM_VERTICES = 453;
|
const int NUM_VERTICES = 453;
|
||||||
const int NUM_INDICES = NUM_TRIANGLES * 3;
|
const int NUM_INDICES = NUM_TRIANGLES * 3;
|
||||||
@@ -1487,7 +1487,7 @@ void ConcaveDemo::renderme()
|
|||||||
{
|
{
|
||||||
updateCamera();
|
updateCamera();
|
||||||
|
|
||||||
float m[16];
|
btScalar m[16];
|
||||||
|
|
||||||
if (m_dynamicsWorld)
|
if (m_dynamicsWorld)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ subject to the following restrictions:
|
|||||||
#include "BulletCollision/NarrowPhaseCollision/btConvexCast.h"
|
#include "BulletCollision/NarrowPhaseCollision/btConvexCast.h"
|
||||||
#include "LinearMath/btTransform.h"
|
#include "LinearMath/btTransform.h"
|
||||||
#include "GL_ShapeDrawer.h"
|
#include "GL_ShapeDrawer.h"
|
||||||
|
#include "GlutStuff.h"
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -48,20 +49,20 @@ struct btDebugCastResult : public btConvexCast::CastResult
|
|||||||
|
|
||||||
virtual void drawCoordSystem(const btTransform& tr)
|
virtual void drawCoordSystem(const btTransform& tr)
|
||||||
{
|
{
|
||||||
float m[16];
|
btScalar m[16];
|
||||||
tr.getOpenGLMatrix(m);
|
tr.getOpenGLMatrix(m);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glLoadMatrixf(m);
|
btglLoadMatrix(m);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glColor3f(1, 0, 0);
|
btglColor3(1, 0, 0);
|
||||||
glVertex3d(0, 0, 0);
|
btglVertex3(0, 0, 0);
|
||||||
glVertex3d(1, 0, 0);
|
btglVertex3(1, 0, 0);
|
||||||
glColor3f(0, 1, 0);
|
btglColor3(0, 1, 0);
|
||||||
glVertex3d(0, 0, 0);
|
btglVertex3(0, 0, 0);
|
||||||
glVertex3d(0, 1, 0);
|
btglVertex3(0, 1, 0);
|
||||||
glColor3f(0, 0, 1);
|
btglColor3(0, 0, 1);
|
||||||
glVertex3d(0, 0, 0);
|
btglVertex3(0, 0, 0);
|
||||||
glVertex3d(0, 0, 1);
|
btglVertex3(0, 0, 1);
|
||||||
glEnd();
|
glEnd();
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
@@ -69,7 +70,7 @@ struct btDebugCastResult : public btConvexCast::CastResult
|
|||||||
virtual void DebugDraw(btScalar fraction)
|
virtual void DebugDraw(btScalar fraction)
|
||||||
{
|
{
|
||||||
|
|
||||||
float m[16];
|
btScalar m[16];
|
||||||
btTransform hitTrans;
|
btTransform hitTrans;
|
||||||
btTransformUtil::integrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans);
|
btTransformUtil::integrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans);
|
||||||
hitTrans.getOpenGLMatrix(m);
|
hitTrans.getOpenGLMatrix(m);
|
||||||
|
|||||||
@@ -708,7 +708,7 @@ void DemoApplication::renderme()
|
|||||||
{
|
{
|
||||||
updateCamera();
|
updateCamera();
|
||||||
|
|
||||||
float m[16];
|
btScalar m[16];
|
||||||
|
|
||||||
if (m_dynamicsWorld)
|
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)
|
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 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);
|
virtual void setDebugMode(int debugMode);
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ subject to the following restrictions:
|
|||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "GlutStuff.h"
|
||||||
#include "GL_ShapeDrawer.h"
|
#include "GL_ShapeDrawer.h"
|
||||||
#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
|
#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btTriangleMeshShape.h"
|
#include "BulletCollision/CollisionShapes/btTriangleMeshShape.h"
|
||||||
@@ -145,8 +146,8 @@ void OGL_displaylist_clean()
|
|||||||
|
|
||||||
void OGL_displaylist_register_shape(btCollisionShape * shape)
|
void OGL_displaylist_register_shape(btCollisionShape * shape)
|
||||||
{
|
{
|
||||||
btVector3 aabbMax(1e30f,1e30f,1e30f);
|
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
btVector3 aabbMin(-1e30f,-1e30f,-1e30f);
|
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
|
||||||
GlDisplaylistDrawcallback drawCallback;
|
GlDisplaylistDrawcallback drawCallback;
|
||||||
TRIMESH_KEY dlist;
|
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();
|
glPushMatrix();
|
||||||
glMultMatrixf(m);
|
btglMultMatrix(m);
|
||||||
|
|
||||||
if (shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
|
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);
|
btTransform childTrans = compoundShape->getChildTransform(i);
|
||||||
const btCollisionShape* colShape = compoundShape->getChildShape(i);
|
const btCollisionShape* colShape = compoundShape->getChildShape(i);
|
||||||
float childMat[16];
|
btScalar childMat[16];
|
||||||
childTrans.getOpenGLMatrix(childMat);
|
childTrans.getOpenGLMatrix(childMat);
|
||||||
drawOpenGL(childMat,colShape,color,debugMode);
|
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)
|
// if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||||
{
|
{
|
||||||
btConcaveShape* concaveMesh = (btTriangleMeshShape*) shape;
|
btConcaveShape* concaveMesh = (btTriangleMeshShape*) shape;
|
||||||
//btVector3 aabbMax(1e30f,1e30f,1e30f);
|
//btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
//btVector3 aabbMax(100,100,100);//1e30f,1e30f,1e30f);
|
//btVector3 aabbMax(100,100,100);//btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
|
|
||||||
//todo pass camera, for some culling
|
//todo pass camera, for some culling
|
||||||
btVector3 aabbMax(1e30f,1e30f,1e30f);
|
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
btVector3 aabbMin(-1e30f,-1e30f,-1e30f);
|
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
|
||||||
|
|
||||||
GlDrawcallback drawCallback;
|
GlDrawcallback drawCallback;
|
||||||
drawCallback.m_wireframe = (debugMode & btIDebugDraw::DBG_DrawWireframe)!=0;
|
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;
|
btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape;
|
||||||
|
|
||||||
//todo: pass camera for some culling
|
//todo: pass camera for some culling
|
||||||
btVector3 aabbMax(1e30f,1e30f,1e30f);
|
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
btVector3 aabbMin(-1e30f,-1e30f,-1e30f);
|
btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30));
|
||||||
TriangleGlDrawcallback drawCallback;
|
TriangleGlDrawcallback drawCallback;
|
||||||
convexMesh->getStridingMesh()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
|
convexMesh->getStridingMesh()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class GL_ShapeDrawer
|
|||||||
{
|
{
|
||||||
public:
|
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();
|
static void drawCoordSystem();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ subject to the following restrictions:
|
|||||||
#else
|
#else
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include "GlutStuff.h"
|
||||||
#include "LinearMath/btTransform.h"
|
#include "LinearMath/btTransform.h"
|
||||||
|
|
||||||
GL_Simplex1to4::GL_Simplex1to4()
|
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
|
/// 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;
|
btTransform tr;
|
||||||
tr.setFromOpenGLMatrix(m);
|
tr.setFromOpenGLMatrix(m);
|
||||||
@@ -62,9 +63,9 @@ void GL_Simplex1to4::calcClosest(float* m)
|
|||||||
//draw v?
|
//draw v?
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glColor3f(1.f, 0.f, 0.f);
|
btglColor3(1.f, 0.f, 0.f);
|
||||||
glVertex3f(0.f, 0.f, 0.f);
|
btglVertex3(0.f, 0.f, 0.f);
|
||||||
glVertex3f(v.x(),v.y(),v.z());
|
btglVertex3(v.x(),v.y(),v.z());
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class GL_Simplex1to4 : public btBU_Simplex1to4
|
|||||||
|
|
||||||
GL_Simplex1to4();
|
GL_Simplex1to4();
|
||||||
|
|
||||||
void calcClosest(float* m);
|
void calcClosest(btScalar* m);
|
||||||
|
|
||||||
void setSimplexSolver(btSimplexSolverInterface* simplexSolver) {
|
void setSimplexSolver(btSimplexSolverInterface* simplexSolver) {
|
||||||
m_simplexSolver = 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);
|
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
|
#endif //GLUT_STUFF_H
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ void SimplexDemo::displayCallback()
|
|||||||
|
|
||||||
GL_ShapeDrawer::drawCoordSystem();
|
GL_ShapeDrawer::drawCoordSystem();
|
||||||
|
|
||||||
float m[16];
|
btScalar m[16];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=0;i<numObjects;i++)
|
for (i=0;i<numObjects;i++)
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ const float TRIANGLE_SIZE=20.f;
|
|||||||
btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles,
|
btTriangleIndexVertexArray* indexVertexArrays = new btTriangleIndexVertexArray(totalTriangles,
|
||||||
gIndices,
|
gIndices,
|
||||||
indexStride,
|
indexStride,
|
||||||
totalVerts,(float*) &gVertices[0].x(),vertStride);
|
totalVerts,(btScalar*) &gVertices[0].x(),vertStride);
|
||||||
|
|
||||||
groundShape = new btBvhTriangleMeshShape(indexVertexArrays);
|
groundShape = new btBvhTriangleMeshShape(indexVertexArrays);
|
||||||
|
|
||||||
@@ -297,7 +297,7 @@ void VehicleDemo::renderme()
|
|||||||
updateCamera();
|
updateCamera();
|
||||||
|
|
||||||
debugDrawer.setDebugMode(getDebugMode());
|
debugDrawer.setDebugMode(getDebugMode());
|
||||||
float m[16];
|
btScalar m[16];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
btCylinderShapeX wheelShape(btVector3(wheelWidth,wheelRadius,wheelRadius));
|
btCylinderShapeX wheelShape(btVector3(wheelWidth,wheelRadius,wheelRadius));
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ void BoxBoxCollisionAlgorithm::processCollision (btCollisionObject* body0,btColl
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float BoxBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
btScalar BoxBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||||
{
|
{
|
||||||
//not yet
|
//not yet
|
||||||
return 1.f;
|
return 1.f;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public:
|
|||||||
|
|
||||||
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
virtual float calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
BoxBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
|
BoxBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
|
||||||
|
|
||||||
|
|||||||
@@ -471,7 +471,7 @@ void btConcaveConcaveCollisionAlgorithm::processCollision (btCollisionObject* bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float btConcaveConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
btScalar btConcaveConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||||
{
|
{
|
||||||
return 1.f;
|
return 1.f;
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
float calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
void clearCache();
|
void clearCache();
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ m_erp(0.4f)
|
|||||||
|
|
||||||
|
|
||||||
//iterative lcp and penalty method
|
//iterative lcp and penalty method
|
||||||
float OdeConstraintSolver::solveGroup(btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer)
|
btScalar OdeConstraintSolver::solveGroup(btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer)
|
||||||
{
|
{
|
||||||
m_CurBody = 0;
|
m_CurBody = 0;
|
||||||
m_CurJoint = 0;
|
m_CurJoint = 0;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
|
|
||||||
virtual ~OdeConstraintSolver() {}
|
virtual ~OdeConstraintSolver() {}
|
||||||
|
|
||||||
virtual float solveGroup(btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info,btIDebugDraw* debugDrawer = 0);
|
virtual btScalar solveGroup(btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info,btIDebugDraw* debugDrawer = 0);
|
||||||
|
|
||||||
///setConstraintForceMixing, the cfm adds some positive value to the main diagonal
|
///setConstraintForceMixing, the cfm adds some positive value to the main diagonal
|
||||||
///This can improve convergence (make matrix positive semidefinite), but it can make the simulation look more 'springy'
|
///This can improve convergence (make matrix positive semidefinite), but it can make the simulation look more 'springy'
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ btAxisSweep3::btAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAab
|
|||||||
|
|
||||||
btVector3 aabbSize = m_worldAabbMax - m_worldAabbMin;
|
btVector3 aabbSize = m_worldAabbMax - m_worldAabbMin;
|
||||||
|
|
||||||
m_quantize = btVector3(65535.0f,65535.0f,65535.0f) / aabbSize;
|
m_quantize = btVector3(btScalar(65535.0),btScalar(65535.0),btScalar(65535.0)) / aabbSize;
|
||||||
|
|
||||||
// allocate handles buffer and put all handles on free list
|
// allocate handles buffer and put all handles on free list
|
||||||
m_pHandles = new Handle[maxHandles];
|
m_pHandles = new Handle[maxHandles];
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ subject to the following restrictions:
|
|||||||
#ifndef COLLISION_ALGORITHM_H
|
#ifndef COLLISION_ALGORITHM_H
|
||||||
#define COLLISION_ALGORITHM_H
|
#define COLLISION_ALGORITHM_H
|
||||||
|
|
||||||
|
#include "LinearMath/btScalar.h"
|
||||||
|
|
||||||
struct btBroadphaseProxy;
|
struct btBroadphaseProxy;
|
||||||
class btDispatcher;
|
class btDispatcher;
|
||||||
class btManifoldResult;
|
class btManifoldResult;
|
||||||
@@ -66,7 +68,7 @@ public:
|
|||||||
|
|
||||||
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0;
|
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0;
|
||||||
|
|
||||||
virtual float calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0;
|
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ subject to the following restrictions:
|
|||||||
#ifndef _DISPATCHER_H
|
#ifndef _DISPATCHER_H
|
||||||
#define _DISPATCHER_H
|
#define _DISPATCHER_H
|
||||||
|
|
||||||
|
#include "LinearMath/btScalar.h"
|
||||||
|
|
||||||
class btCollisionAlgorithm;
|
class btCollisionAlgorithm;
|
||||||
struct btBroadphaseProxy;
|
struct btBroadphaseProxy;
|
||||||
class btRigidBody;
|
class btRigidBody;
|
||||||
@@ -34,10 +36,10 @@ struct btDispatcherInfo
|
|||||||
DISPATCH_CONTINUOUS
|
DISPATCH_CONTINUOUS
|
||||||
};
|
};
|
||||||
btDispatcherInfo()
|
btDispatcherInfo()
|
||||||
:m_timeStep(0.f),
|
:m_timeStep(btScalar(0.)),
|
||||||
m_stepCount(0),
|
m_stepCount(0),
|
||||||
m_dispatchFunc(DISPATCH_DISCRETE),
|
m_dispatchFunc(DISPATCH_DISCRETE),
|
||||||
m_timeOfImpact(1.f),
|
m_timeOfImpact(btScalar(1.)),
|
||||||
m_useContinuous(false),
|
m_useContinuous(false),
|
||||||
m_debugDraw(0),
|
m_debugDraw(0),
|
||||||
m_enableSatConvex(false),
|
m_enableSatConvex(false),
|
||||||
@@ -46,10 +48,10 @@ struct btDispatcherInfo
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
float m_timeStep;
|
btScalar m_timeStep;
|
||||||
int m_stepCount;
|
int m_stepCount;
|
||||||
int m_dispatchFunc;
|
int m_dispatchFunc;
|
||||||
float m_timeOfImpact;
|
btScalar m_timeOfImpact;
|
||||||
bool m_useContinuous;
|
bool m_useContinuous;
|
||||||
class btIDebugDraw* m_debugDraw;
|
class btIDebugDraw* m_debugDraw;
|
||||||
bool m_enableSatConvex;
|
bool m_enableSatConvex;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ subject to the following restrictions:
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "LinearMath/btScalar.h"
|
||||||
#include "SphereTriangleDetector.h"
|
#include "SphereTriangleDetector.h"
|
||||||
#include "BulletCollision/CollisionShapes/btTriangleShape.h"
|
#include "BulletCollision/CollisionShapes/btTriangleShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
||||||
@@ -32,9 +33,9 @@ void SphereTriangleDetector::getClosestPoints(const ClosestPointInput& input,Res
|
|||||||
const btTransform& transformB = input.m_transformB;
|
const btTransform& transformB = input.m_transformB;
|
||||||
|
|
||||||
btVector3 point,normal;
|
btVector3 point,normal;
|
||||||
btScalar timeOfImpact = 1.f;
|
btScalar timeOfImpact = btScalar(1.);
|
||||||
btScalar depth = 0.f;
|
btScalar depth = btScalar(0.);
|
||||||
// output.m_distance = 1e30f;
|
// output.m_distance = btScalar(1e30);
|
||||||
//move sphere into triangle space
|
//move sphere into triangle space
|
||||||
btTransform sphereInTr = transformB.inverseTimes(transformA);
|
btTransform sphereInTr = transformB.inverseTimes(transformA);
|
||||||
|
|
||||||
@@ -45,19 +46,19 @@ void SphereTriangleDetector::getClosestPoints(const ClosestPointInput& input,Res
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_OVERLAP 0.f
|
#define MAX_OVERLAP btScalar(0.)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// See also geometrictools.com
|
// See also geometrictools.com
|
||||||
// Basic idea: D = |p - (lo + t0*lv)| where t0 = lv . (p - lo) / lv . lv
|
// Basic idea: D = |p - (lo + t0*lv)| where t0 = lv . (p - lo) / lv . lv
|
||||||
float SegmentSqrDistance(const btVector3& from, const btVector3& to,const btVector3 &p, btVector3 &nearest) {
|
btScalar SegmentSqrDistance(const btVector3& from, const btVector3& to,const btVector3 &p, btVector3 &nearest) {
|
||||||
btVector3 diff = p - from;
|
btVector3 diff = p - from;
|
||||||
btVector3 v = to - from;
|
btVector3 v = to - from;
|
||||||
float t = v.dot(diff);
|
btScalar t = v.dot(diff);
|
||||||
|
|
||||||
if (t > 0) {
|
if (t > 0) {
|
||||||
float dotVV = v.dot(v);
|
btScalar dotVV = v.dot(v);
|
||||||
if (t < dotVV) {
|
if (t < dotVV) {
|
||||||
t /= dotVV;
|
t /= dotVV;
|
||||||
diff -= t*v;
|
diff -= t*v;
|
||||||
@@ -80,7 +81,7 @@ bool SphereTriangleDetector::facecontains(const btVector3 &p,const btVector3* ve
|
|||||||
}
|
}
|
||||||
|
|
||||||
///combined discrete/continuous sphere-triangle
|
///combined discrete/continuous sphere-triangle
|
||||||
bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, float &timeOfImpact)
|
bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact)
|
||||||
{
|
{
|
||||||
|
|
||||||
const btVector3* vertices = &m_triangle->getVertexPtr(0);
|
const btVector3* vertices = &m_triangle->getVertexPtr(0);
|
||||||
@@ -92,25 +93,25 @@ bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &po
|
|||||||
btVector3 normal = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]);
|
btVector3 normal = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]);
|
||||||
normal.normalize();
|
normal.normalize();
|
||||||
btVector3 p1ToCentre = c - vertices[0];
|
btVector3 p1ToCentre = c - vertices[0];
|
||||||
float distanceFromPlane = p1ToCentre.dot(normal);
|
btScalar distanceFromPlane = p1ToCentre.dot(normal);
|
||||||
|
|
||||||
if (distanceFromPlane < 0.f)
|
if (distanceFromPlane < btScalar(0.))
|
||||||
{
|
{
|
||||||
//triangle facing the other way
|
//triangle facing the other way
|
||||||
|
|
||||||
distanceFromPlane *= -1.f;
|
distanceFromPlane *= btScalar(-1.);
|
||||||
normal *= -1.f;
|
normal *= btScalar(-1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
///todo: move this gContactBreakingThreshold into a proper structure
|
///todo: move this gContactBreakingThreshold into a proper structure
|
||||||
extern float gContactBreakingThreshold;
|
extern btScalar gContactBreakingThreshold;
|
||||||
|
|
||||||
float contactMargin = gContactBreakingThreshold;
|
btScalar contactMargin = gContactBreakingThreshold;
|
||||||
bool isInsideContactPlane = distanceFromPlane < r + contactMargin;
|
bool isInsideContactPlane = distanceFromPlane < r + contactMargin;
|
||||||
bool isInsideShellPlane = distanceFromPlane < r;
|
bool isInsideShellPlane = distanceFromPlane < r;
|
||||||
|
|
||||||
float deltaDotNormal = delta.dot(normal);
|
btScalar deltaDotNormal = delta.dot(normal);
|
||||||
if (!isInsideShellPlane && deltaDotNormal >= 0.0f)
|
if (!isInsideShellPlane && deltaDotNormal >= btScalar(0.0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check for contact / intersection
|
// Check for contact / intersection
|
||||||
@@ -123,7 +124,7 @@ bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &po
|
|||||||
contactPoint = c - normal*distanceFromPlane;
|
contactPoint = c - normal*distanceFromPlane;
|
||||||
} else {
|
} else {
|
||||||
// Could be inside one of the contact capsules
|
// Could be inside one of the contact capsules
|
||||||
float contactCapsuleRadiusSqr = (r + contactMargin) * (r + contactMargin);
|
btScalar contactCapsuleRadiusSqr = (r + contactMargin) * (r + contactMargin);
|
||||||
btVector3 nearestOnEdge;
|
btVector3 nearestOnEdge;
|
||||||
for (int i = 0; i < m_triangle->getNumEdges(); i++) {
|
for (int i = 0; i < m_triangle->getNumEdges(); i++) {
|
||||||
|
|
||||||
@@ -132,7 +133,7 @@ bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &po
|
|||||||
|
|
||||||
m_triangle->getEdge(i,pa,pb);
|
m_triangle->getEdge(i,pa,pb);
|
||||||
|
|
||||||
float distanceSqr = SegmentSqrDistance(pa,pb,c, nearestOnEdge);
|
btScalar distanceSqr = SegmentSqrDistance(pa,pb,c, nearestOnEdge);
|
||||||
if (distanceSqr < contactCapsuleRadiusSqr) {
|
if (distanceSqr < contactCapsuleRadiusSqr) {
|
||||||
// Yep, we're inside a capsule
|
// Yep, we're inside a capsule
|
||||||
hasContact = true;
|
hasContact = true;
|
||||||
@@ -145,9 +146,9 @@ bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &po
|
|||||||
|
|
||||||
if (hasContact) {
|
if (hasContact) {
|
||||||
btVector3 contactToCentre = c - contactPoint;
|
btVector3 contactToCentre = c - contactPoint;
|
||||||
float distanceSqr = contactToCentre.length2();
|
btScalar distanceSqr = contactToCentre.length2();
|
||||||
if (distanceSqr < (r - MAX_OVERLAP)*(r - MAX_OVERLAP)) {
|
if (distanceSqr < (r - MAX_OVERLAP)*(r - MAX_OVERLAP)) {
|
||||||
float distance = sqrtf(distanceSqr);
|
btScalar distance = btSqrt(distanceSqr);
|
||||||
if (1)
|
if (1)
|
||||||
{
|
{
|
||||||
resultNormal = contactToCentre;
|
resultNormal = contactToCentre;
|
||||||
@@ -158,12 +159,12 @@ bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &po
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delta.dot(contactToCentre) >= 0.0f)
|
if (delta.dot(contactToCentre) >= btScalar(0.0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Moving towards the contact point -> collision
|
// Moving towards the contact point -> collision
|
||||||
point = contactPoint;
|
point = contactPoint;
|
||||||
timeOfImpact = 0.0f;
|
timeOfImpact = btScalar(0.0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +190,7 @@ bool SphereTriangleDetector::pointInTriangle(const btVector3 vertices[], const b
|
|||||||
btVector3 edge2_normal( edge2.cross(normal));
|
btVector3 edge2_normal( edge2.cross(normal));
|
||||||
btVector3 edge3_normal( edge3.cross(normal));
|
btVector3 edge3_normal( edge3.cross(normal));
|
||||||
|
|
||||||
float r1, r2, r3;
|
btScalar r1, r2, r3;
|
||||||
r1 = edge1_normal.dot( p1_to_p );
|
r1 = edge1_normal.dot( p1_to_p );
|
||||||
r2 = edge2_normal.dot( p2_to_p );
|
r2 = edge2_normal.dot( p2_to_p );
|
||||||
r3 = edge3_normal.dot( p3_to_p );
|
r3 = edge3_normal.dot( p3_to_p );
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ struct SphereTriangleDetector : public btDiscreteCollisionDetectorInterface
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, float &timeOfImpact);
|
bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact);
|
||||||
bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p );
|
bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p );
|
||||||
bool facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal);
|
bool facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal);
|
||||||
|
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ void btCollisionDispatcher::defaultNearCallback(btBroadphasePair& collisionPair,
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
//continuous collision detection query, time of impact (toi)
|
//continuous collision detection query, time of impact (toi)
|
||||||
float toi = collisionPair.m_algorithm->calculateTimeOfImpact(colObj0,colObj1,dispatchInfo,&contactPointResult);
|
btScalar toi = collisionPair.m_algorithm->calculateTimeOfImpact(colObj0,colObj1,dispatchInfo,&contactPointResult);
|
||||||
if (dispatchInfo.m_timeOfImpact > toi)
|
if (dispatchInfo.m_timeOfImpact > toi)
|
||||||
dispatchInfo.m_timeOfImpact = toi;
|
dispatchInfo.m_timeOfImpact = toi;
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ btCollisionObject::btCollisionObject()
|
|||||||
m_collisionShape(0),
|
m_collisionShape(0),
|
||||||
m_collisionFlags(0),
|
m_collisionFlags(0),
|
||||||
m_activationState1(1),
|
m_activationState1(1),
|
||||||
m_deactivationTime(0.f),
|
m_deactivationTime(btScalar(0.)),
|
||||||
m_userObjectPointer(0),
|
m_userObjectPointer(0),
|
||||||
m_hitFraction(1.f),
|
m_hitFraction(btScalar(1.)),
|
||||||
m_ccdSweptSphereRadius(0.f),
|
m_ccdSweptSphereRadius(btScalar(0.)),
|
||||||
m_ccdSquareMotionThreshold(0.f)
|
m_ccdSquareMotionThreshold(btScalar(0.))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ void btCollisionObject::activate(bool forceActivation)
|
|||||||
if (forceActivation || !(m_collisionFlags & (CF_STATIC_OBJECT|CF_KINEMATIC_OBJECT)))
|
if (forceActivation || !(m_collisionFlags & (CF_STATIC_OBJECT|CF_KINEMATIC_OBJECT)))
|
||||||
{
|
{
|
||||||
setActivationState(ACTIVE_TAG);
|
setActivationState(ACTIVE_TAG);
|
||||||
m_deactivationTime = 0.f;
|
m_deactivationTime = btScalar(0.);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ protected:
|
|||||||
|
|
||||||
int m_islandTag1;
|
int m_islandTag1;
|
||||||
int m_activationState1;
|
int m_activationState1;
|
||||||
float m_deactivationTime;
|
btScalar m_deactivationTime;
|
||||||
|
|
||||||
btScalar m_friction;
|
btScalar m_friction;
|
||||||
btScalar m_restitution;
|
btScalar m_restitution;
|
||||||
@@ -67,13 +67,13 @@ protected:
|
|||||||
void* m_internalOwner;
|
void* m_internalOwner;
|
||||||
|
|
||||||
///time of impact calculation
|
///time of impact calculation
|
||||||
float m_hitFraction;
|
btScalar m_hitFraction;
|
||||||
|
|
||||||
///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
|
///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
|
||||||
float m_ccdSweptSphereRadius;
|
btScalar m_ccdSweptSphereRadius;
|
||||||
|
|
||||||
/// Don't do continuous collision detection if square motion (in one step) is less then m_ccdSquareMotionThreshold
|
/// Don't do continuous collision detection if square motion (in one step) is less then m_ccdSquareMotionThreshold
|
||||||
float m_ccdSquareMotionThreshold;
|
btScalar m_ccdSquareMotionThreshold;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -137,11 +137,11 @@ public:
|
|||||||
|
|
||||||
void setActivationState(int newState);
|
void setActivationState(int newState);
|
||||||
|
|
||||||
void setDeactivationTime(float time)
|
void setDeactivationTime(btScalar time)
|
||||||
{
|
{
|
||||||
m_deactivationTime = time;
|
m_deactivationTime = time;
|
||||||
}
|
}
|
||||||
float getDeactivationTime() const
|
btScalar getDeactivationTime() const
|
||||||
{
|
{
|
||||||
return m_deactivationTime;
|
return m_deactivationTime;
|
||||||
}
|
}
|
||||||
@@ -155,19 +155,19 @@ public:
|
|||||||
return ((getActivationState() != ISLAND_SLEEPING) && (getActivationState() != DISABLE_SIMULATION));
|
return ((getActivationState() != ISLAND_SLEEPING) && (getActivationState() != DISABLE_SIMULATION));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRestitution(float rest)
|
void setRestitution(btScalar rest)
|
||||||
{
|
{
|
||||||
m_restitution = rest;
|
m_restitution = rest;
|
||||||
}
|
}
|
||||||
float getRestitution() const
|
btScalar getRestitution() const
|
||||||
{
|
{
|
||||||
return m_restitution;
|
return m_restitution;
|
||||||
}
|
}
|
||||||
void setFriction(float frict)
|
void setFriction(btScalar frict)
|
||||||
{
|
{
|
||||||
m_friction = frict;
|
m_friction = frict;
|
||||||
}
|
}
|
||||||
float getFriction() const
|
btScalar getFriction() const
|
||||||
{
|
{
|
||||||
return m_friction;
|
return m_friction;
|
||||||
}
|
}
|
||||||
@@ -251,12 +251,12 @@ public:
|
|||||||
m_islandTag1 = tag;
|
m_islandTag1 = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float getHitFraction() const
|
const btScalar getHitFraction() const
|
||||||
{
|
{
|
||||||
return m_hitFraction;
|
return m_hitFraction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setHitFraction(float hitFraction)
|
void setHitFraction(btScalar hitFraction)
|
||||||
{
|
{
|
||||||
m_hitFraction = hitFraction;
|
m_hitFraction = hitFraction;
|
||||||
}
|
}
|
||||||
@@ -273,25 +273,25 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
|
///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
|
||||||
float getCcdSweptSphereRadius() const
|
btScalar getCcdSweptSphereRadius() const
|
||||||
{
|
{
|
||||||
return m_ccdSweptSphereRadius;
|
return m_ccdSweptSphereRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
|
///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
|
||||||
void setCcdSweptSphereRadius(float radius)
|
void setCcdSweptSphereRadius(btScalar radius)
|
||||||
{
|
{
|
||||||
m_ccdSweptSphereRadius = radius;
|
m_ccdSweptSphereRadius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getCcdSquareMotionThreshold() const
|
btScalar getCcdSquareMotionThreshold() const
|
||||||
{
|
{
|
||||||
return m_ccdSquareMotionThreshold;
|
return m_ccdSquareMotionThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Don't do continuous collision detection if square motion (in one step) is less then m_ccdSquareMotionThreshold
|
/// Don't do continuous collision detection if square motion (in one step) is less then m_ccdSquareMotionThreshold
|
||||||
void setCcdSquareMotionThreshold(float ccdSquareMotionThreshold)
|
void setCcdSquareMotionThreshold(btScalar ccdSquareMotionThreshold)
|
||||||
{
|
{
|
||||||
m_ccdSquareMotionThreshold = ccdSquareMotionThreshold;
|
m_ccdSquareMotionThreshold = ccdSquareMotionThreshold;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,12 +185,12 @@ void btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
|
|||||||
RayResultCallback& resultCallback)
|
RayResultCallback& resultCallback)
|
||||||
{
|
{
|
||||||
|
|
||||||
btSphereShape pointShape(0.0f);
|
btSphereShape pointShape(btScalar(0.0));
|
||||||
|
|
||||||
if (collisionShape->isConvex())
|
if (collisionShape->isConvex())
|
||||||
{
|
{
|
||||||
btConvexCast::CastResult castResult;
|
btConvexCast::CastResult castResult;
|
||||||
castResult.m_fraction = 1.f;//??
|
castResult.m_fraction = btScalar(1.);//??
|
||||||
|
|
||||||
btConvexShape* convexShape = (btConvexShape*) collisionShape;
|
btConvexShape* convexShape = (btConvexShape*) collisionShape;
|
||||||
btVoronoiSimplexSolver simplexSolver;
|
btVoronoiSimplexSolver simplexSolver;
|
||||||
@@ -201,7 +201,7 @@ void btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
|
|||||||
if (convexCaster.calcTimeOfImpact(rayFromTrans,rayToTrans,colObjWorldTransform,colObjWorldTransform,castResult))
|
if (convexCaster.calcTimeOfImpact(rayFromTrans,rayToTrans,colObjWorldTransform,colObjWorldTransform,castResult))
|
||||||
{
|
{
|
||||||
//add hit
|
//add hit
|
||||||
if (castResult.m_normal.length2() > 0.0001f)
|
if (castResult.m_normal.length2() > btScalar(0.0001))
|
||||||
{
|
{
|
||||||
castResult.m_normal.normalize();
|
castResult.m_normal.normalize();
|
||||||
if (castResult.m_fraction < resultCallback.m_closestHitFraction)
|
if (castResult.m_fraction < resultCallback.m_closestHitFraction)
|
||||||
@@ -252,7 +252,7 @@ void btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual float reportHit(const btVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex )
|
virtual btScalar reportHit(const btVector3& hitNormalLocal, btScalar hitFraction, int partId, int triangleIndex )
|
||||||
{
|
{
|
||||||
btCollisionWorld::LocalShapeInfo shapeInfo;
|
btCollisionWorld::LocalShapeInfo shapeInfo;
|
||||||
shapeInfo.m_shapePart = partId;
|
shapeInfo.m_shapePart = partId;
|
||||||
@@ -333,7 +333,7 @@ void btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& r
|
|||||||
btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
|
btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
|
||||||
collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax);
|
collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax);
|
||||||
|
|
||||||
float hitLambda = 1.f; //could use resultCallback.m_closestHitFraction, but needs testing
|
btScalar hitLambda = btScalar(1.); //could use resultCallback.m_closestHitFraction, but needs testing
|
||||||
btVector3 hitNormal;
|
btVector3 hitNormal;
|
||||||
if (btRayAabb(rayFromWorld,rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,hitNormal))
|
if (btRayAabb(rayFromWorld,rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,hitNormal))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ public:
|
|||||||
LocalRayResult(btCollisionObject* collisionObject,
|
LocalRayResult(btCollisionObject* collisionObject,
|
||||||
LocalShapeInfo* localShapeInfo,
|
LocalShapeInfo* localShapeInfo,
|
||||||
const btVector3& hitNormalLocal,
|
const btVector3& hitNormalLocal,
|
||||||
float hitFraction)
|
btScalar hitFraction)
|
||||||
:m_collisionObject(collisionObject),
|
:m_collisionObject(collisionObject),
|
||||||
m_localShapeInfo(m_localShapeInfo),
|
m_localShapeInfo(m_localShapeInfo),
|
||||||
m_hitNormalLocal(hitNormalLocal),
|
m_hitNormalLocal(hitNormalLocal),
|
||||||
@@ -148,7 +148,7 @@ public:
|
|||||||
btCollisionObject* m_collisionObject;
|
btCollisionObject* m_collisionObject;
|
||||||
LocalShapeInfo* m_localShapeInfo;
|
LocalShapeInfo* m_localShapeInfo;
|
||||||
const btVector3& m_hitNormalLocal;
|
const btVector3& m_hitNormalLocal;
|
||||||
float m_hitFraction;
|
btScalar m_hitFraction;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -158,17 +158,17 @@ public:
|
|||||||
virtual ~RayResultCallback()
|
virtual ~RayResultCallback()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
float m_closestHitFraction;
|
btScalar m_closestHitFraction;
|
||||||
bool HasHit()
|
bool HasHit()
|
||||||
{
|
{
|
||||||
return (m_closestHitFraction < 1.f);
|
return (m_closestHitFraction < btScalar(1.));
|
||||||
}
|
}
|
||||||
|
|
||||||
RayResultCallback()
|
RayResultCallback()
|
||||||
:m_closestHitFraction(1.f)
|
:m_closestHitFraction(btScalar(1.))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual float AddSingleResult(LocalRayResult& rayResult) = 0;
|
virtual btScalar AddSingleResult(LocalRayResult& rayResult) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ClosestRayResultCallback : public RayResultCallback
|
struct ClosestRayResultCallback : public RayResultCallback
|
||||||
@@ -187,7 +187,7 @@ public:
|
|||||||
btVector3 m_hitPointWorld;
|
btVector3 m_hitPointWorld;
|
||||||
btCollisionObject* m_collisionObject;
|
btCollisionObject* m_collisionObject;
|
||||||
|
|
||||||
virtual float AddSingleResult(LocalRayResult& rayResult)
|
virtual btScalar AddSingleResult(LocalRayResult& rayResult)
|
||||||
{
|
{
|
||||||
|
|
||||||
//caller already does the filter on the m_closestHitFraction
|
//caller already does the filter on the m_closestHitFraction
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ void btCompoundCollisionAlgorithm::processCollision (btCollisionObject* body0,bt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float btCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
btScalar btCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||||
{
|
{
|
||||||
|
|
||||||
btCollisionObject* colObj = m_isSwapped? body1 : body0;
|
btCollisionObject* colObj = m_isSwapped? body1 : body0;
|
||||||
@@ -106,7 +106,7 @@ float btCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* bod
|
|||||||
//then use each overlapping node AABB against Tree0
|
//then use each overlapping node AABB against Tree0
|
||||||
//and vise versa.
|
//and vise versa.
|
||||||
|
|
||||||
float hitFraction = 1.f;
|
btScalar hitFraction = btScalar(1.);
|
||||||
|
|
||||||
int numChildren = m_childCollisionAlgorithms.size();
|
int numChildren = m_childCollisionAlgorithms.size();
|
||||||
int i;
|
int i;
|
||||||
@@ -124,7 +124,7 @@ float btCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* bod
|
|||||||
colObj->setWorldTransform( newChildWorldTrans );
|
colObj->setWorldTransform( newChildWorldTrans );
|
||||||
|
|
||||||
colObj->setCollisionShape( childShape );
|
colObj->setCollisionShape( childShape );
|
||||||
float frac = m_childCollisionAlgorithms[i]->calculateTimeOfImpact(colObj,otherObj,dispatchInfo,resultOut);
|
btScalar frac = m_childCollisionAlgorithms[i]->calculateTimeOfImpact(colObj,otherObj,dispatchInfo,resultOut);
|
||||||
if (frac<hitFraction)
|
if (frac<hitFraction)
|
||||||
{
|
{
|
||||||
hitFraction = frac;
|
hitFraction = frac;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
float calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, i
|
|||||||
m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(triangle[0]),color);
|
m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(triangle[0]),color);
|
||||||
|
|
||||||
//btVector3 center = triangle[0] + triangle[1]+triangle[2];
|
//btVector3 center = triangle[0] + triangle[1]+triangle[2];
|
||||||
//center *= 0.333333f;
|
//center *= btScalar(0.333333);
|
||||||
//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(center),color);
|
//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(center),color);
|
||||||
//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(center),color);
|
//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(center),color);
|
||||||
//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(center),color);
|
//m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(center),color);
|
||||||
@@ -134,7 +134,7 @@ void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, i
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void btConvexTriangleCallback::setTimeStepAndCounters(float collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
void btConvexTriangleCallback::setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||||
{
|
{
|
||||||
m_dispatchInfoPtr = &dispatchInfo;
|
m_dispatchInfoPtr = &dispatchInfo;
|
||||||
m_collisionMarginTriangle = collisionMarginTriangle;
|
m_collisionMarginTriangle = collisionMarginTriangle;
|
||||||
@@ -146,7 +146,7 @@ void btConvexTriangleCallback::setTimeStepAndCounters(float collisionMarginTrian
|
|||||||
btCollisionShape* convexShape = static_cast<btCollisionShape*>(m_convexBody->getCollisionShape());
|
btCollisionShape* convexShape = static_cast<btCollisionShape*>(m_convexBody->getCollisionShape());
|
||||||
//CollisionShape* triangleShape = static_cast<btCollisionShape*>(triBody->m_collisionShape);
|
//CollisionShape* triangleShape = static_cast<btCollisionShape*>(triBody->m_collisionShape);
|
||||||
convexShape->getAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax);
|
convexShape->getAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax);
|
||||||
float extraMargin = collisionMarginTriangle;
|
btScalar extraMargin = collisionMarginTriangle;
|
||||||
btVector3 extra(extraMargin,extraMargin,extraMargin);
|
btVector3 extra(extraMargin,extraMargin,extraMargin);
|
||||||
|
|
||||||
m_aabbMax += extra;
|
m_aabbMax += extra;
|
||||||
@@ -176,7 +176,7 @@ void btConvexConcaveCollisionAlgorithm::processCollision (btCollisionObject* bod
|
|||||||
|
|
||||||
if (convexBody->getCollisionShape()->isConvex())
|
if (convexBody->getCollisionShape()->isConvex())
|
||||||
{
|
{
|
||||||
float collisionMarginTriangle = concaveShape->getMargin();
|
btScalar collisionMarginTriangle = concaveShape->getMargin();
|
||||||
|
|
||||||
resultOut->setPersistentManifold(m_btConvexTriangleCallback.m_manifoldPtr);
|
resultOut->setPersistentManifold(m_btConvexTriangleCallback.m_manifoldPtr);
|
||||||
m_btConvexTriangleCallback.setTimeStepAndCounters(collisionMarginTriangle,dispatchInfo,resultOut);
|
m_btConvexTriangleCallback.setTimeStepAndCounters(collisionMarginTriangle,dispatchInfo,resultOut);
|
||||||
@@ -196,7 +196,7 @@ void btConvexConcaveCollisionAlgorithm::processCollision (btCollisionObject* bod
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float btConvexConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
btScalar btConvexConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||||
{
|
{
|
||||||
|
|
||||||
btCollisionObject* convexbody = m_isSwapped ? body1 : body0;
|
btCollisionObject* convexbody = m_isSwapped ? body1 : body0;
|
||||||
@@ -207,10 +207,10 @@ float btConvexConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject
|
|||||||
|
|
||||||
//only perform CCD above a certain threshold, this prevents blocking on the long run
|
//only perform CCD above a certain threshold, this prevents blocking on the long run
|
||||||
//because object in a blocked ccd state (hitfraction<1) get their linear velocity halved each frame...
|
//because object in a blocked ccd state (hitfraction<1) get their linear velocity halved each frame...
|
||||||
float squareMot0 = (convexbody->getInterpolationWorldTransform().getOrigin() - convexbody->getWorldTransform().getOrigin()).length2();
|
btScalar squareMot0 = (convexbody->getInterpolationWorldTransform().getOrigin() - convexbody->getWorldTransform().getOrigin()).length2();
|
||||||
if (squareMot0 < convexbody->getCcdSquareMotionThreshold())
|
if (squareMot0 < convexbody->getCcdSquareMotionThreshold())
|
||||||
{
|
{
|
||||||
return 1.f;
|
return btScalar(1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
//const btVector3& from = convexbody->m_worldTransform.getOrigin();
|
//const btVector3& from = convexbody->m_worldTransform.getOrigin();
|
||||||
@@ -227,11 +227,11 @@ float btConvexConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject
|
|||||||
btTransform m_ccdSphereToTrans;
|
btTransform m_ccdSphereToTrans;
|
||||||
btTransform m_meshTransform;
|
btTransform m_meshTransform;
|
||||||
|
|
||||||
float m_ccdSphereRadius;
|
btScalar m_ccdSphereRadius;
|
||||||
float m_hitFraction;
|
btScalar m_hitFraction;
|
||||||
|
|
||||||
|
|
||||||
LocalTriangleSphereCastCallback(const btTransform& from,const btTransform& to,float ccdSphereRadius,float hitFraction)
|
LocalTriangleSphereCastCallback(const btTransform& from,const btTransform& to,btScalar ccdSphereRadius,btScalar hitFraction)
|
||||||
:m_ccdSphereFromTrans(from),
|
:m_ccdSphereFromTrans(from),
|
||||||
m_ccdSphereToTrans(to),
|
m_ccdSphereToTrans(to),
|
||||||
m_ccdSphereRadius(ccdSphereRadius),
|
m_ccdSphereRadius(ccdSphereRadius),
|
||||||
@@ -276,11 +276,11 @@ float btConvexConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject
|
|||||||
rayAabbMin.setMin(convexToLocal.getOrigin());
|
rayAabbMin.setMin(convexToLocal.getOrigin());
|
||||||
btVector3 rayAabbMax = convexFromLocal.getOrigin();
|
btVector3 rayAabbMax = convexFromLocal.getOrigin();
|
||||||
rayAabbMax.setMax(convexToLocal.getOrigin());
|
rayAabbMax.setMax(convexToLocal.getOrigin());
|
||||||
float ccdRadius0 = convexbody->getCcdSweptSphereRadius();
|
btScalar ccdRadius0 = convexbody->getCcdSweptSphereRadius();
|
||||||
rayAabbMin -= btVector3(ccdRadius0,ccdRadius0,ccdRadius0);
|
rayAabbMin -= btVector3(ccdRadius0,ccdRadius0,ccdRadius0);
|
||||||
rayAabbMax += btVector3(ccdRadius0,ccdRadius0,ccdRadius0);
|
rayAabbMax += btVector3(ccdRadius0,ccdRadius0,ccdRadius0);
|
||||||
|
|
||||||
float curHitFraction = 1.f; //is this available?
|
btScalar curHitFraction = btScalar(1.); //is this available?
|
||||||
LocalTriangleSphereCastCallback raycastCallback(convexFromLocal,convexToLocal,
|
LocalTriangleSphereCastCallback raycastCallback(convexFromLocal,convexToLocal,
|
||||||
convexbody->getCcdSweptSphereRadius(),curHitFraction);
|
convexbody->getCcdSweptSphereRadius(),curHitFraction);
|
||||||
|
|
||||||
@@ -304,6 +304,6 @@ float btConvexConcaveCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1.f;
|
return btScalar(1.);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class btConvexTriangleCallback : public btTriangleCallback
|
|||||||
|
|
||||||
btDispatcher* m_dispatcher;
|
btDispatcher* m_dispatcher;
|
||||||
const btDispatcherInfo* m_dispatchInfoPtr;
|
const btDispatcherInfo* m_dispatchInfoPtr;
|
||||||
float m_collisionMarginTriangle;
|
btScalar m_collisionMarginTriangle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int m_triangleCount;
|
int m_triangleCount;
|
||||||
@@ -47,7 +47,7 @@ int m_triangleCount;
|
|||||||
|
|
||||||
btConvexTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped);
|
btConvexTriangleCallback(btDispatcher* dispatcher,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped);
|
||||||
|
|
||||||
void setTimeStepAndCounters(float collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
void setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
virtual ~btConvexTriangleCallback();
|
virtual ~btConvexTriangleCallback();
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ public:
|
|||||||
|
|
||||||
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
float calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
void clearCache();
|
void clearCache();
|
||||||
|
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
|
|||||||
input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
|
input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
|
||||||
input.m_stackAlloc = dispatchInfo.m_stackAllocator;
|
input.m_stackAlloc = dispatchInfo.m_stackAllocator;
|
||||||
|
|
||||||
// input.m_maximumDistanceSquared = 1e30f;
|
// input.m_maximumDistanceSquared = btScalar(1e30);
|
||||||
|
|
||||||
input.m_transformA = body0->getWorldTransform();
|
input.m_transformA = body0->getWorldTransform();
|
||||||
input.m_transformB = body1->getWorldTransform();
|
input.m_transformB = body1->getWorldTransform();
|
||||||
@@ -146,24 +146,24 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
|
|||||||
|
|
||||||
|
|
||||||
bool disableCcd = false;
|
bool disableCcd = false;
|
||||||
float btConvexConvexAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
btScalar btConvexConvexAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||||
{
|
{
|
||||||
///Rather then checking ALL pairs, only calculate TOI when motion exceeds threshold
|
///Rather then checking ALL pairs, only calculate TOI when motion exceeds threshold
|
||||||
|
|
||||||
///Linear motion for one of objects needs to exceed m_ccdSquareMotionThreshold
|
///Linear motion for one of objects needs to exceed m_ccdSquareMotionThreshold
|
||||||
///col0->m_worldTransform,
|
///col0->m_worldTransform,
|
||||||
float resultFraction = 1.f;
|
btScalar resultFraction = btScalar(1.);
|
||||||
|
|
||||||
|
|
||||||
float squareMot0 = (col0->getInterpolationWorldTransform().getOrigin() - col0->getWorldTransform().getOrigin()).length2();
|
btScalar squareMot0 = (col0->getInterpolationWorldTransform().getOrigin() - col0->getWorldTransform().getOrigin()).length2();
|
||||||
float squareMot1 = (col1->getInterpolationWorldTransform().getOrigin() - col1->getWorldTransform().getOrigin()).length2();
|
btScalar squareMot1 = (col1->getInterpolationWorldTransform().getOrigin() - col1->getWorldTransform().getOrigin()).length2();
|
||||||
|
|
||||||
if (squareMot0 < col0->getCcdSquareMotionThreshold() &&
|
if (squareMot0 < col0->getCcdSquareMotionThreshold() &&
|
||||||
squareMot1 < col1->getCcdSquareMotionThreshold())
|
squareMot1 < col1->getCcdSquareMotionThreshold())
|
||||||
return resultFraction;
|
return resultFraction;
|
||||||
|
|
||||||
if (disableCcd)
|
if (disableCcd)
|
||||||
return 1.f;
|
return btScalar(1.);
|
||||||
|
|
||||||
|
|
||||||
//An adhoc way of testing the Continuous Collision Detection algorithms
|
//An adhoc way of testing the Continuous Collision Detection algorithms
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
|
|
||||||
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
virtual float calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
void setLowLevelOfDetail(bool useLowLevel);
|
void setLowLevelOfDetail(bool useLowLevel);
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ void btEmptyAlgorithm::processCollision (btCollisionObject* body0,btCollisionObj
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float btEmptyAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
btScalar btEmptyAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||||
{
|
{
|
||||||
return 1.f;
|
return btScalar(1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
|
|
||||||
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
virtual float calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ inline btScalar calculateCombinedFriction(const btCollisionObject* body0,const b
|
|||||||
{
|
{
|
||||||
btScalar friction = body0->getFriction() * body1->getFriction();
|
btScalar friction = body0->getFriction() * body1->getFriction();
|
||||||
|
|
||||||
const btScalar MAX_FRICTION = 10.f;
|
const btScalar MAX_FRICTION = btScalar(10.);
|
||||||
if (friction < -MAX_FRICTION)
|
if (friction < -MAX_FRICTION)
|
||||||
friction = -MAX_FRICTION;
|
friction = -MAX_FRICTION;
|
||||||
if (friction > MAX_FRICTION)
|
if (friction > MAX_FRICTION)
|
||||||
@@ -53,7 +53,7 @@ btManifoldResult::btManifoldResult(btCollisionObject* body0,btCollisionObject* b
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth)
|
void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
|
||||||
{
|
{
|
||||||
assert(m_manifoldPtr);
|
assert(m_manifoldPtr);
|
||||||
//order in manifold needs to match
|
//order in manifold needs to match
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public:
|
|||||||
m_index1=index1;
|
m_index1=index1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth);
|
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ void btSimulationIslandManager::findUnions(btDispatcher* dispatcher)
|
|||||||
for (int i=0;i<dispatcher->getNumManifolds();i++)
|
for (int i=0;i<dispatcher->getNumManifolds();i++)
|
||||||
{
|
{
|
||||||
const btPersistentManifold* manifold = dispatcher->getManifoldByIndexInternal(i);
|
const btPersistentManifold* manifold = dispatcher->getManifoldByIndexInternal(i);
|
||||||
//static objects (invmass 0.f) don't merge !
|
//static objects (invmass btScalar(0.)) don't merge !
|
||||||
|
|
||||||
const btCollisionObject* colObj0 = static_cast<const btCollisionObject*>(manifold->getBody0());
|
const btCollisionObject* colObj0 = static_cast<const btCollisionObject*>(manifold->getBody0());
|
||||||
const btCollisionObject* colObj1 = static_cast<const btCollisionObject*>(manifold->getBody1());
|
const btCollisionObject* colObj1 = static_cast<const btCollisionObject*>(manifold->getBody1());
|
||||||
@@ -66,7 +66,7 @@ void btSimulationIslandManager::updateActivationState(btCollisionWorld* colWorld
|
|||||||
|
|
||||||
btCollisionObject* collisionObject= (*i);
|
btCollisionObject* collisionObject= (*i);
|
||||||
collisionObject->setIslandTag(index);
|
collisionObject->setIslandTag(index);
|
||||||
collisionObject->setHitFraction(1.f);
|
collisionObject->setHitFraction(btScalar(1.));
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@ void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,
|
|||||||
int startManifoldIndex = 0;
|
int startManifoldIndex = 0;
|
||||||
int endManifoldIndex = 1;
|
int endManifoldIndex = 1;
|
||||||
|
|
||||||
int islandId;
|
//int islandId;
|
||||||
|
|
||||||
|
|
||||||
//update the sleeping state for bodies, if all are sleeping
|
//update the sleeping state for bodies, if all are sleeping
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ void btSphereBoxCollisionAlgorithm::processCollision (btCollisionObject* body0,b
|
|||||||
btVector3 sphereCenter = sphereObj->getWorldTransform().getOrigin();
|
btVector3 sphereCenter = sphereObj->getWorldTransform().getOrigin();
|
||||||
btScalar radius = sphere0->getRadius();
|
btScalar radius = sphere0->getRadius();
|
||||||
|
|
||||||
float dist = getSphereDistance(boxObj,pOnBox,pOnSphere,sphereCenter,radius);
|
btScalar dist = getSphereDistance(boxObj,pOnBox,pOnSphere,sphereCenter,radius);
|
||||||
|
|
||||||
if (dist < SIMD_EPSILON)
|
if (dist < SIMD_EPSILON)
|
||||||
{
|
{
|
||||||
@@ -81,10 +81,10 @@ void btSphereBoxCollisionAlgorithm::processCollision (btCollisionObject* body0,b
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float btSphereBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
btScalar btSphereBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||||
{
|
{
|
||||||
//not yet
|
//not yet
|
||||||
return 1.f;
|
return btScalar(1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -117,14 +117,14 @@ btScalar btSphereBoxCollisionAlgorithm::getSphereDistance(btCollisionObject* box
|
|||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
btVector3 tmp, prel, n[6], normal, v3P;
|
btVector3 tmp, prel, n[6], normal, v3P;
|
||||||
btScalar fSep = 10000000.0f, fSepThis;
|
btScalar fSep = btScalar(10000000.0), fSepThis;
|
||||||
|
|
||||||
n[0].setValue( -1.0f, 0.0f, 0.0f );
|
n[0].setValue( btScalar(-1.0), btScalar(0.0), btScalar(0.0) );
|
||||||
n[1].setValue( 0.0f, -1.0f, 0.0f );
|
n[1].setValue( btScalar(0.0), btScalar(-1.0), btScalar(0.0) );
|
||||||
n[2].setValue( 0.0f, 0.0f, -1.0f );
|
n[2].setValue( btScalar(0.0), btScalar(0.0), btScalar(-1.0) );
|
||||||
n[3].setValue( 1.0f, 0.0f, 0.0f );
|
n[3].setValue( btScalar(1.0), btScalar(0.0), btScalar(0.0) );
|
||||||
n[4].setValue( 0.0f, 1.0f, 0.0f );
|
n[4].setValue( btScalar(0.0), btScalar(1.0), btScalar(0.0) );
|
||||||
n[5].setValue( 0.0f, 0.0f, 1.0f );
|
n[5].setValue( btScalar(0.0), btScalar(0.0), btScalar(1.0) );
|
||||||
|
|
||||||
// convert point in local space
|
// convert point in local space
|
||||||
prel = m44T.invXform( sphereCenter);
|
prel = m44T.invXform( sphereCenter);
|
||||||
@@ -136,7 +136,7 @@ btScalar btSphereBoxCollisionAlgorithm::getSphereDistance(btCollisionObject* box
|
|||||||
for (int i=0;i<6;i++)
|
for (int i=0;i<6;i++)
|
||||||
{
|
{
|
||||||
int j = i<3? 0:1;
|
int j = i<3? 0:1;
|
||||||
if ( (fSepThis = ((v3P-bounds[j]) .dot(n[i]))) > 0.0f )
|
if ( (fSepThis = ((v3P-bounds[j]) .dot(n[i]))) > btScalar(0.0) )
|
||||||
{
|
{
|
||||||
v3P = v3P - n[i]*fSepThis;
|
v3P = v3P - n[i]*fSepThis;
|
||||||
bFound = true;
|
bFound = true;
|
||||||
@@ -154,9 +154,9 @@ btScalar btSphereBoxCollisionAlgorithm::getSphereDistance(btCollisionObject* box
|
|||||||
pointOnBox = v3P + normal*margins;
|
pointOnBox = v3P + normal*margins;
|
||||||
v3PointOnSphere = prel - normal*fRadius;
|
v3PointOnSphere = prel - normal*fRadius;
|
||||||
|
|
||||||
if ( ((v3PointOnSphere - pointOnBox) .dot (normal)) > 0.0f )
|
if ( ((v3PointOnSphere - pointOnBox) .dot (normal)) > btScalar(0.0) )
|
||||||
{
|
{
|
||||||
return 1.0f;
|
return btScalar(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// transform back in world space
|
// transform back in world space
|
||||||
@@ -171,7 +171,7 @@ btScalar btSphereBoxCollisionAlgorithm::getSphereDistance(btCollisionObject* box
|
|||||||
{
|
{
|
||||||
fSep = - btSqrt(fSeps2);
|
fSep = - btSqrt(fSeps2);
|
||||||
normal = (pointOnBox-v3PointOnSphere);
|
normal = (pointOnBox-v3PointOnSphere);
|
||||||
normal *= 1.f/fSep;
|
normal *= btScalar(1.)/fSep;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fSep;
|
return fSep;
|
||||||
@@ -185,10 +185,10 @@ btScalar btSphereBoxCollisionAlgorithm::getSphereDistance(btCollisionObject* box
|
|||||||
bounds[0] = boundsVec[0];
|
bounds[0] = boundsVec[0];
|
||||||
bounds[1] = boundsVec[1];
|
bounds[1] = boundsVec[1];
|
||||||
|
|
||||||
if ( fPenetration <= 0.0f )
|
if ( fPenetration <= btScalar(0.0) )
|
||||||
return (fPenetration-margins);
|
return (fPenetration-margins);
|
||||||
else
|
else
|
||||||
return 1.0f;
|
return btScalar(1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
btScalar btSphereBoxCollisionAlgorithm::getSpherePenetration( btCollisionObject* boxObj,btVector3& pointOnBox, btVector3& v3PointOnSphere, const btVector3& sphereCenter, btScalar fRadius, const btVector3& aabbMin, const btVector3& aabbMax)
|
btScalar btSphereBoxCollisionAlgorithm::getSpherePenetration( btCollisionObject* boxObj,btVector3& pointOnBox, btVector3& v3PointOnSphere, const btVector3& sphereCenter, btScalar fRadius, const btVector3& aabbMin, const btVector3& aabbMax)
|
||||||
@@ -200,14 +200,14 @@ btScalar btSphereBoxCollisionAlgorithm::getSpherePenetration( btCollisionObject*
|
|||||||
bounds[1] = aabbMax;
|
bounds[1] = aabbMax;
|
||||||
|
|
||||||
btVector3 p0, tmp, prel, n[6], normal;
|
btVector3 p0, tmp, prel, n[6], normal;
|
||||||
btScalar fSep = -10000000.0f, fSepThis;
|
btScalar fSep = btScalar(-10000000.0), fSepThis;
|
||||||
|
|
||||||
n[0].setValue( -1.0f, 0.0f, 0.0f );
|
n[0].setValue( btScalar(-1.0), btScalar(0.0), btScalar(0.0) );
|
||||||
n[1].setValue( 0.0f, -1.0f, 0.0f );
|
n[1].setValue( btScalar(0.0), btScalar(-1.0), btScalar(0.0) );
|
||||||
n[2].setValue( 0.0f, 0.0f, -1.0f );
|
n[2].setValue( btScalar(0.0), btScalar(0.0), btScalar(-1.0) );
|
||||||
n[3].setValue( 1.0f, 0.0f, 0.0f );
|
n[3].setValue( btScalar(1.0), btScalar(0.0), btScalar(0.0) );
|
||||||
n[4].setValue( 0.0f, 1.0f, 0.0f );
|
n[4].setValue( btScalar(0.0), btScalar(1.0), btScalar(0.0) );
|
||||||
n[5].setValue( 0.0f, 0.0f, 1.0f );
|
n[5].setValue( btScalar(0.0), btScalar(0.0), btScalar(1.0) );
|
||||||
|
|
||||||
const btTransform& m44T = boxObj->getWorldTransform();
|
const btTransform& m44T = boxObj->getWorldTransform();
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ btScalar btSphereBoxCollisionAlgorithm::getSpherePenetration( btCollisionObject*
|
|||||||
for (int i=0;i<6;i++)
|
for (int i=0;i<6;i++)
|
||||||
{
|
{
|
||||||
int j = i<3 ? 0:1;
|
int j = i<3 ? 0:1;
|
||||||
if ( (fSepThis = ((prel-bounds[j]) .dot( n[i]))-fRadius) > 0.0f ) return 1.0f;
|
if ( (fSepThis = ((prel-bounds[j]) .dot( n[i]))-fRadius) > btScalar(0.0) ) return btScalar(1.0);
|
||||||
if ( fSepThis > fSep )
|
if ( fSepThis > fSep )
|
||||||
{
|
{
|
||||||
p0 = bounds[j]; normal = (btVector3&)n[i];
|
p0 = bounds[j]; normal = (btVector3&)n[i];
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
|
|
||||||
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
virtual float calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
btScalar getSphereDistance( btCollisionObject* boxObj,btVector3& v3PointOnBox, btVector3& v3PointOnSphere, const btVector3& v3SphereCenter, btScalar fRadius );
|
btScalar getSphereDistance( btCollisionObject* boxObj,btVector3& v3PointOnBox, btVector3& v3PointOnSphere, const btVector3& v3SphereCenter, btScalar fRadius );
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ void btSphereSphereCollisionAlgorithm::processCollision (btCollisionObject* col0
|
|||||||
btSphereShape* sphere1 = (btSphereShape*)col1->getCollisionShape();
|
btSphereShape* sphere1 = (btSphereShape*)col1->getCollisionShape();
|
||||||
|
|
||||||
btVector3 diff = col0->getWorldTransform().getOrigin()- col1->getWorldTransform().getOrigin();
|
btVector3 diff = col0->getWorldTransform().getOrigin()- col1->getWorldTransform().getOrigin();
|
||||||
float len = diff.length();
|
btScalar len = diff.length();
|
||||||
btScalar radius0 = sphere0->getRadius();
|
btScalar radius0 = sphere0->getRadius();
|
||||||
btScalar radius1 = sphere1->getRadius();
|
btScalar radius1 = sphere1->getRadius();
|
||||||
|
|
||||||
@@ -71,8 +71,8 @@ void btSphereSphereCollisionAlgorithm::processCollision (btCollisionObject* col0
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float btSphereSphereCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
btScalar btSphereSphereCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||||
{
|
{
|
||||||
//not yet
|
//not yet
|
||||||
return 1.f;
|
return btScalar(1.);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
|
|
||||||
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
virtual float calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
|
|
||||||
virtual ~btSphereSphereCollisionAlgorithm();
|
virtual ~btSphereSphereCollisionAlgorithm();
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ void btSphereTriangleCollisionAlgorithm::processCollision (btCollisionObject* co
|
|||||||
SphereTriangleDetector detector(sphere,triangle);
|
SphereTriangleDetector detector(sphere,triangle);
|
||||||
|
|
||||||
btDiscreteCollisionDetectorInterface::ClosestPointInput input;
|
btDiscreteCollisionDetectorInterface::ClosestPointInput input;
|
||||||
input.m_maximumDistanceSquared = 1e30f;//todo: tighter bounds
|
input.m_maximumDistanceSquared = btScalar(1e30);//todo: tighter bounds
|
||||||
input.m_transformA = col0->getWorldTransform();
|
input.m_transformA = col0->getWorldTransform();
|
||||||
input.m_transformB = col1->getWorldTransform();
|
input.m_transformB = col1->getWorldTransform();
|
||||||
|
|
||||||
@@ -64,8 +64,8 @@ void btSphereTriangleCollisionAlgorithm::processCollision (btCollisionObject* co
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float btSphereTriangleCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
btScalar btSphereTriangleCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||||
{
|
{
|
||||||
//not yet
|
//not yet
|
||||||
return 1.f;
|
return btScalar(1.);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
|
|
||||||
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
virtual float calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
|
|
||||||
virtual ~btSphereTriangleCollisionAlgorithm();
|
virtual ~btSphereTriangleCollisionAlgorithm();
|
||||||
|
|||||||
@@ -42,16 +42,16 @@ void btBoxShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabb
|
|||||||
|
|
||||||
void btBoxShape::calculateLocalInertia(btScalar mass,btVector3& inertia)
|
void btBoxShape::calculateLocalInertia(btScalar mass,btVector3& inertia)
|
||||||
{
|
{
|
||||||
//float margin = 0.f;
|
//btScalar margin = btScalar(0.);
|
||||||
btVector3 halfExtents = getHalfExtents();
|
btVector3 halfExtents = getHalfExtents();
|
||||||
|
|
||||||
btScalar lx=2.f*(halfExtents.x());
|
btScalar lx=btScalar(2.)*(halfExtents.x());
|
||||||
btScalar ly=2.f*(halfExtents.y());
|
btScalar ly=btScalar(2.)*(halfExtents.y());
|
||||||
btScalar lz=2.f*(halfExtents.z());
|
btScalar lz=btScalar(2.)*(halfExtents.z());
|
||||||
|
|
||||||
inertia[0] = mass/(12.0f) * (ly*ly + lz*lz);
|
inertia[0] = mass/(btScalar(12.0)) * (ly*ly + lz*lz);
|
||||||
inertia[1] = mass/(12.0f) * (lx*lx + lz*lz);
|
inertia[1] = mass/(btScalar(12.0)) * (lx*lx + lz*lz);
|
||||||
inertia[2] = mass/(12.0f) * (lx*lx + ly*ly);
|
inertia[2] = mass/(btScalar(12.0)) * (lx*lx + ly*ly);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ public:
|
|||||||
btVector3 halfExtents = getHalfExtents();
|
btVector3 halfExtents = getHalfExtents();
|
||||||
|
|
||||||
btVector3 supVertex;
|
btVector3 supVertex;
|
||||||
supVertex = btPoint3(vec.x() < btScalar(0.0f) ? -halfExtents.x() : halfExtents.x(),
|
supVertex = btPoint3(vec.x() < btScalar(0.0) ? -halfExtents.x() : halfExtents.x(),
|
||||||
vec.y() < btScalar(0.0f) ? -halfExtents.y() : halfExtents.y(),
|
vec.y() < btScalar(0.0) ? -halfExtents.y() : halfExtents.y(),
|
||||||
vec.z() < btScalar(0.0f) ? -halfExtents.z() : halfExtents.z());
|
vec.z() < btScalar(0.0) ? -halfExtents.z() : halfExtents.z());
|
||||||
|
|
||||||
return supVertex;
|
return supVertex;
|
||||||
}
|
}
|
||||||
@@ -54,9 +54,9 @@ public:
|
|||||||
btVector3 margin(getMargin(),getMargin(),getMargin());
|
btVector3 margin(getMargin(),getMargin(),getMargin());
|
||||||
halfExtents -= margin;
|
halfExtents -= margin;
|
||||||
|
|
||||||
return btVector3(vec.x() < btScalar(0.0f) ? -halfExtents.x() : halfExtents.x(),
|
return btVector3(vec.x() < btScalar(0.0) ? -halfExtents.x() : halfExtents.x(),
|
||||||
vec.y() < btScalar(0.0f) ? -halfExtents.y() : halfExtents.y(),
|
vec.y() < btScalar(0.0) ? -halfExtents.y() : halfExtents.y(),
|
||||||
vec.z() < btScalar(0.0f) ? -halfExtents.z() : halfExtents.z());
|
vec.z() < btScalar(0.0) ? -halfExtents.z() : halfExtents.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
|
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
|
||||||
@@ -69,9 +69,9 @@ public:
|
|||||||
for (int i=0;i<numVectors;i++)
|
for (int i=0;i<numVectors;i++)
|
||||||
{
|
{
|
||||||
const btVector3& vec = vectors[i];
|
const btVector3& vec = vectors[i];
|
||||||
supportVerticesOut[i].setValue(vec.x() < btScalar(0.0f) ? -halfExtents.x() : halfExtents.x(),
|
supportVerticesOut[i].setValue(vec.x() < btScalar(0.0) ? -halfExtents.x() : halfExtents.x(),
|
||||||
vec.y() < btScalar(0.0f) ? -halfExtents.y() : halfExtents.y(),
|
vec.y() < btScalar(0.0) ? -halfExtents.y() : halfExtents.y(),
|
||||||
vec.z() < btScalar(0.0f) ? -halfExtents.z() : halfExtents.z());
|
vec.z() < btScalar(0.0) ? -halfExtents.z() : halfExtents.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -132,27 +132,27 @@ public:
|
|||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
plane.setValue(1.f,0.f,0.f);
|
plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.));
|
||||||
plane[3] = -halfExtents.x();
|
plane[3] = -halfExtents.x();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
plane.setValue(-1.f,0.f,0.f);
|
plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.));
|
||||||
plane[3] = -halfExtents.x();
|
plane[3] = -halfExtents.x();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
plane.setValue(0.f,1.f,0.f);
|
plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.));
|
||||||
plane[3] = -halfExtents.y();
|
plane[3] = -halfExtents.y();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
plane.setValue(0.f,-1.f,0.f);
|
plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.));
|
||||||
plane[3] = -halfExtents.y();
|
plane[3] = -halfExtents.y();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
plane.setValue(0.f,0.f,1.f);
|
plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.));
|
||||||
plane[3] = -halfExtents.z();
|
plane[3] = -halfExtents.z();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
plane.setValue(0.f,0.f,-1.f);
|
plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.));
|
||||||
plane[3] = -halfExtents.z();
|
plane[3] = -halfExtents.z();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -265,22 +265,22 @@ public:
|
|||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
penetrationVector.setValue(1.f,0.f,0.f);
|
penetrationVector.setValue(btScalar(1.),btScalar(0.),btScalar(0.));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
penetrationVector.setValue(-1.f,0.f,0.f);
|
penetrationVector.setValue(btScalar(-1.),btScalar(0.),btScalar(0.));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
penetrationVector.setValue(0.f,1.f,0.f);
|
penetrationVector.setValue(btScalar(0.),btScalar(1.),btScalar(0.));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
penetrationVector.setValue(0.f,-1.f,0.f);
|
penetrationVector.setValue(btScalar(0.),btScalar(-1.),btScalar(0.));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
penetrationVector.setValue(0.f,0.f,1.f);
|
penetrationVector.setValue(btScalar(0.),btScalar(0.),btScalar(1.));
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
penetrationVector.setValue(0.f,0.f,-1.f);
|
penetrationVector.setValue(btScalar(0.),btScalar(0.),btScalar(-1.));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ void btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,co
|
|||||||
#ifdef DEBUG_TRIANGLE_MESH
|
#ifdef DEBUG_TRIANGLE_MESH
|
||||||
printf("%d ,",graphicsindex);
|
printf("%d ,",graphicsindex);
|
||||||
#endif //DEBUG_TRIANGLE_MESH
|
#endif //DEBUG_TRIANGLE_MESH
|
||||||
float* graphicsbase = (float*)(vertexbase+graphicsindex*stride);
|
btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
|
||||||
|
|
||||||
m_triangle[j] = btVector3(
|
m_triangle[j] = btVector3(
|
||||||
graphicsbase[0]*meshScaling.getX(),
|
graphicsbase[0]*meshScaling.getX(),
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
//used by Gjk and some other algorithms
|
//used by Gjk and some other algorithms
|
||||||
|
|
||||||
#define CONVEX_DISTANCE_MARGIN 0.04f// 0.1f//;//0.01f
|
#define CONVEX_DISTANCE_MARGIN btScalar(0.04)// btScalar(0.1)//;//btScalar(0.01)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ void btCollisionShape::getBoundingSphere(btVector3& center,btScalar& radius) con
|
|||||||
|
|
||||||
getAabb(tr,aabbMin,aabbMax);
|
getAabb(tr,aabbMin,aabbMax);
|
||||||
|
|
||||||
radius = (aabbMax-aabbMin).length()*0.5f;
|
radius = (aabbMax-aabbMin).length()*btScalar(0.5);
|
||||||
center = (aabbMin+aabbMax)*0.5f;
|
center = (aabbMin+aabbMax)*btScalar(0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
float btCollisionShape::getAngularMotionDisc() const
|
btScalar btCollisionShape::getAngularMotionDisc() const
|
||||||
{
|
{
|
||||||
btVector3 center;
|
btVector3 center;
|
||||||
float disc;
|
btScalar disc;
|
||||||
getBoundingSphere(center,disc);
|
getBoundingSphere(center,disc);
|
||||||
disc += (center).length();
|
disc += (center).length();
|
||||||
return disc;
|
return disc;
|
||||||
@@ -41,25 +41,25 @@ void btCollisionShape::calculateTemporalAabb(const btTransform& curTrans,const b
|
|||||||
//start with static aabb
|
//start with static aabb
|
||||||
getAabb(curTrans,temporalAabbMin,temporalAabbMax);
|
getAabb(curTrans,temporalAabbMin,temporalAabbMax);
|
||||||
|
|
||||||
float temporalAabbMaxx = temporalAabbMax.getX();
|
btScalar temporalAabbMaxx = temporalAabbMax.getX();
|
||||||
float temporalAabbMaxy = temporalAabbMax.getY();
|
btScalar temporalAabbMaxy = temporalAabbMax.getY();
|
||||||
float temporalAabbMaxz = temporalAabbMax.getZ();
|
btScalar temporalAabbMaxz = temporalAabbMax.getZ();
|
||||||
float temporalAabbMinx = temporalAabbMin.getX();
|
btScalar temporalAabbMinx = temporalAabbMin.getX();
|
||||||
float temporalAabbMiny = temporalAabbMin.getY();
|
btScalar temporalAabbMiny = temporalAabbMin.getY();
|
||||||
float temporalAabbMinz = temporalAabbMin.getZ();
|
btScalar temporalAabbMinz = temporalAabbMin.getZ();
|
||||||
|
|
||||||
// add linear motion
|
// add linear motion
|
||||||
btVector3 linMotion = linvel*timeStep;
|
btVector3 linMotion = linvel*timeStep;
|
||||||
//todo: simd would have a vector max/min operation, instead of per-element access
|
//todo: simd would have a vector max/min operation, instead of per-element access
|
||||||
if (linMotion.x() > 0.f)
|
if (linMotion.x() > btScalar(0.))
|
||||||
temporalAabbMaxx += linMotion.x();
|
temporalAabbMaxx += linMotion.x();
|
||||||
else
|
else
|
||||||
temporalAabbMinx += linMotion.x();
|
temporalAabbMinx += linMotion.x();
|
||||||
if (linMotion.y() > 0.f)
|
if (linMotion.y() > btScalar(0.))
|
||||||
temporalAabbMaxy += linMotion.y();
|
temporalAabbMaxy += linMotion.y();
|
||||||
else
|
else
|
||||||
temporalAabbMiny += linMotion.y();
|
temporalAabbMiny += linMotion.y();
|
||||||
if (linMotion.z() > 0.f)
|
if (linMotion.z() > btScalar(0.))
|
||||||
temporalAabbMaxz += linMotion.z();
|
temporalAabbMaxz += linMotion.z();
|
||||||
else
|
else
|
||||||
temporalAabbMinz += linMotion.z();
|
temporalAabbMinz += linMotion.z();
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public:
|
|||||||
virtual void getBoundingSphere(btVector3& center,btScalar& radius) const;
|
virtual void getBoundingSphere(btVector3& center,btScalar& radius) const;
|
||||||
|
|
||||||
///getAngularMotionDisc returns the maximus radius needed for Conservative Advancement to handle time-of-impact with rotations.
|
///getAngularMotionDisc returns the maximus radius needed for Conservative Advancement to handle time-of-impact with rotations.
|
||||||
virtual float getAngularMotionDisc() const;
|
virtual btScalar getAngularMotionDisc() const;
|
||||||
|
|
||||||
virtual int getShapeType() const=0;
|
virtual int getShapeType() const=0;
|
||||||
|
|
||||||
@@ -84,8 +84,8 @@ public:
|
|||||||
const char * m_tempDebug;
|
const char * m_tempDebug;
|
||||||
//endif debugging support
|
//endif debugging support
|
||||||
|
|
||||||
virtual void setMargin(float margin) = 0;
|
virtual void setMargin(btScalar margin) = 0;
|
||||||
virtual float getMargin() const = 0;
|
virtual btScalar getMargin() const = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
|
|
||||||
btCompoundShape::btCompoundShape()
|
btCompoundShape::btCompoundShape()
|
||||||
:m_localAabbMin(1e30f,1e30f,1e30f),
|
:m_localAabbMin(btScalar(1e30),btScalar(1e30),btScalar(1e30)),
|
||||||
m_localAabbMax(-1e30f,-1e30f,-1e30f),
|
m_localAabbMax(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30)),
|
||||||
m_aabbTree(0),
|
m_aabbTree(0),
|
||||||
m_collisionMargin(0.f),
|
m_collisionMargin(btScalar(0.)),
|
||||||
m_localScaling(1.f,1.f,1.f)
|
m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,8 +60,8 @@ void btCompoundShape::addChildShape(const btTransform& localTransform,btCollisio
|
|||||||
///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
|
///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
|
||||||
void btCompoundShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
|
void btCompoundShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
|
||||||
{
|
{
|
||||||
btVector3 localHalfExtents = 0.5f*(m_localAabbMax-m_localAabbMin);
|
btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin);
|
||||||
btVector3 localCenter = 0.5f*(m_localAabbMax+m_localAabbMin);
|
btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin);
|
||||||
|
|
||||||
btMatrix3x3 abs_b = trans.getBasis().absolute();
|
btMatrix3x3 abs_b = trans.getBasis().absolute();
|
||||||
|
|
||||||
@@ -84,15 +84,15 @@ void btCompoundShape::calculateLocalInertia(btScalar mass,btVector3& inertia)
|
|||||||
btVector3 aabbMin,aabbMax;
|
btVector3 aabbMin,aabbMax;
|
||||||
getAabb(ident,aabbMin,aabbMax);
|
getAabb(ident,aabbMin,aabbMax);
|
||||||
|
|
||||||
btVector3 halfExtents = (aabbMax-aabbMin)*0.5f;
|
btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
|
||||||
|
|
||||||
btScalar lx=2.f*(halfExtents.x());
|
btScalar lx=btScalar(2.)*(halfExtents.x());
|
||||||
btScalar ly=2.f*(halfExtents.y());
|
btScalar ly=btScalar(2.)*(halfExtents.y());
|
||||||
btScalar lz=2.f*(halfExtents.z());
|
btScalar lz=btScalar(2.)*(halfExtents.z());
|
||||||
|
|
||||||
inertia[0] = mass/(12.0f) * (ly*ly + lz*lz);
|
inertia[0] = mass/(btScalar(12.0)) * (ly*ly + lz*lz);
|
||||||
inertia[1] = mass/(12.0f) * (lx*lx + lz*lz);
|
inertia[1] = mass/(btScalar(12.0)) * (lx*lx + lz*lz);
|
||||||
inertia[2] = mass/(12.0f) * (lx*lx + ly*ly);
|
inertia[2] = mass/(btScalar(12.0)) * (lx*lx + ly*ly);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,11 +85,11 @@ public:
|
|||||||
|
|
||||||
virtual int getShapeType() const { return COMPOUND_SHAPE_PROXYTYPE;}
|
virtual int getShapeType() const { return COMPOUND_SHAPE_PROXYTYPE;}
|
||||||
|
|
||||||
virtual void setMargin(float margin)
|
virtual void setMargin(btScalar margin)
|
||||||
{
|
{
|
||||||
m_collisionMargin = margin;
|
m_collisionMargin = margin;
|
||||||
}
|
}
|
||||||
virtual float getMargin() const
|
virtual btScalar getMargin() const
|
||||||
{
|
{
|
||||||
return m_collisionMargin;
|
return m_collisionMargin;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include "btConcaveShape.h"
|
#include "btConcaveShape.h"
|
||||||
|
|
||||||
btConcaveShape::btConcaveShape() : m_collisionMargin(0.f)
|
btConcaveShape::btConcaveShape() : m_collisionMargin(btScalar(0.))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ subject to the following restrictions:
|
|||||||
class btConcaveShape : public btCollisionShape
|
class btConcaveShape : public btCollisionShape
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
float m_collisionMargin;
|
btScalar m_collisionMargin;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
btConcaveShape();
|
btConcaveShape();
|
||||||
@@ -36,10 +36,10 @@ public:
|
|||||||
|
|
||||||
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const = 0;
|
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const = 0;
|
||||||
|
|
||||||
virtual float getMargin() const {
|
virtual btScalar getMargin() const {
|
||||||
return m_collisionMargin;
|
return m_collisionMargin;
|
||||||
}
|
}
|
||||||
virtual void setMargin(float collisionMargin)
|
virtual void setMargin(btScalar collisionMargin)
|
||||||
{
|
{
|
||||||
m_collisionMargin = collisionMargin;
|
m_collisionMargin = collisionMargin;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ m_height(height)
|
|||||||
{
|
{
|
||||||
setConeUpIndex(1);
|
setConeUpIndex(1);
|
||||||
btVector3 halfExtents;
|
btVector3 halfExtents;
|
||||||
m_sinAngle = (m_radius / sqrt(m_radius * m_radius + m_height * m_height));
|
m_sinAngle = (m_radius / btSqrt(m_radius * m_radius + m_height * m_height));
|
||||||
}
|
}
|
||||||
|
|
||||||
btConeShapeZ::btConeShapeZ (btScalar radius,btScalar height):
|
btConeShapeZ::btConeShapeZ (btScalar radius,btScalar height):
|
||||||
@@ -67,15 +67,15 @@ void btConeShape::setConeUpIndex(int upIndex)
|
|||||||
btVector3 btConeShape::coneLocalSupport(const btVector3& v) const
|
btVector3 btConeShape::coneLocalSupport(const btVector3& v) const
|
||||||
{
|
{
|
||||||
|
|
||||||
float halfHeight = m_height * 0.5f;
|
btScalar halfHeight = m_height * btScalar(0.5);
|
||||||
|
|
||||||
if (v[m_coneIndices[1]] > v.length() * m_sinAngle)
|
if (v[m_coneIndices[1]] > v.length() * m_sinAngle)
|
||||||
{
|
{
|
||||||
btVector3 tmp;
|
btVector3 tmp;
|
||||||
|
|
||||||
tmp[m_coneIndices[0]] = 0.f;
|
tmp[m_coneIndices[0]] = btScalar(0.);
|
||||||
tmp[m_coneIndices[1]] = halfHeight;
|
tmp[m_coneIndices[1]] = halfHeight;
|
||||||
tmp[m_coneIndices[2]] = 0.f;
|
tmp[m_coneIndices[2]] = btScalar(0.);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -90,9 +90,9 @@ btVector3 btConeShape::coneLocalSupport(const btVector3& v) const
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
btVector3 tmp;
|
btVector3 tmp;
|
||||||
tmp[m_coneIndices[0]] = 0.f;
|
tmp[m_coneIndices[0]] = btScalar(0.);
|
||||||
tmp[m_coneIndices[1]] = -halfHeight;
|
tmp[m_coneIndices[1]] = -halfHeight;
|
||||||
tmp[m_coneIndices[2]] = 0.f;
|
tmp[m_coneIndices[2]] = btScalar(0.);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,12 +117,12 @@ void btConeShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVect
|
|||||||
btVector3 btConeShape::localGetSupportingVertex(const btVector3& vec) const
|
btVector3 btConeShape::localGetSupportingVertex(const btVector3& vec) const
|
||||||
{
|
{
|
||||||
btVector3 supVertex = coneLocalSupport(vec);
|
btVector3 supVertex = coneLocalSupport(vec);
|
||||||
if ( getMargin()!=0.f )
|
if ( getMargin()!=btScalar(0.) )
|
||||||
{
|
{
|
||||||
btVector3 vecnorm = vec;
|
btVector3 vecnorm = vec;
|
||||||
if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
|
if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
|
||||||
{
|
{
|
||||||
vecnorm.setValue(-1.f,-1.f,-1.f);
|
vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
|
||||||
}
|
}
|
||||||
vecnorm.normalize();
|
vecnorm.normalize();
|
||||||
supVertex+= getMargin() * vecnorm;
|
supVertex+= getMargin() * vecnorm;
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ class btConeShape : public btConvexShape
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
float m_sinAngle;
|
btScalar m_sinAngle;
|
||||||
float m_radius;
|
btScalar m_radius;
|
||||||
float m_height;
|
btScalar m_height;
|
||||||
int m_coneIndices[3];
|
int m_coneIndices[3];
|
||||||
btVector3 coneLocalSupport(const btVector3& v) const;
|
btVector3 coneLocalSupport(const btVector3& v) const;
|
||||||
|
|
||||||
@@ -38,8 +38,8 @@ public:
|
|||||||
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec) const;
|
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec) const;
|
||||||
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
|
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
|
||||||
|
|
||||||
float getRadius() const { return m_radius;}
|
btScalar getRadius() const { return m_radius;}
|
||||||
float getHeight() const { return m_height;}
|
btScalar getHeight() const { return m_height;}
|
||||||
|
|
||||||
|
|
||||||
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia)
|
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia)
|
||||||
@@ -49,17 +49,17 @@ public:
|
|||||||
btVector3 aabbMin,aabbMax;
|
btVector3 aabbMin,aabbMax;
|
||||||
getAabb(identity,aabbMin,aabbMax);
|
getAabb(identity,aabbMin,aabbMax);
|
||||||
|
|
||||||
btVector3 halfExtents = (aabbMax-aabbMin)*0.5f;
|
btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
|
||||||
|
|
||||||
float margin = getMargin();
|
btScalar margin = getMargin();
|
||||||
|
|
||||||
btScalar lx=2.f*(halfExtents.x()+margin);
|
btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
|
||||||
btScalar ly=2.f*(halfExtents.y()+margin);
|
btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
|
||||||
btScalar lz=2.f*(halfExtents.z()+margin);
|
btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
|
||||||
const btScalar x2 = lx*lx;
|
const btScalar x2 = lx*lx;
|
||||||
const btScalar y2 = ly*ly;
|
const btScalar y2 = ly*ly;
|
||||||
const btScalar z2 = lz*lz;
|
const btScalar z2 = lz*lz;
|
||||||
const btScalar scaledmass = mass * 0.08333333f;
|
const btScalar scaledmass = mass * btScalar(0.08333333);
|
||||||
|
|
||||||
inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
|
inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
btConvexHullShape ::btConvexHullShape (const float* points,int numPoints,int stride)
|
btConvexHullShape ::btConvexHullShape (const btScalar* points,int numPoints,int stride)
|
||||||
{
|
{
|
||||||
m_points.resize(numPoints);
|
m_points.resize(numPoints);
|
||||||
|
|
||||||
@@ -34,17 +34,17 @@ btConvexHullShape ::btConvexHullShape (const float* points,int numPoints,int str
|
|||||||
|
|
||||||
btVector3 btConvexHullShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
|
btVector3 btConvexHullShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
|
||||||
{
|
{
|
||||||
btVector3 supVec(0.f,0.f,0.f);
|
btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
btScalar newDot,maxDot = -1e30f;
|
btScalar newDot,maxDot = btScalar(-1e30);
|
||||||
|
|
||||||
btVector3 vec = vec0;
|
btVector3 vec = vec0;
|
||||||
btScalar lenSqr = vec.length2();
|
btScalar lenSqr = vec.length2();
|
||||||
if (lenSqr < 0.0001f)
|
if (lenSqr < btScalar(0.0001))
|
||||||
{
|
{
|
||||||
vec.setValue(1,0,0);
|
vec.setValue(1,0,0);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
float rlen = 1.f / btSqrt(lenSqr );
|
btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
|
||||||
vec *= rlen;
|
vec *= rlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ void btConvexHullShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const
|
|||||||
{
|
{
|
||||||
for (int i=0;i<numVectors;i++)
|
for (int i=0;i<numVectors;i++)
|
||||||
{
|
{
|
||||||
supportVerticesOut[i][3] = -1e30f;
|
supportVerticesOut[i][3] = btScalar(-1e30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t i=0;i<m_points.size();i++)
|
for (size_t i=0;i<m_points.size();i++)
|
||||||
@@ -101,12 +101,12 @@ btVector3 btConvexHullShape::localGetSupportingVertex(const btVector3& vec)const
|
|||||||
{
|
{
|
||||||
btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec);
|
btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec);
|
||||||
|
|
||||||
if ( getMargin()!=0.f )
|
if ( getMargin()!=btScalar(0.) )
|
||||||
{
|
{
|
||||||
btVector3 vecnorm = vec;
|
btVector3 vecnorm = vec;
|
||||||
if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
|
if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
|
||||||
{
|
{
|
||||||
vecnorm.setValue(-1.f,-1.f,-1.f);
|
vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
|
||||||
}
|
}
|
||||||
vecnorm.normalize();
|
vecnorm.normalize();
|
||||||
supVertex+= getMargin() * vecnorm;
|
supVertex+= getMargin() * vecnorm;
|
||||||
|
|||||||
@@ -31,10 +31,10 @@ class btConvexHullShape : public btPolyhedralConvexShape
|
|||||||
btAlignedObjectArray<btPoint3> m_points;
|
btAlignedObjectArray<btPoint3> m_points;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
///this constructor optionally takes in a pointer to points. Each point is assumed to be 3 consecutive float (x,y,z), the striding defines the number of bytes between each point, in memory.
|
///this constructor optionally takes in a pointer to points. Each point is assumed to be 3 consecutive btScalar (x,y,z), the striding defines the number of bytes between each point, in memory.
|
||||||
///It is easier to not pass any points in the constructor, and just add one point at a time, using addPoint.
|
///It is easier to not pass any points in the constructor, and just add one point at a time, using addPoint.
|
||||||
///btConvexHullShape make an internal copy of the points.
|
///btConvexHullShape make an internal copy of the points.
|
||||||
btConvexHullShape(const float* points=0,int numPoints=0, int stride=sizeof(btPoint3));
|
btConvexHullShape(const btScalar* points=0,int numPoints=0, int stride=sizeof(btPoint3));
|
||||||
|
|
||||||
void addPoint(const btPoint3& point)
|
void addPoint(const btPoint3& point)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ subject to the following restrictions:
|
|||||||
#include "btConvexShape.h"
|
#include "btConvexShape.h"
|
||||||
|
|
||||||
btConvexShape::btConvexShape()
|
btConvexShape::btConvexShape()
|
||||||
: m_localScaling(1.f,1.f,1.f),
|
: m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)),
|
||||||
m_collisionMargin(CONVEX_DISTANCE_MARGIN)
|
m_collisionMargin(CONVEX_DISTANCE_MARGIN)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -35,14 +35,14 @@ void btConvexShape::getAabbSlow(const btTransform& trans,btVector3&minAabb,btVec
|
|||||||
btScalar margin = getMargin();
|
btScalar margin = getMargin();
|
||||||
for (int i=0;i<3;i++)
|
for (int i=0;i<3;i++)
|
||||||
{
|
{
|
||||||
btVector3 vec(0.f,0.f,0.f);
|
btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
vec[i] = 1.f;
|
vec[i] = btScalar(1.);
|
||||||
|
|
||||||
btVector3 sv = localGetSupportingVertex(vec*trans.getBasis());
|
btVector3 sv = localGetSupportingVertex(vec*trans.getBasis());
|
||||||
|
|
||||||
btVector3 tmp = trans(sv);
|
btVector3 tmp = trans(sv);
|
||||||
maxAabb[i] = tmp[i]+margin;
|
maxAabb[i] = tmp[i]+margin;
|
||||||
vec[i] = -1.f;
|
vec[i] = btScalar(-1.);
|
||||||
tmp = trans(localGetSupportingVertex(vec*trans.getBasis()));
|
tmp = trans(localGetSupportingVertex(vec*trans.getBasis()));
|
||||||
minAabb[i] = tmp[i]-margin;
|
minAabb[i] = tmp[i]-margin;
|
||||||
}
|
}
|
||||||
@@ -52,12 +52,12 @@ btVector3 btConvexShape::localGetSupportingVertex(const btVector3& vec)const
|
|||||||
{
|
{
|
||||||
btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec);
|
btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec);
|
||||||
|
|
||||||
if ( getMargin()!=0.f )
|
if ( getMargin()!=btScalar(0.) )
|
||||||
{
|
{
|
||||||
btVector3 vecnorm = vec;
|
btVector3 vecnorm = vec;
|
||||||
if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
|
if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
|
||||||
{
|
{
|
||||||
vecnorm.setValue(-1.f,-1.f,-1.f);
|
vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
|
||||||
}
|
}
|
||||||
vecnorm.normalize();
|
vecnorm.normalize();
|
||||||
supVertex+= getMargin() * vecnorm;
|
supVertex+= getMargin() * vecnorm;
|
||||||
|
|||||||
@@ -75,11 +75,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void setMargin(float margin)
|
virtual void setMargin(btScalar margin)
|
||||||
{
|
{
|
||||||
m_collisionMargin = margin;
|
m_collisionMargin = margin;
|
||||||
}
|
}
|
||||||
virtual float getMargin() const
|
virtual btScalar getMargin() const
|
||||||
{
|
{
|
||||||
return m_collisionMargin;
|
return m_collisionMargin;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ public:
|
|||||||
btVector3 m_supportVecLocal;
|
btVector3 m_supportVecLocal;
|
||||||
|
|
||||||
LocalSupportVertexCallback(const btVector3& supportVecLocal)
|
LocalSupportVertexCallback(const btVector3& supportVecLocal)
|
||||||
: m_supportVertexLocal(0.f,0.f,0.f),
|
: m_supportVertexLocal(btScalar(0.),btScalar(0.),btScalar(0.)),
|
||||||
m_maxDot(-1e30f),
|
m_maxDot(btScalar(-1e30)),
|
||||||
m_supportVecLocal(supportVecLocal)
|
m_supportVecLocal(supportVecLocal)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -71,21 +71,21 @@ public:
|
|||||||
|
|
||||||
btVector3 btConvexTriangleMeshShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
|
btVector3 btConvexTriangleMeshShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
|
||||||
{
|
{
|
||||||
btVector3 supVec(0.f,0.f,0.f);
|
btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
|
|
||||||
btVector3 vec = vec0;
|
btVector3 vec = vec0;
|
||||||
btScalar lenSqr = vec.length2();
|
btScalar lenSqr = vec.length2();
|
||||||
if (lenSqr < 0.0001f)
|
if (lenSqr < btScalar(0.0001))
|
||||||
{
|
{
|
||||||
vec.setValue(1,0,0);
|
vec.setValue(1,0,0);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
float rlen = 1.f / btSqrt(lenSqr );
|
btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
|
||||||
vec *= rlen;
|
vec *= rlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalSupportVertexCallback supportCallback(vec);
|
LocalSupportVertexCallback supportCallback(vec);
|
||||||
btVector3 aabbMax(1e30f,1e30f,1e30f);
|
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax);
|
m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax);
|
||||||
supVec = supportCallback.GetSupportVertexLocal();
|
supVec = supportCallback.GetSupportVertexLocal();
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ void btConvexTriangleMeshShape::batchedUnitVectorGetSupportingVertexWithoutMargi
|
|||||||
{
|
{
|
||||||
for (int i=0;i<numVectors;i++)
|
for (int i=0;i<numVectors;i++)
|
||||||
{
|
{
|
||||||
supportVerticesOut[i][3] = -1e30f;
|
supportVerticesOut[i][3] = btScalar(-1e30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ void btConvexTriangleMeshShape::batchedUnitVectorGetSupportingVertexWithoutMargi
|
|||||||
{
|
{
|
||||||
const btVector3& vec = vectors[j];
|
const btVector3& vec = vectors[j];
|
||||||
LocalSupportVertexCallback supportCallback(vec);
|
LocalSupportVertexCallback supportCallback(vec);
|
||||||
btVector3 aabbMax(1e30f,1e30f,1e30f);
|
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax);
|
m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax);
|
||||||
supportVerticesOut[j] = supportCallback.GetSupportVertexLocal();
|
supportVerticesOut[j] = supportCallback.GetSupportVertexLocal();
|
||||||
}
|
}
|
||||||
@@ -122,12 +122,12 @@ btVector3 btConvexTriangleMeshShape::localGetSupportingVertex(const btVector3& v
|
|||||||
{
|
{
|
||||||
btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec);
|
btVector3 supVertex = localGetSupportingVertexWithoutMargin(vec);
|
||||||
|
|
||||||
if ( getMargin()!=0.f )
|
if ( getMargin()!=btScalar(0.) )
|
||||||
{
|
{
|
||||||
btVector3 vecnorm = vec;
|
btVector3 vecnorm = vec;
|
||||||
if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
|
if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
|
||||||
{
|
{
|
||||||
vecnorm.setValue(-1.f,-1.f,-1.f);
|
vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
|
||||||
}
|
}
|
||||||
vecnorm.normalize();
|
vecnorm.normalize();
|
||||||
supVertex+= getMargin() * vecnorm;
|
supVertex+= getMargin() * vecnorm;
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ const int ZZ = 2;
|
|||||||
// extents of the cylinder is: X,Y is for radius, and Z for height
|
// extents of the cylinder is: X,Y is for radius, and Z for height
|
||||||
|
|
||||||
|
|
||||||
float radius = halfExtents[XX];
|
btScalar radius = halfExtents[XX];
|
||||||
float halfHeight = halfExtents[cylinderUpAxis];
|
btScalar halfHeight = halfExtents[cylinderUpAxis];
|
||||||
|
|
||||||
|
|
||||||
btVector3 tmp;
|
btVector3 tmp;
|
||||||
@@ -87,8 +87,8 @@ const int YY = 1;
|
|||||||
const int ZZ = 2;
|
const int ZZ = 2;
|
||||||
|
|
||||||
|
|
||||||
float radius = halfExtents[XX];
|
btScalar radius = halfExtents[XX];
|
||||||
float halfHeight = halfExtents[cylinderUpAxis];
|
btScalar halfHeight = halfExtents[cylinderUpAxis];
|
||||||
|
|
||||||
|
|
||||||
btVector3 tmp;
|
btVector3 tmp;
|
||||||
@@ -124,8 +124,8 @@ const int ZZ = 1;
|
|||||||
// extents of the cylinder is: X,Y is for radius, and Z for height
|
// extents of the cylinder is: X,Y is for radius, and Z for height
|
||||||
|
|
||||||
|
|
||||||
float radius = halfExtents[XX];
|
btScalar radius = halfExtents[XX];
|
||||||
float halfHeight = halfExtents[cylinderUpAxis];
|
btScalar halfHeight = halfExtents[cylinderUpAxis];
|
||||||
|
|
||||||
|
|
||||||
btVector3 tmp;
|
btVector3 tmp;
|
||||||
|
|||||||
@@ -44,12 +44,12 @@ public:
|
|||||||
btVector3 supVertex;
|
btVector3 supVertex;
|
||||||
supVertex = localGetSupportingVertexWithoutMargin(vec);
|
supVertex = localGetSupportingVertexWithoutMargin(vec);
|
||||||
|
|
||||||
if ( getMargin()!=0.f )
|
if ( getMargin()!=btScalar(0.) )
|
||||||
{
|
{
|
||||||
btVector3 vecnorm = vec;
|
btVector3 vecnorm = vec;
|
||||||
if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
|
if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
|
||||||
{
|
{
|
||||||
vecnorm.setValue(-1.f,-1.f,-1.f);
|
vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
|
||||||
}
|
}
|
||||||
vecnorm.normalize();
|
vecnorm.normalize();
|
||||||
supVertex+= getMargin() * vecnorm;
|
supVertex+= getMargin() * vecnorm;
|
||||||
@@ -71,7 +71,7 @@ public:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual float getRadius() const
|
virtual btScalar getRadius() const
|
||||||
{
|
{
|
||||||
return getHalfExtents().getX();
|
return getHalfExtents().getX();
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ public:
|
|||||||
return "CylinderX";
|
return "CylinderX";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual float getRadius() const
|
virtual btScalar getRadius() const
|
||||||
{
|
{
|
||||||
return getHalfExtents().getY();
|
return getHalfExtents().getY();
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ public:
|
|||||||
return "CylinderZ";
|
return "CylinderZ";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual float getRadius() const
|
virtual btScalar getRadius() const
|
||||||
{
|
{
|
||||||
return getHalfExtents().getX();
|
return getHalfExtents().getX();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
|
|
||||||
btHeightfieldTerrainShape::btHeightfieldTerrainShape()
|
btHeightfieldTerrainShape::btHeightfieldTerrainShape()
|
||||||
:m_localScaling(0.f,0.f,0.f)
|
:m_localScaling(btScalar(0.),btScalar(0.),btScalar(0.))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,8 +32,8 @@ btHeightfieldTerrainShape::~btHeightfieldTerrainShape()
|
|||||||
|
|
||||||
void btHeightfieldTerrainShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
|
void btHeightfieldTerrainShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
|
||||||
{
|
{
|
||||||
aabbMin.setValue(-1e30f,-1e30f,-1e30f);
|
aabbMin.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
|
||||||
aabbMax.setValue(1e30f,1e30f,1e30f);
|
aabbMax.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,9 +43,9 @@ void btHeightfieldTerrainShape::getAabb(const btTransform& t,btVector3& aabbMin,
|
|||||||
void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
|
void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
|
||||||
{
|
{
|
||||||
|
|
||||||
btVector3 halfExtents = (aabbMax - aabbMin) * 0.5f;
|
btVector3 halfExtents = (aabbMax - aabbMin) * btScalar(0.5);
|
||||||
btScalar radius = halfExtents.length();
|
btScalar radius = halfExtents.length();
|
||||||
btVector3 center = (aabbMax + aabbMin) * 0.5f;
|
btVector3 center = (aabbMax + aabbMin) * btScalar(0.5);
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
//this is where the triangles are generated, given AABB and plane equation (normal/constant)
|
//this is where the triangles are generated, given AABB and plane equation (normal/constant)
|
||||||
@@ -79,7 +79,7 @@ void btHeightfieldTerrainShape::calculateLocalInertia(btScalar mass,btVector3& i
|
|||||||
{
|
{
|
||||||
//moving concave objects not supported
|
//moving concave objects not supported
|
||||||
|
|
||||||
inertia.setValue(0.f,0.f,0.f);
|
inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
}
|
}
|
||||||
|
|
||||||
void btHeightfieldTerrainShape::setLocalScaling(const btVector3& scaling)
|
void btHeightfieldTerrainShape::setLocalScaling(const btVector3& scaling)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void btMinkowskiSumShape::batchedUnitVectorGetSupportingVertexWithoutMargin(cons
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
float btMinkowskiSumShape::getMargin() const
|
btScalar btMinkowskiSumShape::getMargin() const
|
||||||
{
|
{
|
||||||
return m_shapeA->getMargin() + m_shapeB->getMargin();
|
return m_shapeA->getMargin() + m_shapeB->getMargin();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public:
|
|||||||
|
|
||||||
virtual int getShapeType() const { return MINKOWSKI_SUM_SHAPE_PROXYTYPE; }
|
virtual int getShapeType() const { return MINKOWSKI_SUM_SHAPE_PROXYTYPE; }
|
||||||
|
|
||||||
virtual float getMargin() const;
|
virtual btScalar getMargin() const;
|
||||||
|
|
||||||
const btConvexShape* getShapeA() const { return m_shapeA;}
|
const btConvexShape* getShapeA() const { return m_shapeA;}
|
||||||
const btConvexShape* getShapeB() const { return m_shapeB;}
|
const btConvexShape* getShapeB() const { return m_shapeB;}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ subject to the following restrictions:
|
|||||||
btMultiSphereShape::btMultiSphereShape (const btVector3& inertiaHalfExtents,const btVector3* positions,const btScalar* radi,int numSpheres)
|
btMultiSphereShape::btMultiSphereShape (const btVector3& inertiaHalfExtents,const btVector3* positions,const btScalar* radi,int numSpheres)
|
||||||
:m_inertiaHalfExtents(inertiaHalfExtents)
|
:m_inertiaHalfExtents(inertiaHalfExtents)
|
||||||
{
|
{
|
||||||
float startMargin = 1e30f;
|
btScalar startMargin = btScalar(1e30);
|
||||||
|
|
||||||
m_numSpheres = numSpheres;
|
m_numSpheres = numSpheres;
|
||||||
for (int i=0;i<m_numSpheres;i++)
|
for (int i=0;i<m_numSpheres;i++)
|
||||||
@@ -42,17 +42,17 @@ btMultiSphereShape::btMultiSphereShape (const btVector3& inertiaHalfExtents,cons
|
|||||||
int i;
|
int i;
|
||||||
btVector3 supVec(0,0,0);
|
btVector3 supVec(0,0,0);
|
||||||
|
|
||||||
btScalar maxDot(-1e30f);
|
btScalar maxDot(btScalar(-1e30));
|
||||||
|
|
||||||
|
|
||||||
btVector3 vec = vec0;
|
btVector3 vec = vec0;
|
||||||
btScalar lenSqr = vec.length2();
|
btScalar lenSqr = vec.length2();
|
||||||
if (lenSqr < 0.0001f)
|
if (lenSqr < btScalar(0.0001))
|
||||||
{
|
{
|
||||||
vec.setValue(1,0,0);
|
vec.setValue(1,0,0);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
float rlen = 1.f / btSqrt(lenSqr );
|
btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
|
||||||
vec *= rlen;
|
vec *= rlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ btMultiSphereShape::btMultiSphereShape (const btVector3& inertiaHalfExtents,cons
|
|||||||
|
|
||||||
for (int j=0;j<numVectors;j++)
|
for (int j=0;j<numVectors;j++)
|
||||||
{
|
{
|
||||||
btScalar maxDot(-1e30f);
|
btScalar maxDot(btScalar(-1e30));
|
||||||
|
|
||||||
const btVector3& vec = vectors[j];
|
const btVector3& vec = vectors[j];
|
||||||
|
|
||||||
@@ -126,17 +126,17 @@ void btMultiSphereShape::calculateLocalInertia(btScalar mass,btVector3& inertia)
|
|||||||
|
|
||||||
// getAabb(ident,aabbMin,aabbMax);
|
// getAabb(ident,aabbMin,aabbMax);
|
||||||
|
|
||||||
btVector3 halfExtents = m_inertiaHalfExtents;//(aabbMax - aabbMin)* 0.5f;
|
btVector3 halfExtents = m_inertiaHalfExtents;//(aabbMax - aabbMin)* btScalar(0.5);
|
||||||
|
|
||||||
float margin = CONVEX_DISTANCE_MARGIN;
|
btScalar margin = CONVEX_DISTANCE_MARGIN;
|
||||||
|
|
||||||
btScalar lx=2.f*(halfExtents[0]+margin);
|
btScalar lx=btScalar(2.)*(halfExtents[0]+margin);
|
||||||
btScalar ly=2.f*(halfExtents[1]+margin);
|
btScalar ly=btScalar(2.)*(halfExtents[1]+margin);
|
||||||
btScalar lz=2.f*(halfExtents[2]+margin);
|
btScalar lz=btScalar(2.)*(halfExtents[2]+margin);
|
||||||
const btScalar x2 = lx*lx;
|
const btScalar x2 = lx*lx;
|
||||||
const btScalar y2 = ly*ly;
|
const btScalar y2 = ly*ly;
|
||||||
const btScalar z2 = lz*lz;
|
const btScalar z2 = lz*lz;
|
||||||
const btScalar scaledmass = mass * 0.08333333f;
|
const btScalar scaledmass = mass * btScalar(.08333333);
|
||||||
|
|
||||||
inertia[0] = scaledmass * (y2+z2);
|
inertia[0] = scaledmass * (y2+z2);
|
||||||
inertia[1] = scaledmass * (x2+z2);
|
inertia[1] = scaledmass * (x2+z2);
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ void btOptimizedBvh::build(btStridingMeshInterface* triangles)
|
|||||||
{
|
{
|
||||||
|
|
||||||
btOptimizedBvhNode node;
|
btOptimizedBvhNode node;
|
||||||
node.m_aabbMin = btVector3(1e30f,1e30f,1e30f);
|
node.m_aabbMin = btVector3(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
node.m_aabbMax = btVector3(-1e30f,-1e30f,-1e30f);
|
node.m_aabbMax = btVector3(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
|
||||||
node.m_aabbMin.setMin(triangle[0]);
|
node.m_aabbMin.setMin(triangle[0]);
|
||||||
node.m_aabbMax.setMax(triangle[0]);
|
node.m_aabbMax.setMax(triangle[0]);
|
||||||
node.m_aabbMin.setMin(triangle[1]);
|
node.m_aabbMin.setMin(triangle[1]);
|
||||||
@@ -73,8 +73,8 @@ void btOptimizedBvh::build(btStridingMeshInterface* triangles)
|
|||||||
|
|
||||||
NodeTriangleCallback callback(m_leafNodes);
|
NodeTriangleCallback callback(m_leafNodes);
|
||||||
|
|
||||||
btVector3 aabbMin(-1e30f,-1e30f,-1e30f);
|
btVector3 aabbMin(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
|
||||||
btVector3 aabbMax(1e30f,1e30f,1e30f);
|
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
|
|
||||||
triangles->InternalProcessAllTriangles(&callback,aabbMin,aabbMax);
|
triangles->InternalProcessAllTriangles(&callback,aabbMin,aabbMax);
|
||||||
|
|
||||||
@@ -118,8 +118,8 @@ btOptimizedBvhNode* btOptimizedBvh::buildTree (NodeArray& leafNodes,int startInd
|
|||||||
|
|
||||||
internalNode = &m_contiguousNodes[m_curNodeIndex++];
|
internalNode = &m_contiguousNodes[m_curNodeIndex++];
|
||||||
|
|
||||||
internalNode->m_aabbMax.setValue(-1e30f,-1e30f,-1e30f);
|
internalNode->m_aabbMax.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
|
||||||
internalNode->m_aabbMin.setValue(1e30f,1e30f,1e30f);
|
internalNode->m_aabbMin.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
|
|
||||||
for (i=startIndex;i<endIndex;i++)
|
for (i=startIndex;i<endIndex;i++)
|
||||||
{
|
{
|
||||||
@@ -142,22 +142,22 @@ int btOptimizedBvh::sortAndCalcSplittingIndex(NodeArray& leafNodes,int startInde
|
|||||||
int i;
|
int i;
|
||||||
int splitIndex =startIndex;
|
int splitIndex =startIndex;
|
||||||
int numIndices = endIndex - startIndex;
|
int numIndices = endIndex - startIndex;
|
||||||
float splitValue;
|
btScalar splitValue;
|
||||||
|
|
||||||
btVector3 means(0.f,0.f,0.f);
|
btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
for (i=startIndex;i<endIndex;i++)
|
for (i=startIndex;i<endIndex;i++)
|
||||||
{
|
{
|
||||||
btVector3 center = 0.5f*(leafNodes[i].m_aabbMax+leafNodes[i].m_aabbMin);
|
btVector3 center = btScalar(0.5)*(leafNodes[i].m_aabbMax+leafNodes[i].m_aabbMin);
|
||||||
means+=center;
|
means+=center;
|
||||||
}
|
}
|
||||||
means *= (1.f/(float)numIndices);
|
means *= (btScalar(1.)/(btScalar)numIndices);
|
||||||
|
|
||||||
splitValue = means[splitAxis];
|
splitValue = means[splitAxis];
|
||||||
|
|
||||||
//sort leafNodes so all values larger then splitValue comes first, and smaller values start from 'splitIndex'.
|
//sort leafNodes so all values larger then splitValue comes first, and smaller values start from 'splitIndex'.
|
||||||
for (i=startIndex;i<endIndex;i++)
|
for (i=startIndex;i<endIndex;i++)
|
||||||
{
|
{
|
||||||
btVector3 center = 0.5f*(leafNodes[i].m_aabbMax+leafNodes[i].m_aabbMin);
|
btVector3 center = btScalar(0.5)*(leafNodes[i].m_aabbMax+leafNodes[i].m_aabbMin);
|
||||||
if (center[splitAxis] > splitValue)
|
if (center[splitAxis] > splitValue)
|
||||||
{
|
{
|
||||||
//swap
|
//swap
|
||||||
@@ -179,25 +179,25 @@ int btOptimizedBvh::calcSplittingAxis(NodeArray& leafNodes,int startIndex,int en
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
btVector3 means(0.f,0.f,0.f);
|
btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
btVector3 variance(0.f,0.f,0.f);
|
btVector3 variance(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
int numIndices = endIndex-startIndex;
|
int numIndices = endIndex-startIndex;
|
||||||
|
|
||||||
for (i=startIndex;i<endIndex;i++)
|
for (i=startIndex;i<endIndex;i++)
|
||||||
{
|
{
|
||||||
btVector3 center = 0.5f*(leafNodes[i].m_aabbMax+leafNodes[i].m_aabbMin);
|
btVector3 center = btScalar(0.5)*(leafNodes[i].m_aabbMax+leafNodes[i].m_aabbMin);
|
||||||
means+=center;
|
means+=center;
|
||||||
}
|
}
|
||||||
means *= (1.f/(float)numIndices);
|
means *= (btScalar(1.)/(btScalar)numIndices);
|
||||||
|
|
||||||
for (i=startIndex;i<endIndex;i++)
|
for (i=startIndex;i<endIndex;i++)
|
||||||
{
|
{
|
||||||
btVector3 center = 0.5f*(leafNodes[i].m_aabbMax+leafNodes[i].m_aabbMin);
|
btVector3 center = btScalar(0.5)*(leafNodes[i].m_aabbMax+leafNodes[i].m_aabbMin);
|
||||||
btVector3 diff2 = center-means;
|
btVector3 diff2 = center-means;
|
||||||
diff2 = diff2 * diff2;
|
diff2 = diff2 * diff2;
|
||||||
variance += diff2;
|
variance += diff2;
|
||||||
}
|
}
|
||||||
variance *= (1.f/ ((float)numIndices-1) );
|
variance *= (btScalar(1.)/ ((btScalar)numIndices-1) );
|
||||||
|
|
||||||
return variance.maxAxis();
|
return variance.maxAxis();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,16 +28,16 @@ btVector3 btPolyhedralConvexShape::localGetSupportingVertexWithoutMargin(const b
|
|||||||
int i;
|
int i;
|
||||||
btVector3 supVec(0,0,0);
|
btVector3 supVec(0,0,0);
|
||||||
|
|
||||||
btScalar maxDot(-1e30f);
|
btScalar maxDot(btScalar(-1e30));
|
||||||
|
|
||||||
btVector3 vec = vec0;
|
btVector3 vec = vec0;
|
||||||
btScalar lenSqr = vec.length2();
|
btScalar lenSqr = vec.length2();
|
||||||
if (lenSqr < 0.0001f)
|
if (lenSqr < btScalar(0.0001))
|
||||||
{
|
{
|
||||||
vec.setValue(1,0,0);
|
vec.setValue(1,0,0);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
float rlen = 1.f / btSqrt(lenSqr );
|
btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
|
||||||
vec *= rlen;
|
vec *= rlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ void btPolyhedralConvexShape::batchedUnitVectorGetSupportingVertexWithoutMargin(
|
|||||||
|
|
||||||
for (i=0;i<numVectors;i++)
|
for (i=0;i<numVectors;i++)
|
||||||
{
|
{
|
||||||
supportVerticesOut[i][3] = -1e30f;
|
supportVerticesOut[i][3] = btScalar(-1e30);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j=0;j<numVectors;j++)
|
for (int j=0;j<numVectors;j++)
|
||||||
@@ -96,21 +96,21 @@ void btPolyhedralConvexShape::calculateLocalInertia(btScalar mass,btVector3& ine
|
|||||||
{
|
{
|
||||||
//not yet, return box inertia
|
//not yet, return box inertia
|
||||||
|
|
||||||
float margin = getMargin();
|
btScalar margin = getMargin();
|
||||||
|
|
||||||
btTransform ident;
|
btTransform ident;
|
||||||
ident.setIdentity();
|
ident.setIdentity();
|
||||||
btVector3 aabbMin,aabbMax;
|
btVector3 aabbMin,aabbMax;
|
||||||
getAabb(ident,aabbMin,aabbMax);
|
getAabb(ident,aabbMin,aabbMax);
|
||||||
btVector3 halfExtents = (aabbMax-aabbMin)*0.5f;
|
btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
|
||||||
|
|
||||||
btScalar lx=2.f*(halfExtents.x()+margin);
|
btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
|
||||||
btScalar ly=2.f*(halfExtents.y()+margin);
|
btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
|
||||||
btScalar lz=2.f*(halfExtents.z()+margin);
|
btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
|
||||||
const btScalar x2 = lx*lx;
|
const btScalar x2 = lx*lx;
|
||||||
const btScalar y2 = ly*ly;
|
const btScalar y2 = ly*ly;
|
||||||
const btScalar z2 = lz*lz;
|
const btScalar z2 = lz*lz;
|
||||||
const btScalar scaledmass = mass * 0.08333333f;
|
const btScalar scaledmass = mass * btScalar(0.08333333);
|
||||||
|
|
||||||
inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
|
inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
|
||||||
|
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ btSphereShape ::btSphereShape (btScalar radius)
|
|||||||
|
|
||||||
btVector3 btSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
|
btVector3 btSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
|
||||||
{
|
{
|
||||||
return btVector3(0.f,0.f,0.f);
|
return btVector3(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
}
|
}
|
||||||
|
|
||||||
void btSphereShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
|
void btSphereShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
|
||||||
{
|
{
|
||||||
for (int i=0;i<numVectors;i++)
|
for (int i=0;i<numVectors;i++)
|
||||||
{
|
{
|
||||||
supportVerticesOut[i].setValue(0.f,0.f,0.f);
|
supportVerticesOut[i].setValue(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ btVector3 btSphereShape::localGetSupportingVertex(const btVector3& vec)const
|
|||||||
btVector3 vecnorm = vec;
|
btVector3 vecnorm = vec;
|
||||||
if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
|
if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
|
||||||
{
|
{
|
||||||
vecnorm.setValue(-1.f,-1.f,-1.f);
|
vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
|
||||||
}
|
}
|
||||||
vecnorm.normalize();
|
vecnorm.normalize();
|
||||||
supVertex+= getMargin() * vecnorm;
|
supVertex+= getMargin() * vecnorm;
|
||||||
@@ -67,7 +67,7 @@ void btSphereShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& a
|
|||||||
|
|
||||||
void btSphereShape::calculateLocalInertia(btScalar mass,btVector3& inertia)
|
void btSphereShape::calculateLocalInertia(btScalar mass,btVector3& inertia)
|
||||||
{
|
{
|
||||||
btScalar elem = 0.4f * mass * getMargin()*getMargin();
|
btScalar elem = btScalar(0.4) * mass * getMargin()*getMargin();
|
||||||
inertia[0] = inertia[1] = inertia[2] = elem;
|
inertia[0] = inertia[1] = inertia[2] = elem;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,11 +45,11 @@ public:
|
|||||||
//debugging
|
//debugging
|
||||||
virtual char* getName()const {return "SPHERE";}
|
virtual char* getName()const {return "SPHERE";}
|
||||||
|
|
||||||
virtual void setMargin(float margin)
|
virtual void setMargin(btScalar margin)
|
||||||
{
|
{
|
||||||
btConvexShape::setMargin(margin);
|
btConvexShape::setMargin(margin);
|
||||||
}
|
}
|
||||||
virtual float getMargin() const
|
virtual btScalar getMargin() const
|
||||||
{
|
{
|
||||||
//to improve gjk behaviour, use radius+margin as the full margin, so never get into the penetration case
|
//to improve gjk behaviour, use radius+margin as the full margin, so never get into the penetration case
|
||||||
//this means, non-uniform scaling is not supported anymore
|
//this means, non-uniform scaling is not supported anymore
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ subject to the following restrictions:
|
|||||||
btStaticPlaneShape::btStaticPlaneShape(const btVector3& planeNormal,btScalar planeConstant)
|
btStaticPlaneShape::btStaticPlaneShape(const btVector3& planeNormal,btScalar planeConstant)
|
||||||
:m_planeNormal(planeNormal),
|
:m_planeNormal(planeNormal),
|
||||||
m_planeConstant(planeConstant),
|
m_planeConstant(planeConstant),
|
||||||
m_localScaling(0.f,0.f,0.f)
|
m_localScaling(btScalar(0.),btScalar(0.),btScalar(0.))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ btStaticPlaneShape::~btStaticPlaneShape()
|
|||||||
|
|
||||||
void btStaticPlaneShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
|
void btStaticPlaneShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
|
||||||
{
|
{
|
||||||
btVector3 infvec (1e30f,1e30f,1e30f);
|
btVector3 infvec (btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
|
|
||||||
btVector3 center = m_planeNormal*m_planeConstant;
|
btVector3 center = m_planeNormal*m_planeConstant;
|
||||||
aabbMin = center + infvec*m_planeNormal;
|
aabbMin = center + infvec*m_planeNormal;
|
||||||
@@ -42,8 +42,8 @@ void btStaticPlaneShape::getAabb(const btTransform& t,btVector3& aabbMin,btVecto
|
|||||||
aabbMin.setMin(center - infvec*m_planeNormal);
|
aabbMin.setMin(center - infvec*m_planeNormal);
|
||||||
aabbMax.setMax(center - infvec*m_planeNormal);
|
aabbMax.setMax(center - infvec*m_planeNormal);
|
||||||
|
|
||||||
aabbMin.setValue(-1e30f,-1e30f,-1e30f);
|
aabbMin.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
|
||||||
aabbMax.setValue(1e30f,1e30f,1e30f);
|
aabbMax.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,9 +53,9 @@ void btStaticPlaneShape::getAabb(const btTransform& t,btVector3& aabbMin,btVecto
|
|||||||
void btStaticPlaneShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
|
void btStaticPlaneShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
|
||||||
{
|
{
|
||||||
|
|
||||||
btVector3 halfExtents = (aabbMax - aabbMin) * 0.5f;
|
btVector3 halfExtents = (aabbMax - aabbMin) * btScalar(0.5);
|
||||||
btScalar radius = halfExtents.length();
|
btScalar radius = halfExtents.length();
|
||||||
btVector3 center = (aabbMax + aabbMin) * 0.5f;
|
btVector3 center = (aabbMax + aabbMin) * btScalar(0.5);
|
||||||
|
|
||||||
//this is where the triangles are generated, given AABB and plane equation (normal/constant)
|
//this is where the triangles are generated, given AABB and plane equation (normal/constant)
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ void btStaticPlaneShape::calculateLocalInertia(btScalar mass,btVector3& inertia)
|
|||||||
{
|
{
|
||||||
//moving concave objects not supported
|
//moving concave objects not supported
|
||||||
|
|
||||||
inertia.setValue(0.f,0.f,0.f);
|
inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
}
|
}
|
||||||
|
|
||||||
void btStaticPlaneShape::setLocalScaling(const btVector3& scaling)
|
void btStaticPlaneShape::setLocalScaling(const btVector3& scaling)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ void btStridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
|
|||||||
int stride,numverts,numtriangles;
|
int stride,numverts,numtriangles;
|
||||||
int gfxindex;
|
int gfxindex;
|
||||||
btVector3 triangle[3];
|
btVector3 triangle[3];
|
||||||
float* graphicsbase;
|
btScalar* graphicsbase;
|
||||||
|
|
||||||
btVector3 meshScaling = getScaling();
|
btVector3 meshScaling = getScaling();
|
||||||
|
|
||||||
@@ -50,11 +50,11 @@ void btStridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
|
|||||||
for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
|
for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
|
||||||
{
|
{
|
||||||
int* tri_indices= (int*)(indexbase+gfxindex*indexstride);
|
int* tri_indices= (int*)(indexbase+gfxindex*indexstride);
|
||||||
graphicsbase = (float*)(vertexbase+tri_indices[0]*stride);
|
graphicsbase = (btScalar*)(vertexbase+tri_indices[0]*stride);
|
||||||
triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
|
triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
|
||||||
graphicsbase = (float*)(vertexbase+tri_indices[1]*stride);
|
graphicsbase = (btScalar*)(vertexbase+tri_indices[1]*stride);
|
||||||
triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ());
|
triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ());
|
||||||
graphicsbase = (float*)(vertexbase+tri_indices[2]*stride);
|
graphicsbase = (btScalar*)(vertexbase+tri_indices[2]*stride);
|
||||||
triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ());
|
triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ());
|
||||||
callback->internalProcessTriangleIndex(triangle,part,gfxindex);
|
callback->internalProcessTriangleIndex(triangle,part,gfxindex);
|
||||||
}
|
}
|
||||||
@@ -65,11 +65,11 @@ void btStridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
|
|||||||
for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
|
for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
|
||||||
{
|
{
|
||||||
short int* tri_indices= (short int*)(indexbase+gfxindex*indexstride);
|
short int* tri_indices= (short int*)(indexbase+gfxindex*indexstride);
|
||||||
graphicsbase = (float*)(vertexbase+tri_indices[0]*stride);
|
graphicsbase = (btScalar*)(vertexbase+tri_indices[0]*stride);
|
||||||
triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
|
triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
|
||||||
graphicsbase = (float*)(vertexbase+tri_indices[1]*stride);
|
graphicsbase = (btScalar*)(vertexbase+tri_indices[1]*stride);
|
||||||
triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ());
|
triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ());
|
||||||
graphicsbase = (float*)(vertexbase+tri_indices[2]*stride);
|
graphicsbase = (btScalar*)(vertexbase+tri_indices[2]*stride);
|
||||||
triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ());
|
triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ());
|
||||||
callback->internalProcessTriangleIndex(triangle,part,gfxindex);
|
callback->internalProcessTriangleIndex(triangle,part,gfxindex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class btStridingMeshInterface
|
|||||||
btVector3 m_scaling;
|
btVector3 m_scaling;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
btStridingMeshInterface() :m_scaling(1.f,1.f,1.f)
|
btStridingMeshInterface() :m_scaling(btScalar(1.),btScalar(1.),btScalar(1.))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include "btTriangleIndexVertexArray.h"
|
#include "btTriangleIndexVertexArray.h"
|
||||||
|
|
||||||
btTriangleIndexVertexArray::btTriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,float* vertexBase,int vertexStride)
|
btTriangleIndexVertexArray::btTriangleIndexVertexArray(int numTriangles,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride)
|
||||||
{
|
{
|
||||||
btIndexedMesh mesh;
|
btIndexedMesh mesh;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ struct btIndexedMesh
|
|||||||
int* m_triangleIndexBase;
|
int* m_triangleIndexBase;
|
||||||
int m_triangleIndexStride;
|
int m_triangleIndexStride;
|
||||||
int m_numVertices;
|
int m_numVertices;
|
||||||
float* m_vertexBase;
|
btScalar* m_vertexBase;
|
||||||
int m_vertexStride;
|
int m_vertexStride;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//just to be backwards compatible
|
//just to be backwards compatible
|
||||||
btTriangleIndexVertexArray(int numTriangleIndices,int* triangleIndexBase,int triangleIndexStride,int numVertices,float* vertexBase,int vertexStride);
|
btTriangleIndexVertexArray(int numTriangleIndices,int* triangleIndexBase,int triangleIndexStride,int numVertices,btScalar* vertexBase,int vertexStride);
|
||||||
|
|
||||||
void addIndexedMesh(const btIndexedMesh& mesh)
|
void addIndexedMesh(const btIndexedMesh& mesh)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ btTriangleMeshShape::~btTriangleMeshShape()
|
|||||||
void btTriangleMeshShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
|
void btTriangleMeshShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
|
||||||
{
|
{
|
||||||
|
|
||||||
btVector3 localHalfExtents = 0.5f*(m_localAabbMax-m_localAabbMin);
|
btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin);
|
||||||
btVector3 localCenter = 0.5f*(m_localAabbMax+m_localAabbMin);
|
btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin);
|
||||||
|
|
||||||
btMatrix3x3 abs_b = trans.getBasis().absolute();
|
btMatrix3x3 abs_b = trans.getBasis().absolute();
|
||||||
|
|
||||||
@@ -62,11 +62,11 @@ void btTriangleMeshShape::recalcLocalAabb()
|
|||||||
{
|
{
|
||||||
for (int i=0;i<3;i++)
|
for (int i=0;i<3;i++)
|
||||||
{
|
{
|
||||||
btVector3 vec(0.f,0.f,0.f);
|
btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
vec[i] = 1.f;
|
vec[i] = btScalar(1.);
|
||||||
btVector3 tmp = localGetSupportingVertex(vec);
|
btVector3 tmp = localGetSupportingVertex(vec);
|
||||||
m_localAabbMax[i] = tmp[i]+m_collisionMargin;
|
m_localAabbMax[i] = tmp[i]+m_collisionMargin;
|
||||||
vec[i] = -1.f;
|
vec[i] = btScalar(-1.);
|
||||||
tmp = localGetSupportingVertex(vec);
|
tmp = localGetSupportingVertex(vec);
|
||||||
m_localAabbMin[i] = tmp[i]-m_collisionMargin;
|
m_localAabbMin[i] = tmp[i]-m_collisionMargin;
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ public:
|
|||||||
btVector3 m_supportVecLocal;
|
btVector3 m_supportVecLocal;
|
||||||
|
|
||||||
SupportVertexCallback(const btVector3& supportVecWorld,const btTransform& trans)
|
SupportVertexCallback(const btVector3& supportVecWorld,const btTransform& trans)
|
||||||
: m_supportVertexLocal(0.f,0.f,0.f), m_worldTrans(trans) ,m_maxDot(-1e30f)
|
: m_supportVertexLocal(btScalar(0.),btScalar(0.),btScalar(0.)), m_worldTrans(trans) ,m_maxDot(btScalar(-1e30))
|
||||||
|
|
||||||
{
|
{
|
||||||
m_supportVecLocal = supportVecWorld * m_worldTrans.getBasis();
|
m_supportVecLocal = supportVecWorld * m_worldTrans.getBasis();
|
||||||
@@ -178,7 +178,7 @@ void btTriangleMeshShape::calculateLocalInertia(btScalar mass,btVector3& inertia
|
|||||||
{
|
{
|
||||||
//moving concave objects not supported
|
//moving concave objects not supported
|
||||||
assert(0);
|
assert(0);
|
||||||
inertia.setValue(0.f,0.f,0.f);
|
inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ btVector3 btTriangleMeshShape::localGetSupportingVertex(const btVector3& vec) co
|
|||||||
|
|
||||||
SupportVertexCallback supportCallback(vec,ident);
|
SupportVertexCallback supportCallback(vec,ident);
|
||||||
|
|
||||||
btVector3 aabbMax(1e30f,1e30f,1e30f);
|
btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
|
||||||
|
|
||||||
processAllTriangles(&supportCallback,-aabbMax,aabbMax);
|
processAllTriangles(&supportCallback,-aabbMax,aabbMax);
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public:
|
|||||||
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia)
|
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia)
|
||||||
{
|
{
|
||||||
btAssert(0);
|
btAssert(0);
|
||||||
inertia.setValue(0.f,0.f,0.f);
|
inertia.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isInside(const btPoint3& pt,btScalar tolerance) const
|
virtual bool isInside(const btPoint3& pt,btScalar tolerance) const
|
||||||
@@ -166,7 +166,7 @@ public:
|
|||||||
{
|
{
|
||||||
calcNormal(penetrationVector);
|
calcNormal(penetrationVector);
|
||||||
if (index)
|
if (index)
|
||||||
penetrationVector *= -1.f;
|
penetrationVector *= btScalar(-1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,28 +49,28 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
|
|||||||
|
|
||||||
/// compute linear and angular velocity for this interval, to interpolate
|
/// compute linear and angular velocity for this interval, to interpolate
|
||||||
btVector3 linVelA,angVelA,linVelB,angVelB;
|
btVector3 linVelA,angVelA,linVelB,angVelB;
|
||||||
btTransformUtil::calculateVelocity(fromA,toA,1.f,linVelA,angVelA);
|
btTransformUtil::calculateVelocity(fromA,toA,btScalar(1.),linVelA,angVelA);
|
||||||
btTransformUtil::calculateVelocity(fromB,toB,1.f,linVelB,angVelB);
|
btTransformUtil::calculateVelocity(fromB,toB,btScalar(1.),linVelB,angVelB);
|
||||||
|
|
||||||
btScalar boundingRadiusA = m_convexA->getAngularMotionDisc();
|
btScalar boundingRadiusA = m_convexA->getAngularMotionDisc();
|
||||||
btScalar boundingRadiusB = m_convexB->getAngularMotionDisc();
|
btScalar boundingRadiusB = m_convexB->getAngularMotionDisc();
|
||||||
|
|
||||||
btScalar maxAngularProjectedVelocity = angVelA.length() * boundingRadiusA + angVelB.length() * boundingRadiusB;
|
btScalar maxAngularProjectedVelocity = angVelA.length() * boundingRadiusA + angVelB.length() * boundingRadiusB;
|
||||||
|
|
||||||
float radius = 0.001f;
|
btScalar radius = btScalar(0.001);
|
||||||
|
|
||||||
btScalar lambda = 0.f;
|
btScalar lambda = btScalar(0.);
|
||||||
btVector3 v(1,0,0);
|
btVector3 v(1,0,0);
|
||||||
|
|
||||||
int maxIter = MAX_ITERATIONS;
|
int maxIter = MAX_ITERATIONS;
|
||||||
|
|
||||||
btVector3 n;
|
btVector3 n;
|
||||||
n.setValue(0.f,0.f,0.f);
|
n.setValue(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
bool hasResult = false;
|
bool hasResult = false;
|
||||||
btVector3 c;
|
btVector3 c;
|
||||||
|
|
||||||
float lastLambda = lambda;
|
btScalar lastLambda = lambda;
|
||||||
//float epsilon = 0.001f;
|
//btScalar epsilon = btScalar(0.001);
|
||||||
|
|
||||||
int numIter = 0;
|
int numIter = 0;
|
||||||
//first solution, using GJK
|
//first solution, using GJK
|
||||||
@@ -79,8 +79,8 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
|
|||||||
btTransform identityTrans;
|
btTransform identityTrans;
|
||||||
identityTrans.setIdentity();
|
identityTrans.setIdentity();
|
||||||
|
|
||||||
btSphereShape raySphere(0.0f);
|
btSphereShape raySphere(btScalar(0.0));
|
||||||
raySphere.setMargin(0.f);
|
raySphere.setMargin(btScalar(0.));
|
||||||
|
|
||||||
|
|
||||||
// result.drawCoordSystem(sphereTr);
|
// result.drawCoordSystem(sphereTr);
|
||||||
@@ -116,23 +116,23 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
|
|||||||
if (numIter > maxIter)
|
if (numIter > maxIter)
|
||||||
return false; //todo: report a failure
|
return false; //todo: report a failure
|
||||||
|
|
||||||
float dLambda = 0.f;
|
btScalar dLambda = btScalar(0.);
|
||||||
|
|
||||||
//calculate safe moving fraction from distance / (linear+rotational velocity)
|
//calculate safe moving fraction from distance / (linear+rotational velocity)
|
||||||
|
|
||||||
//float clippedDist = GEN_min(angularConservativeRadius,dist);
|
//btScalar clippedDist = GEN_min(angularConservativeRadius,dist);
|
||||||
//float clippedDist = dist;
|
//btScalar clippedDist = dist;
|
||||||
|
|
||||||
float projectedLinearVelocity = (linVelB-linVelA).dot(n);
|
btScalar projectedLinearVelocity = (linVelB-linVelA).dot(n);
|
||||||
|
|
||||||
dLambda = dist / (projectedLinearVelocity+ maxAngularProjectedVelocity);
|
dLambda = dist / (projectedLinearVelocity+ maxAngularProjectedVelocity);
|
||||||
|
|
||||||
lambda = lambda + dLambda;
|
lambda = lambda + dLambda;
|
||||||
|
|
||||||
if (lambda > 1.f)
|
if (lambda > btScalar(1.))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (lambda < 0.f)
|
if (lambda < btScalar(0.))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//todo: next check with relative epsilon
|
//todo: next check with relative epsilon
|
||||||
@@ -159,7 +159,7 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
|
|||||||
gjk.getClosestPoints(input,pointCollector,0);
|
gjk.getClosestPoints(input,pointCollector,0);
|
||||||
if (pointCollector.m_hasResult)
|
if (pointCollector.m_hasResult)
|
||||||
{
|
{
|
||||||
if (pointCollector.m_distance < 0.f)
|
if (pointCollector.m_distance < btScalar(0.))
|
||||||
{
|
{
|
||||||
//degenerate ?!
|
//degenerate ?!
|
||||||
result.m_fraction = lastLambda;
|
result.m_fraction = lastLambda;
|
||||||
@@ -188,9 +188,9 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
|
|||||||
//todo:
|
//todo:
|
||||||
//if movement away from normal, discard result
|
//if movement away from normal, discard result
|
||||||
btVector3 move = transBLocalTo.getOrigin() - transBLocalFrom.getOrigin();
|
btVector3 move = transBLocalTo.getOrigin() - transBLocalFrom.getOrigin();
|
||||||
if (result.m_fraction < 1.f)
|
if (result.m_fraction < btScalar(1.))
|
||||||
{
|
{
|
||||||
if (move.dot(result.m_normal) <= 0.f)
|
if (move.dot(result.m_normal) <= btScalar(0.))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
virtual void drawCoordSystem(const btTransform& trans) {}
|
virtual void drawCoordSystem(const btTransform& trans) {}
|
||||||
|
|
||||||
CastResult()
|
CastResult()
|
||||||
:m_fraction(1e30f),
|
:m_fraction(btScalar(1e30)),
|
||||||
m_debugDrawer(0)
|
m_debugDrawer(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ struct btDiscreteCollisionDetectorInterface
|
|||||||
|
|
||||||
///setShapeIdentifiers provides experimental support for per-triangle material / custom material combiner
|
///setShapeIdentifiers provides experimental support for per-triangle material / custom material combiner
|
||||||
virtual void setShapeIdentifiers(int partId0,int index0, int partId1,int index1)=0;
|
virtual void setShapeIdentifiers(int partId0,int index0, int partId1,int index1)=0;
|
||||||
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth)=0;
|
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ClosestPointInput
|
struct ClosestPointInput
|
||||||
{
|
{
|
||||||
ClosestPointInput()
|
ClosestPointInput()
|
||||||
:m_maximumDistanceSquared(1e30f),
|
:m_maximumDistanceSquared(btScalar(1e30)),
|
||||||
m_stackAlloc(0)
|
m_stackAlloc(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -69,13 +69,13 @@ struct btStorageResult : public btDiscreteCollisionDetectorInterface::Result
|
|||||||
btVector3 m_closestPointInB;
|
btVector3 m_closestPointInB;
|
||||||
btScalar m_distance; //negative means penetration !
|
btScalar m_distance; //negative means penetration !
|
||||||
|
|
||||||
btStorageResult() : m_distance(1e30f)
|
btStorageResult() : m_distance(btScalar(1e30))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
virtual ~btStorageResult() {};
|
virtual ~btStorageResult() {};
|
||||||
|
|
||||||
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth)
|
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
|
||||||
{
|
{
|
||||||
if (depth < m_distance)
|
if (depth < m_distance)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,9 +60,9 @@ bool btGjkConvexCast::calcTimeOfImpact(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
float radius = 0.01f;
|
btScalar radius = btScalar(0.01);
|
||||||
|
|
||||||
btScalar lambda = 0.f;
|
btScalar lambda = btScalar(0.);
|
||||||
btVector3 s = rayFromLocalA.getOrigin();
|
btVector3 s = rayFromLocalA.getOrigin();
|
||||||
btVector3 r = rayToLocalA.getOrigin()-rayFromLocalA.getOrigin();
|
btVector3 r = rayToLocalA.getOrigin()-rayFromLocalA.getOrigin();
|
||||||
btVector3 x = s;
|
btVector3 x = s;
|
||||||
@@ -71,7 +71,7 @@ bool btGjkConvexCast::calcTimeOfImpact(
|
|||||||
bool hasResult = false;
|
bool hasResult = false;
|
||||||
btVector3 c;
|
btVector3 c;
|
||||||
|
|
||||||
float lastLambda = lambda;
|
btScalar lastLambda = lambda;
|
||||||
|
|
||||||
//first solution, using GJK
|
//first solution, using GJK
|
||||||
|
|
||||||
@@ -81,8 +81,8 @@ bool btGjkConvexCast::calcTimeOfImpact(
|
|||||||
btTransform identityTrans;
|
btTransform identityTrans;
|
||||||
identityTrans.setIdentity();
|
identityTrans.setIdentity();
|
||||||
|
|
||||||
btSphereShape raySphere(0.0f);
|
btSphereShape raySphere(btScalar(0.0));
|
||||||
raySphere.setMargin(0.f);
|
raySphere.setMargin(btScalar(0.));
|
||||||
|
|
||||||
btTransform sphereTr;
|
btTransform sphereTr;
|
||||||
sphereTr.setIdentity();
|
sphereTr.setIdentity();
|
||||||
@@ -112,7 +112,7 @@ bool btGjkConvexCast::calcTimeOfImpact(
|
|||||||
if (dist < radius)
|
if (dist < radius)
|
||||||
{
|
{
|
||||||
//penetration
|
//penetration
|
||||||
lastLambda = 1.f;
|
lastLambda = btScalar(1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
//not close enough
|
//not close enough
|
||||||
@@ -143,7 +143,7 @@ bool btGjkConvexCast::calcTimeOfImpact(
|
|||||||
gjk.getClosestPoints(input,pointCollector,0);
|
gjk.getClosestPoints(input,pointCollector,0);
|
||||||
if (pointCollector.m_hasResult)
|
if (pointCollector.m_hasResult)
|
||||||
{
|
{
|
||||||
if (pointCollector.m_distance < 0.f)
|
if (pointCollector.m_distance < btScalar(0.))
|
||||||
{
|
{
|
||||||
//degeneracy, report a hit
|
//degeneracy, report a hit
|
||||||
result.m_fraction = lastLambda;
|
result.m_fraction = lastLambda;
|
||||||
@@ -160,7 +160,7 @@ bool btGjkConvexCast::calcTimeOfImpact(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastLambda < 1.f)
|
if (lastLambda < btScalar(1.))
|
||||||
{
|
{
|
||||||
|
|
||||||
result.m_fraction = lastLambda;
|
result.m_fraction = lastLambda;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& sim
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
const btScalar radialmargin(0.f);
|
const btScalar radialmargin(btScalar(0.));
|
||||||
|
|
||||||
btGjkEpaSolver::sResults results;
|
btGjkEpaSolver::sResults results;
|
||||||
if(btGjkEpaSolver::Collide( pConvexA,transformA,
|
if(btGjkEpaSolver::Collide( pConvexA,transformA,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ subject to the following restrictions:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//must be above the machine epsilon
|
//must be above the machine epsilon
|
||||||
#define REL_ERROR2 1.0e-6f
|
#define REL_ERROR2 btScalar(1.0e-6)
|
||||||
|
|
||||||
//temp globals, to improve GJK/EPA/penetration calculations
|
//temp globals, to improve GJK/EPA/penetration calculations
|
||||||
int gNumDeepPenetrationChecks = 0;
|
int gNumDeepPenetrationChecks = 0;
|
||||||
@@ -36,7 +36,7 @@ int gNumGjkChecks = 0;
|
|||||||
|
|
||||||
|
|
||||||
btGjkPairDetector::btGjkPairDetector(btConvexShape* objectA,btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver)
|
btGjkPairDetector::btGjkPairDetector(btConvexShape* objectA,btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver)
|
||||||
:m_cachedSeparatingAxis(0.f,0.f,1.f),
|
:m_cachedSeparatingAxis(btScalar(0.),btScalar(0.),btScalar(1.)),
|
||||||
m_penetrationDepthSolver(penetrationDepthSolver),
|
m_penetrationDepthSolver(penetrationDepthSolver),
|
||||||
m_simplexSolver(simplexSolver),
|
m_simplexSolver(simplexSolver),
|
||||||
m_minkowskiA(objectA),
|
m_minkowskiA(objectA),
|
||||||
@@ -49,25 +49,25 @@ m_catchDegeneracies(1)
|
|||||||
|
|
||||||
void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw)
|
void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw)
|
||||||
{
|
{
|
||||||
btScalar distance=0.f;
|
btScalar distance=btScalar(0.);
|
||||||
btVector3 normalInB(0.f,0.f,0.f);
|
btVector3 normalInB(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
btVector3 pointOnA,pointOnB;
|
btVector3 pointOnA,pointOnB;
|
||||||
btTransform localTransA = input.m_transformA;
|
btTransform localTransA = input.m_transformA;
|
||||||
btTransform localTransB = input.m_transformB;
|
btTransform localTransB = input.m_transformB;
|
||||||
btVector3 positionOffset = (localTransA.getOrigin() + localTransB.getOrigin()) * 0.5f;
|
btVector3 positionOffset = (localTransA.getOrigin() + localTransB.getOrigin()) * btScalar(0.5);
|
||||||
localTransA.getOrigin() -= positionOffset;
|
localTransA.getOrigin() -= positionOffset;
|
||||||
localTransB.getOrigin() -= positionOffset;
|
localTransB.getOrigin() -= positionOffset;
|
||||||
|
|
||||||
float marginA = m_minkowskiA->getMargin();
|
btScalar marginA = m_minkowskiA->getMargin();
|
||||||
float marginB = m_minkowskiB->getMargin();
|
btScalar marginB = m_minkowskiB->getMargin();
|
||||||
|
|
||||||
gNumGjkChecks++;
|
gNumGjkChecks++;
|
||||||
|
|
||||||
//for CCD we don't use margins
|
//for CCD we don't use margins
|
||||||
if (m_ignoreMargin)
|
if (m_ignoreMargin)
|
||||||
{
|
{
|
||||||
marginA = 0.f;
|
marginA = btScalar(0.);
|
||||||
marginB = 0.f;
|
marginB = btScalar(0.);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_curIter = 0;
|
m_curIter = 0;
|
||||||
@@ -83,7 +83,7 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
|
|||||||
|
|
||||||
{
|
{
|
||||||
btScalar squaredDistance = SIMD_INFINITY;
|
btScalar squaredDistance = SIMD_INFINITY;
|
||||||
btScalar delta = 0.f;
|
btScalar delta = btScalar(0.);
|
||||||
|
|
||||||
btScalar margin = marginA + marginB;
|
btScalar margin = marginA + marginB;
|
||||||
|
|
||||||
@@ -120,12 +120,12 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// are we getting any closer ?
|
// are we getting any closer ?
|
||||||
float f0 = squaredDistance - delta;
|
btScalar f0 = squaredDistance - delta;
|
||||||
float f1 = squaredDistance * REL_ERROR2;
|
btScalar f1 = squaredDistance * REL_ERROR2;
|
||||||
|
|
||||||
if (f0 <= f1)
|
if (f0 <= f1)
|
||||||
{
|
{
|
||||||
if (f0 <= 0.f)
|
if (f0 <= btScalar(0.))
|
||||||
{
|
{
|
||||||
m_degenerateSimplex = 2;
|
m_degenerateSimplex = 2;
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,7 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
|
|||||||
{
|
{
|
||||||
m_simplexSolver->compute_points(pointOnA, pointOnB);
|
m_simplexSolver->compute_points(pointOnA, pointOnB);
|
||||||
normalInB = pointOnA-pointOnB;
|
normalInB = pointOnA-pointOnB;
|
||||||
float lenSqr = m_cachedSeparatingAxis.length2();
|
btScalar lenSqr = m_cachedSeparatingAxis.length2();
|
||||||
//valid normal
|
//valid normal
|
||||||
if (lenSqr < 0.0001)
|
if (lenSqr < 0.0001)
|
||||||
{
|
{
|
||||||
@@ -199,14 +199,14 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
|
|||||||
}
|
}
|
||||||
if (lenSqr > SIMD_EPSILON*SIMD_EPSILON)
|
if (lenSqr > SIMD_EPSILON*SIMD_EPSILON)
|
||||||
{
|
{
|
||||||
float rlen = 1.f / btSqrt(lenSqr );
|
btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
|
||||||
normalInB *= rlen; //normalize
|
normalInB *= rlen; //normalize
|
||||||
btScalar s = btSqrt(squaredDistance);
|
btScalar s = btSqrt(squaredDistance);
|
||||||
|
|
||||||
btAssert(s > btScalar(0.0));
|
btAssert(s > btScalar(0.0));
|
||||||
pointOnA -= m_cachedSeparatingAxis * (marginA / s);
|
pointOnA -= m_cachedSeparatingAxis * (marginA / s);
|
||||||
pointOnB += m_cachedSeparatingAxis * (marginB / s);
|
pointOnB += m_cachedSeparatingAxis * (marginB / s);
|
||||||
distance = ((1.f/rlen) - margin);
|
distance = ((btScalar(1.)/rlen) - margin);
|
||||||
isValid = true;
|
isValid = true;
|
||||||
|
|
||||||
m_lastUsedMethod = 1;
|
m_lastUsedMethod = 1;
|
||||||
@@ -243,11 +243,11 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
|
|||||||
if (isValid2)
|
if (isValid2)
|
||||||
{
|
{
|
||||||
btVector3 tmpNormalInB = tmpPointOnB-tmpPointOnA;
|
btVector3 tmpNormalInB = tmpPointOnB-tmpPointOnA;
|
||||||
float lenSqr = tmpNormalInB.length2();
|
btScalar lenSqr = tmpNormalInB.length2();
|
||||||
if (lenSqr > (SIMD_EPSILON*SIMD_EPSILON))
|
if (lenSqr > (SIMD_EPSILON*SIMD_EPSILON))
|
||||||
{
|
{
|
||||||
tmpNormalInB /= btSqrt(lenSqr);
|
tmpNormalInB /= btSqrt(lenSqr);
|
||||||
float distance2 = -(tmpPointOnA-tmpPointOnB).length();
|
btScalar distance2 = -(tmpPointOnA-tmpPointOnB).length();
|
||||||
//only replace valid penetrations when the result is deeper (check)
|
//only replace valid penetrations when the result is deeper (check)
|
||||||
if (!isValid || (distance2 < distance))
|
if (!isValid || (distance2 < distance))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ class btManifoldPoint
|
|||||||
m_localPointB( pointB ),
|
m_localPointB( pointB ),
|
||||||
m_normalWorldOnB( normal ),
|
m_normalWorldOnB( normal ),
|
||||||
m_distance1( distance ),
|
m_distance1( distance ),
|
||||||
m_combinedFriction(0.f),
|
m_combinedFriction(btScalar(0.)),
|
||||||
m_combinedRestitution(0.f),
|
m_combinedRestitution(btScalar(0.)),
|
||||||
m_userPersistentData(0),
|
m_userPersistentData(0),
|
||||||
m_lifeTime(0)
|
m_lifeTime(0)
|
||||||
{
|
{
|
||||||
@@ -58,16 +58,16 @@ class btManifoldPoint
|
|||||||
btVector3 m_positionWorldOnA;
|
btVector3 m_positionWorldOnA;
|
||||||
btVector3 m_normalWorldOnB;
|
btVector3 m_normalWorldOnB;
|
||||||
|
|
||||||
float m_distance1;
|
btScalar m_distance1;
|
||||||
float m_combinedFriction;
|
btScalar m_combinedFriction;
|
||||||
float m_combinedRestitution;
|
btScalar m_combinedRestitution;
|
||||||
|
|
||||||
|
|
||||||
mutable void* m_userPersistentData;
|
mutable void* m_userPersistentData;
|
||||||
|
|
||||||
int m_lifeTime;//lifetime of the contactpoint in frames
|
int m_lifeTime;//lifetime of the contactpoint in frames
|
||||||
|
|
||||||
float getDistance() const
|
btScalar getDistance() const
|
||||||
{
|
{
|
||||||
return m_distance1;
|
return m_distance1;
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ class btManifoldPoint
|
|||||||
return m_positionWorldOnB;
|
return m_positionWorldOnB;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDistance(float dist)
|
void setDistance(btScalar dist)
|
||||||
{
|
{
|
||||||
m_distance1 = dist;
|
m_distance1 = dist;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,48 +25,48 @@ subject to the following restrictions:
|
|||||||
#define NUM_UNITSPHERE_POINTS 42
|
#define NUM_UNITSPHERE_POINTS 42
|
||||||
static btVector3 sPenetrationDirections[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2] =
|
static btVector3 sPenetrationDirections[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2] =
|
||||||
{
|
{
|
||||||
btVector3(0.000000f , -0.000000f,-1.000000f),
|
btVector3(btScalar(0.000000) , btScalar(-0.000000),btScalar(-1.000000)),
|
||||||
btVector3(0.723608f , -0.525725f,-0.447219f),
|
btVector3(btScalar(0.723608) , btScalar(-0.525725),btScalar(-0.447219)),
|
||||||
btVector3(-0.276388f , -0.850649f,-0.447219f),
|
btVector3(btScalar(-0.276388) , btScalar(-0.850649),btScalar(-0.447219)),
|
||||||
btVector3(-0.894426f , -0.000000f,-0.447216f),
|
btVector3(btScalar(-0.894426) , btScalar(-0.000000),btScalar(-0.447216)),
|
||||||
btVector3(-0.276388f , 0.850649f,-0.447220f),
|
btVector3(btScalar(-0.276388) , btScalar(0.850649),btScalar(-0.447220)),
|
||||||
btVector3(0.723608f , 0.525725f,-0.447219f),
|
btVector3(btScalar(0.723608) , btScalar(0.525725),btScalar(-0.447219)),
|
||||||
btVector3(0.276388f , -0.850649f,0.447220f),
|
btVector3(btScalar(0.276388) , btScalar(-0.850649),btScalar(0.447220)),
|
||||||
btVector3(-0.723608f , -0.525725f,0.447219f),
|
btVector3(btScalar(-0.723608) , btScalar(-0.525725),btScalar(0.447219)),
|
||||||
btVector3(-0.723608f , 0.525725f,0.447219f),
|
btVector3(btScalar(-0.723608) , btScalar(0.525725),btScalar(0.447219)),
|
||||||
btVector3(0.276388f , 0.850649f,0.447219f),
|
btVector3(btScalar(0.276388) , btScalar(0.850649),btScalar(0.447219)),
|
||||||
btVector3(0.894426f , 0.000000f,0.447216f),
|
btVector3(btScalar(0.894426) , btScalar(0.000000),btScalar(0.447216)),
|
||||||
btVector3(-0.000000f , 0.000000f,1.000000f),
|
btVector3(btScalar(-0.000000) , btScalar(0.000000),btScalar(1.000000)),
|
||||||
btVector3(0.425323f , -0.309011f,-0.850654f),
|
btVector3(btScalar(0.425323) , btScalar(-0.309011),btScalar(-0.850654)),
|
||||||
btVector3(-0.162456f , -0.499995f,-0.850654f),
|
btVector3(btScalar(-0.162456) , btScalar(-0.499995),btScalar(-0.850654)),
|
||||||
btVector3(0.262869f , -0.809012f,-0.525738f),
|
btVector3(btScalar(0.262869) , btScalar(-0.809012),btScalar(-0.525738)),
|
||||||
btVector3(0.425323f , 0.309011f,-0.850654f),
|
btVector3(btScalar(0.425323) , btScalar(0.309011),btScalar(-0.850654)),
|
||||||
btVector3(0.850648f , -0.000000f,-0.525736f),
|
btVector3(btScalar(0.850648) , btScalar(-0.000000),btScalar(-0.525736)),
|
||||||
btVector3(-0.525730f , -0.000000f,-0.850652f),
|
btVector3(btScalar(-0.525730) , btScalar(-0.000000),btScalar(-0.850652)),
|
||||||
btVector3(-0.688190f , -0.499997f,-0.525736f),
|
btVector3(btScalar(-0.688190) , btScalar(-0.499997),btScalar(-0.525736)),
|
||||||
btVector3(-0.162456f , 0.499995f,-0.850654f),
|
btVector3(btScalar(-0.162456) , btScalar(0.499995),btScalar(-0.850654)),
|
||||||
btVector3(-0.688190f , 0.499997f,-0.525736f),
|
btVector3(btScalar(-0.688190) , btScalar(0.499997),btScalar(-0.525736)),
|
||||||
btVector3(0.262869f , 0.809012f,-0.525738f),
|
btVector3(btScalar(0.262869) , btScalar(0.809012),btScalar(-0.525738)),
|
||||||
btVector3(0.951058f , 0.309013f,0.000000f),
|
btVector3(btScalar(0.951058) , btScalar(0.309013),btScalar(0.000000)),
|
||||||
btVector3(0.951058f , -0.309013f,0.000000f),
|
btVector3(btScalar(0.951058) , btScalar(-0.309013),btScalar(0.000000)),
|
||||||
btVector3(0.587786f , -0.809017f,0.000000f),
|
btVector3(btScalar(0.587786) , btScalar(-0.809017),btScalar(0.000000)),
|
||||||
btVector3(0.000000f , -1.000000f,0.000000f),
|
btVector3(btScalar(0.000000) , btScalar(-1.000000),btScalar(0.000000)),
|
||||||
btVector3(-0.587786f , -0.809017f,0.000000f),
|
btVector3(btScalar(-0.587786) , btScalar(-0.809017),btScalar(0.000000)),
|
||||||
btVector3(-0.951058f , -0.309013f,-0.000000f),
|
btVector3(btScalar(-0.951058) , btScalar(-0.309013),btScalar(-0.000000)),
|
||||||
btVector3(-0.951058f , 0.309013f,-0.000000f),
|
btVector3(btScalar(-0.951058) , btScalar(0.309013),btScalar(-0.000000)),
|
||||||
btVector3(-0.587786f , 0.809017f,-0.000000f),
|
btVector3(btScalar(-0.587786) , btScalar(0.809017),btScalar(-0.000000)),
|
||||||
btVector3(-0.000000f , 1.000000f,-0.000000f),
|
btVector3(btScalar(-0.000000) , btScalar(1.000000),btScalar(-0.000000)),
|
||||||
btVector3(0.587786f , 0.809017f,-0.000000f),
|
btVector3(btScalar(0.587786) , btScalar(0.809017),btScalar(-0.000000)),
|
||||||
btVector3(0.688190f , -0.499997f,0.525736f),
|
btVector3(btScalar(0.688190) , btScalar(-0.499997),btScalar(0.525736)),
|
||||||
btVector3(-0.262869f , -0.809012f,0.525738f),
|
btVector3(btScalar(-0.262869) , btScalar(-0.809012),btScalar(0.525738)),
|
||||||
btVector3(-0.850648f , 0.000000f,0.525736f),
|
btVector3(btScalar(-0.850648) , btScalar(0.000000),btScalar(0.525736)),
|
||||||
btVector3(-0.262869f , 0.809012f,0.525738f),
|
btVector3(btScalar(-0.262869) , btScalar(0.809012),btScalar(0.525738)),
|
||||||
btVector3(0.688190f , 0.499997f,0.525736f),
|
btVector3(btScalar(0.688190) , btScalar(0.499997),btScalar(0.525736)),
|
||||||
btVector3(0.525730f , 0.000000f,0.850652f),
|
btVector3(btScalar(0.525730) , btScalar(0.000000),btScalar(0.850652)),
|
||||||
btVector3(0.162456f , -0.499995f,0.850654f),
|
btVector3(btScalar(0.162456) , btScalar(-0.499995),btScalar(0.850654)),
|
||||||
btVector3(-0.425323f , -0.309011f,0.850654f),
|
btVector3(btScalar(-0.425323) , btScalar(-0.309011),btScalar(0.850654)),
|
||||||
btVector3(-0.425323f , 0.309011f,0.850654f),
|
btVector3(btScalar(-0.425323) , btScalar(0.309011),btScalar(0.850654)),
|
||||||
btVector3(0.162456f , 0.499995f,0.850654f)
|
btVector3(btScalar(0.162456) , btScalar(0.499995),btScalar(0.850654))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -88,13 +88,13 @@ bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& s
|
|||||||
|
|
||||||
btVector3 m_normalOnBInWorld;
|
btVector3 m_normalOnBInWorld;
|
||||||
btVector3 m_pointInWorld;
|
btVector3 m_pointInWorld;
|
||||||
float m_depth;
|
btScalar m_depth;
|
||||||
bool m_hasResult;
|
bool m_hasResult;
|
||||||
|
|
||||||
virtual void setShapeIdentifiers(int partId0,int index0, int partId1,int index1)
|
virtual void setShapeIdentifiers(int partId0,int index0, int partId1,int index1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth)
|
void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
|
||||||
{
|
{
|
||||||
m_normalOnBInWorld = normalOnBInWorld;
|
m_normalOnBInWorld = normalOnBInWorld;
|
||||||
m_pointInWorld = pointInWorld;
|
m_pointInWorld = pointInWorld;
|
||||||
@@ -104,7 +104,7 @@ bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& s
|
|||||||
};
|
};
|
||||||
|
|
||||||
//just take fixed number of orientation, and sample the penetration depth in that direction
|
//just take fixed number of orientation, and sample the penetration depth in that direction
|
||||||
float minProj = 1e30f;
|
btScalar minProj = btScalar(1e30);
|
||||||
btVector3 minNorm;
|
btVector3 minNorm;
|
||||||
btVector3 minVertex;
|
btVector3 minVertex;
|
||||||
btVector3 minA,minB;
|
btVector3 minA,minB;
|
||||||
@@ -180,7 +180,7 @@ bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& s
|
|||||||
pWorld = transA(pInA);
|
pWorld = transA(pInA);
|
||||||
qWorld = transB(qInB);
|
qWorld = transB(qInB);
|
||||||
w = qWorld - pWorld;
|
w = qWorld - pWorld;
|
||||||
float delta = norm.dot(w);
|
btScalar delta = norm.dot(w);
|
||||||
//find smallest delta
|
//find smallest delta
|
||||||
if (delta < minProj)
|
if (delta < minProj)
|
||||||
{
|
{
|
||||||
@@ -234,7 +234,7 @@ bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& s
|
|||||||
pWorld = transA(pInA);
|
pWorld = transA(pInA);
|
||||||
qWorld = transB(qInB);
|
qWorld = transB(qInB);
|
||||||
w = qWorld - pWorld;
|
w = qWorld - pWorld;
|
||||||
float delta = norm.dot(w);
|
btScalar delta = norm.dot(w);
|
||||||
//find smallest delta
|
//find smallest delta
|
||||||
if (delta < minProj)
|
if (delta < minProj)
|
||||||
{
|
{
|
||||||
@@ -251,7 +251,7 @@ bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& s
|
|||||||
minA += minNorm*convexA->getMargin();
|
minA += minNorm*convexA->getMargin();
|
||||||
minB -= minNorm*convexB->getMargin();
|
minB -= minNorm*convexB->getMargin();
|
||||||
//no penetration
|
//no penetration
|
||||||
if (minProj < 0.f)
|
if (minProj < btScalar(0.))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
minProj += (convexA->getMargin() + convexB->getMargin());
|
minProj += (convexA->getMargin() + convexB->getMargin());
|
||||||
@@ -268,7 +268,7 @@ bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& s
|
|||||||
debugDraw->drawLine(minA,minB,color);
|
debugDraw->drawLine(minA,minB,color);
|
||||||
color = btVector3 (1,1,1);
|
color = btVector3 (1,1,1);
|
||||||
btVector3 vec = minB-minA;
|
btVector3 vec = minB-minA;
|
||||||
float prj2 = minNorm.dot(vec);
|
btScalar prj2 = minNorm.dot(vec);
|
||||||
debugDraw->drawLine(minA,minA+(minNorm*minProj),color);
|
debugDraw->drawLine(minA,minA+(minNorm*minProj),color);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -292,16 +292,16 @@ bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& s
|
|||||||
|
|
||||||
input.m_transformA = displacedTrans;
|
input.m_transformA = displacedTrans;
|
||||||
input.m_transformB = transB;
|
input.m_transformB = transB;
|
||||||
input.m_maximumDistanceSquared = 1e30f;//minProj;
|
input.m_maximumDistanceSquared = btScalar(1e30);//minProj;
|
||||||
|
|
||||||
btIntermediateResult res;
|
btIntermediateResult res;
|
||||||
gjkdet.getClosestPoints(input,res,debugDraw);
|
gjkdet.getClosestPoints(input,res,debugDraw);
|
||||||
|
|
||||||
float correctedMinNorm = minProj - res.m_depth;
|
btScalar correctedMinNorm = minProj - res.m_depth;
|
||||||
|
|
||||||
|
|
||||||
//the penetration depth is over-estimated, relax it
|
//the penetration depth is over-estimated, relax it
|
||||||
float penetration_relaxation= 1.f;
|
btScalar penetration_relaxation= btScalar(1.);
|
||||||
minNorm*=penetration_relaxation;
|
minNorm*=penetration_relaxation;
|
||||||
|
|
||||||
if (res.m_hasResult)
|
if (res.m_hasResult)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ subject to the following restrictions:
|
|||||||
#include "LinearMath/btTransform.h"
|
#include "LinearMath/btTransform.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
float gContactBreakingThreshold = 0.02f;
|
btScalar gContactBreakingThreshold = btScalar(0.02);
|
||||||
ContactDestroyedCallback gContactDestroyedCallback = 0;
|
ContactDestroyedCallback gContactDestroyedCallback = 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ int btPersistentManifold::sortCachedPoints(const btManifoldPoint& pt)
|
|||||||
int maxPenetrationIndex = -1;
|
int maxPenetrationIndex = -1;
|
||||||
#define KEEP_DEEPEST_POINT 1
|
#define KEEP_DEEPEST_POINT 1
|
||||||
#ifdef KEEP_DEEPEST_POINT
|
#ifdef KEEP_DEEPEST_POINT
|
||||||
float maxPenetration = pt.getDistance();
|
btScalar maxPenetration = pt.getDistance();
|
||||||
for (int i=0;i<4;i++)
|
for (int i=0;i<4;i++)
|
||||||
{
|
{
|
||||||
if (m_pointCache[i].getDistance() < maxPenetration)
|
if (m_pointCache[i].getDistance() < maxPenetration)
|
||||||
@@ -111,7 +111,7 @@ int btPersistentManifold::sortCachedPoints(const btManifoldPoint& pt)
|
|||||||
}
|
}
|
||||||
#endif //KEEP_DEEPEST_POINT
|
#endif //KEEP_DEEPEST_POINT
|
||||||
|
|
||||||
btScalar res0(0.f),res1(0.f),res2(0.f),res3(0.f);
|
btScalar res0(btScalar(0.)),res1(btScalar(0.)),res2(btScalar(0.)),res3(btScalar(0.));
|
||||||
if (maxPenetrationIndex != 0)
|
if (maxPenetrationIndex != 0)
|
||||||
{
|
{
|
||||||
btVector3 a0 = pt.m_localPointA-m_pointCache[1].m_localPointA;
|
btVector3 a0 = pt.m_localPointA-m_pointCache[1].m_localPointA;
|
||||||
@@ -193,7 +193,7 @@ void btPersistentManifold::AddManifoldPoint(const btManifoldPoint& newPoint)
|
|||||||
replaceContactPoint(newPoint,insertIndex);
|
replaceContactPoint(newPoint,insertIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
float btPersistentManifold::getContactBreakingThreshold() const
|
btScalar btPersistentManifold::getContactBreakingThreshold() const
|
||||||
{
|
{
|
||||||
return gContactBreakingThreshold;
|
return gContactBreakingThreshold;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ subject to the following restrictions:
|
|||||||
struct btCollisionResult;
|
struct btCollisionResult;
|
||||||
|
|
||||||
///contact breaking and merging threshold
|
///contact breaking and merging threshold
|
||||||
extern float gContactBreakingThreshold;
|
extern btScalar gContactBreakingThreshold;
|
||||||
|
|
||||||
typedef bool (*ContactDestroyedCallback)(void* userPersistentData);
|
typedef bool (*ContactDestroyedCallback)(void* userPersistentData);
|
||||||
extern ContactDestroyedCallback gContactDestroyedCallback;
|
extern ContactDestroyedCallback gContactDestroyedCallback;
|
||||||
@@ -97,7 +97,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// todo: get this margin from the current physics / collision environment
|
/// todo: get this margin from the current physics / collision environment
|
||||||
float getContactBreakingThreshold() const;
|
btScalar getContactBreakingThreshold() const;
|
||||||
|
|
||||||
int getCacheEntry(const btManifoldPoint& newPoint) const;
|
int getCacheEntry(const btManifoldPoint& newPoint) const;
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ struct btPointCollector : public btDiscreteCollisionDetectorInterface::Result
|
|||||||
bool m_hasResult;
|
bool m_hasResult;
|
||||||
|
|
||||||
btPointCollector ()
|
btPointCollector ()
|
||||||
: m_distance(1e30f),m_hasResult(false)
|
: m_distance(btScalar(1e30)),m_hasResult(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ struct btPointCollector : public btDiscreteCollisionDetectorInterface::Result
|
|||||||
//??
|
//??
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth)
|
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
|
||||||
{
|
{
|
||||||
if (depth< m_distance)
|
if (depth< m_distance)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ btTriangleRaycastCallback::btTriangleRaycastCallback(const btVector3& from,const
|
|||||||
:
|
:
|
||||||
m_from(from),
|
m_from(from),
|
||||||
m_to(to),
|
m_to(to),
|
||||||
m_hitFraction(1.f)
|
m_hitFraction(btScalar(1.))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,19 +40,19 @@ void btTriangleRaycastCallback::processTriangle(btVector3* triangle,int partId,
|
|||||||
|
|
||||||
btVector3 triangleNormal; triangleNormal = v10.cross( v20 );
|
btVector3 triangleNormal; triangleNormal = v10.cross( v20 );
|
||||||
|
|
||||||
const float dist = vert0.dot(triangleNormal);
|
const btScalar dist = vert0.dot(triangleNormal);
|
||||||
float dist_a = triangleNormal.dot(m_from) ;
|
btScalar dist_a = triangleNormal.dot(m_from) ;
|
||||||
dist_a-= dist;
|
dist_a-= dist;
|
||||||
float dist_b = triangleNormal.dot(m_to);
|
btScalar dist_b = triangleNormal.dot(m_to);
|
||||||
dist_b -= dist;
|
dist_b -= dist;
|
||||||
|
|
||||||
if ( dist_a * dist_b >= 0.0f)
|
if ( dist_a * dist_b >= btScalar(0.0) )
|
||||||
{
|
{
|
||||||
return ; // same sign
|
return ; // same sign
|
||||||
}
|
}
|
||||||
|
|
||||||
const float proj_length=dist_a-dist_b;
|
const btScalar proj_length=dist_a-dist_b;
|
||||||
const float distance = (dist_a)/(proj_length);
|
const btScalar distance = (dist_a)/(proj_length);
|
||||||
// Now we have the intersection point on the plane, we'll see if it's inside the triangle
|
// Now we have the intersection point on the plane, we'll see if it's inside the triangle
|
||||||
// Add an epsilon as a tolerance for the raycast,
|
// Add an epsilon as a tolerance for the raycast,
|
||||||
// in case the ray hits exacly on the edge of the triangle.
|
// in case the ray hits exacly on the edge of the triangle.
|
||||||
@@ -62,27 +62,27 @@ void btTriangleRaycastCallback::processTriangle(btVector3* triangle,int partId,
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
float edge_tolerance =triangleNormal.length2();
|
btScalar edge_tolerance =triangleNormal.length2();
|
||||||
edge_tolerance *= -0.0001f;
|
edge_tolerance *= btScalar(-0.0001);
|
||||||
btVector3 point; point.setInterpolate3( m_from, m_to, distance);
|
btVector3 point; point.setInterpolate3( m_from, m_to, distance);
|
||||||
{
|
{
|
||||||
btVector3 v0p; v0p = vert0 - point;
|
btVector3 v0p; v0p = vert0 - point;
|
||||||
btVector3 v1p; v1p = vert1 - point;
|
btVector3 v1p; v1p = vert1 - point;
|
||||||
btVector3 cp0; cp0 = v0p.cross( v1p );
|
btVector3 cp0; cp0 = v0p.cross( v1p );
|
||||||
|
|
||||||
if ( (float)(cp0.dot(triangleNormal)) >=edge_tolerance)
|
if ( (btScalar)(cp0.dot(triangleNormal)) >=edge_tolerance)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
btVector3 v2p; v2p = vert2 - point;
|
btVector3 v2p; v2p = vert2 - point;
|
||||||
btVector3 cp1;
|
btVector3 cp1;
|
||||||
cp1 = v1p.cross( v2p);
|
cp1 = v1p.cross( v2p);
|
||||||
if ( (float)(cp1.dot(triangleNormal)) >=edge_tolerance)
|
if ( (btScalar)(cp1.dot(triangleNormal)) >=edge_tolerance)
|
||||||
{
|
{
|
||||||
btVector3 cp2;
|
btVector3 cp2;
|
||||||
cp2 = v2p.cross(v0p);
|
cp2 = v2p.cross(v0p);
|
||||||
|
|
||||||
if ( (float)(cp2.dot(triangleNormal)) >=edge_tolerance)
|
if ( (btScalar)(cp2.dot(triangleNormal)) >=edge_tolerance)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( dist_a > 0 )
|
if ( dist_a > 0 )
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user