ASSERT -> btAssert
Added btStackAlloc to Bullet (right now only used by btGjkEpa) removed default constructors of btCollisionWorld/btDiscreteDynamicsWorld, to reduce link-time dependencies
This commit is contained in:
@@ -133,7 +133,17 @@ void BspDemo::initPhysics(char* bspfilename)
|
|||||||
m_forwardAxis = 1;
|
m_forwardAxis = 1;
|
||||||
|
|
||||||
///Setup a Physics Simulation Environment
|
///Setup a Physics Simulation Environment
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld();
|
|
||||||
|
btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
|
||||||
|
btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
|
||||||
|
btVector3 worldMin(-1000,-1000,-1000);
|
||||||
|
btVector3 worldMax(1000,1000,1000);
|
||||||
|
btOverlappingPairCache* pairCache = new btAxisSweep3(worldMin,worldMax);
|
||||||
|
//btOverlappingPairCache* broadphase = new btSimpleBroadphase();
|
||||||
|
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||||
|
//ConstraintSolver* solver = new OdeConstraintSolver;
|
||||||
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
|
||||||
|
|
||||||
m_dynamicsWorld->setGravity(-m_cameraUp * 10);
|
m_dynamicsWorld->setGravity(-m_cameraUp * 10);
|
||||||
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
||||||
|
|
||||||
|
|||||||
@@ -720,7 +720,7 @@ bool ColladaConverter::saveAs(const char* filename)
|
|||||||
{
|
{
|
||||||
for (int i=0;i<m_numObjects;i++)
|
for (int i=0;i<m_numObjects;i++)
|
||||||
{
|
{
|
||||||
assert(m_colladadomNodes[i]);
|
btAssert(m_colladadomNodes[i]);
|
||||||
if (!m_colladadomNodes[i]->getTranslate_array().getCount())
|
if (!m_colladadomNodes[i]->getTranslate_array().getCount())
|
||||||
{
|
{
|
||||||
domTranslate* transl = (domTranslate*) m_colladadomNodes[i]->createAndPlace("translate");
|
domTranslate* transl = (domTranslate*) m_colladadomNodes[i]->createAndPlace("translate");
|
||||||
|
|||||||
@@ -160,7 +160,14 @@ void ColladaDemo::initPhysics(const char* filename)
|
|||||||
m_cameraUp = btVector3(0,0,1);
|
m_cameraUp = btVector3(0,0,1);
|
||||||
m_forwardAxis = 1;
|
m_forwardAxis = 1;
|
||||||
|
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld();
|
btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
|
||||||
|
btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
|
||||||
|
btVector3 worldMin(-1000,-1000,-1000);
|
||||||
|
btVector3 worldMax(1000,1000,1000);
|
||||||
|
btOverlappingPairCache* pairCache = new btAxisSweep3(worldMin,worldMax);
|
||||||
|
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||||
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
|
||||||
|
|
||||||
//m_dynamicsWorld = new btSimpleDynamicsWorld();
|
//m_dynamicsWorld = new btSimpleDynamicsWorld();
|
||||||
|
|
||||||
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
||||||
|
|||||||
@@ -151,11 +151,14 @@ void ConcaveDemo::initPhysics()
|
|||||||
|
|
||||||
btCollisionShape* trimeshShape = new btBvhTriangleMeshShape(indexVertexArrays);
|
btCollisionShape* trimeshShape = new btBvhTriangleMeshShape(indexVertexArrays);
|
||||||
|
|
||||||
//btConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
|
|
||||||
//btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
|
|
||||||
//btOverlappingPairCache* broadphase = new btSimpleBroadphase();
|
|
||||||
|
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld();
|
btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
|
||||||
|
btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
|
||||||
|
btVector3 worldMin(-1000,-1000,-1000);
|
||||||
|
btVector3 worldMax(1000,1000,1000);
|
||||||
|
btOverlappingPairCache* pairCache = new btAxisSweep3(worldMin,worldMax);
|
||||||
|
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||||
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
|
||||||
|
|
||||||
float mass = 0.f;
|
float mass = 0.f;
|
||||||
btTransform startTransform;
|
btTransform startTransform;
|
||||||
|
|||||||
@@ -75,12 +75,16 @@ void drawLimit()
|
|||||||
|
|
||||||
void ConstraintDemo::initPhysics()
|
void ConstraintDemo::initPhysics()
|
||||||
{
|
{
|
||||||
//ConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
|
btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
|
||||||
//ConstraintSolver* solver = new OdeConstraintSolver;
|
btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
|
||||||
//btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
|
btVector3 worldMin(-1000,-1000,-1000);
|
||||||
|
btVector3 worldMax(1000,1000,1000);
|
||||||
|
btOverlappingPairCache* pairCache = new btAxisSweep3(worldMin,worldMax);
|
||||||
//btOverlappingPairCache* broadphase = new btSimpleBroadphase();
|
//btOverlappingPairCache* broadphase = new btSimpleBroadphase();
|
||||||
|
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||||
|
//ConstraintSolver* solver = new OdeConstraintSolver;
|
||||||
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
|
||||||
|
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld();
|
|
||||||
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
||||||
|
|
||||||
btCollisionShape* shape = new btBoxShape(btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS));
|
btCollisionShape* shape = new btBoxShape(btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS));
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
|
#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
|
||||||
#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
|
#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
|
||||||
#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
|
#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
|
||||||
|
#include "LinearMath/btStackAlloc.h"
|
||||||
|
|
||||||
//We can use the Bullet EPA or sampling penetration depth solver, but comparison might be useful
|
//We can use the Bullet EPA or sampling penetration depth solver, but comparison might be useful
|
||||||
//#define COMPARE_WITH_SOLID35_AND_OTHER_EPA 1
|
//#define COMPARE_WITH_SOLID35_AND_OTHER_EPA 1
|
||||||
#ifdef COMPARE_WITH_SOLID35_AND_OTHER_EPA
|
#ifdef COMPARE_WITH_SOLID35_AND_OTHER_EPA
|
||||||
@@ -279,6 +281,9 @@ static float gDepth;
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//2 Mb by default, could be made smaller
|
||||||
|
btStackAlloc gStackAlloc(1024*1024*2);
|
||||||
|
|
||||||
static bool TestEPA(const MyConvex& hull0, const MyConvex& hull1)
|
static bool TestEPA(const MyConvex& hull0, const MyConvex& hull1)
|
||||||
{
|
{
|
||||||
static btSimplexSolverInterface simplexSolver;
|
static btSimplexSolverInterface simplexSolver;
|
||||||
@@ -323,6 +328,7 @@ static bool TestEPA(const MyConvex& hull0, const MyConvex& hull1)
|
|||||||
btDiscreteCollisionDetectorInterface::ClosestPointInput input;
|
btDiscreteCollisionDetectorInterface::ClosestPointInput input;
|
||||||
input.m_transformA = hull0.mTransform;
|
input.m_transformA = hull0.mTransform;
|
||||||
input.m_transformB = hull1.mTransform;
|
input.m_transformB = hull1.mTransform;
|
||||||
|
input.m_stackAlloc = &gStackAlloc;
|
||||||
|
|
||||||
MyResult output;
|
MyResult output;
|
||||||
GJK.getClosestPoints(input, output, 0);
|
GJK.getClosestPoints(input, output, 0);
|
||||||
|
|||||||
@@ -1634,7 +1634,8 @@ void ConcaveDemo::initPhysics()
|
|||||||
//btOverlappingPairCache* broadphase = new btSimpleBroadphase();
|
//btOverlappingPairCache* broadphase = new btSimpleBroadphase();
|
||||||
btOverlappingPairCache* broadphase = new btSimpleBroadphase();
|
btOverlappingPairCache* broadphase = new btSimpleBroadphase();
|
||||||
|
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase);
|
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||||
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,constraintSolver);
|
||||||
|
|
||||||
m_gimpactCollisionCreateFunc = new btConcaveConcaveCollisionAlgorithm::CreateFunc;
|
m_gimpactCollisionCreateFunc = new btConcaveConcaveCollisionAlgorithm::CreateFunc;
|
||||||
dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE,GIMPACT_SHAPE_PROXYTYPE,m_gimpactCollisionCreateFunc);
|
dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE,GIMPACT_SHAPE_PROXYTYPE,m_gimpactCollisionCreateFunc);
|
||||||
@@ -1865,7 +1866,7 @@ void ConcaveDemo::clientMoveAndDisplay()
|
|||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
float dt = m_clock.getTimeMilliseconds() * 0.001f;
|
float dt = float(m_clock.getTimeMicroseconds()) * 0.000001f;
|
||||||
m_clock.reset();
|
m_clock.reset();
|
||||||
|
|
||||||
m_dynamicsWorld->stepSimulation(dt);
|
m_dynamicsWorld->stepSimulation(dt);
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ void UserCollisionAlgorithm::initPhysics()
|
|||||||
btOverlappingPairCache* broadphase = new btAxisSweep3(-maxAabb,maxAabb);//SimpleBroadphase();
|
btOverlappingPairCache* broadphase = new btAxisSweep3(-maxAabb,maxAabb);//SimpleBroadphase();
|
||||||
dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE,GIMPACT_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc);
|
dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE,GIMPACT_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc);
|
||||||
|
|
||||||
|
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase);
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,constraintSolver);
|
||||||
|
|
||||||
float mass = 0.f;
|
float mass = 0.f;
|
||||||
btTransform startTransform;
|
btTransform startTransform;
|
||||||
|
|||||||
@@ -109,7 +109,12 @@ void VehicleDemo::setupPhysics()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
|
btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld();
|
btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
|
||||||
|
btVector3 worldMin(-1000,-1000,-1000);
|
||||||
|
btVector3 worldMax(1000,1000,1000);
|
||||||
|
btOverlappingPairCache* pairCache = new btAxisSweep3(worldMin,worldMax);
|
||||||
|
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||||
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
|
||||||
#ifdef FORCE_ZAXIS_UP
|
#ifdef FORCE_ZAXIS_UP
|
||||||
m_dynamicsWorld->setGravity(btVector3(0,0,-10));
|
m_dynamicsWorld->setGravity(btVector3(0,0,-10));
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ void gim_closest_point_triangle_segment(GIM_TRIANGLE_DATA * triangle, vec3f s1,v
|
|||||||
VEC_COPY(closest_points[1],sdiff);//normal
|
VEC_COPY(closest_points[1],sdiff);//normal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(out_edge>2) return ;// ???? ASSERT this please
|
if(out_edge>2) return ;// ???? btAssert this please
|
||||||
|
|
||||||
if(GIM_IS_ZERO(dis))
|
if(GIM_IS_ZERO(dis))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ enum btCollisionDispatcherId
|
|||||||
};
|
};
|
||||||
|
|
||||||
class btPersistentManifold;
|
class btPersistentManifold;
|
||||||
|
class btStackAlloc;
|
||||||
|
|
||||||
struct btDispatcherInfo
|
struct btDispatcherInfo
|
||||||
{
|
{
|
||||||
@@ -45,7 +46,8 @@ struct btDispatcherInfo
|
|||||||
m_useContinuous(false),
|
m_useContinuous(false),
|
||||||
m_debugDraw(0),
|
m_debugDraw(0),
|
||||||
m_enableSatConvex(false),
|
m_enableSatConvex(false),
|
||||||
m_enableSPU(false)
|
m_enableSPU(false),
|
||||||
|
m_stackAllocator(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -57,6 +59,7 @@ struct btDispatcherInfo
|
|||||||
class btIDebugDraw* m_debugDraw;
|
class btIDebugDraw* m_debugDraw;
|
||||||
bool m_enableSatConvex;
|
bool m_enableSatConvex;
|
||||||
bool m_enableSPU;
|
bool m_enableSPU;
|
||||||
|
btStackAlloc* m_stackAllocator;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ btPersistentManifold* btCollisionDispatcher::getNewManifold(void* b0,void* b1)
|
|||||||
{
|
{
|
||||||
gNumManifold++;
|
gNumManifold++;
|
||||||
|
|
||||||
//ASSERT(gNumManifold < 65535);
|
//btAssert(gNumManifold < 65535);
|
||||||
|
|
||||||
|
|
||||||
btCollisionObject* body0 = (btCollisionObject*)b0;
|
btCollisionObject* body0 = (btCollisionObject*)b0;
|
||||||
@@ -145,7 +145,7 @@ void btCollisionDispatcher::releaseManifold(btPersistentManifold* manifold)
|
|||||||
|
|
||||||
btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold)
|
btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold)
|
||||||
{
|
{
|
||||||
#define USE_DISPATCH_REGISTRY_ARRAY 1
|
|
||||||
#ifdef USE_DISPATCH_REGISTRY_ARRAY
|
#ifdef USE_DISPATCH_REGISTRY_ARRAY
|
||||||
|
|
||||||
btCollisionAlgorithmConstructionInfo ci;
|
btCollisionAlgorithmConstructionInfo ci;
|
||||||
@@ -194,6 +194,7 @@ btCollisionAlgorithmCreateFunc* btCollisionDispatcher::internalFindCreateFunc(in
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef USE_DISPATCH_REGISTRY_ARRAY
|
||||||
|
|
||||||
btCollisionAlgorithm* btCollisionDispatcher::internalFindAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold)
|
btCollisionAlgorithm* btCollisionDispatcher::internalFindAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold)
|
||||||
{
|
{
|
||||||
@@ -232,6 +233,7 @@ btCollisionAlgorithm* btCollisionDispatcher::internalFindAlgorithm(btCollisionOb
|
|||||||
return new btEmptyAlgorithm(ci);
|
return new btEmptyAlgorithm(ci);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif //USE_DISPATCH_REGISTRY_ARRAY
|
||||||
|
|
||||||
bool btCollisionDispatcher::needsResponse(btCollisionObject* body0,btCollisionObject* body1)
|
bool btCollisionDispatcher::needsResponse(btCollisionObject* body0,btCollisionObject* body1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class btOverlappingPairCache;
|
|||||||
|
|
||||||
#include "btCollisionCreateFunc.h"
|
#include "btCollisionCreateFunc.h"
|
||||||
|
|
||||||
|
#define USE_DISPATCH_REGISTRY_ARRAY 1
|
||||||
|
|
||||||
|
|
||||||
///btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs.
|
///btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs.
|
||||||
@@ -56,7 +56,9 @@ class btCollisionDispatcher : public btDispatcher
|
|||||||
btCollisionAlgorithmCreateFunc* m_swappedCompoundCreateFunc;
|
btCollisionAlgorithmCreateFunc* m_swappedCompoundCreateFunc;
|
||||||
btCollisionAlgorithmCreateFunc* m_emptyCreateFunc;
|
btCollisionAlgorithmCreateFunc* m_emptyCreateFunc;
|
||||||
|
|
||||||
|
#ifndef USE_DISPATCH_REGISTRY_ARRAY
|
||||||
btCollisionAlgorithm* internalFindAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold = 0);
|
btCollisionAlgorithm* internalFindAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold = 0);
|
||||||
|
#endif //USE_DISPATCH_REGISTRY_ARRAY
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ subject to the following restrictions:
|
|||||||
#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
|
#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
|
||||||
#include "LinearMath/btAabbUtil2.h"
|
#include "LinearMath/btAabbUtil2.h"
|
||||||
#include "LinearMath/btQuickprof.h"
|
#include "LinearMath/btQuickprof.h"
|
||||||
|
#include "LinearMath/btStackAlloc.h"
|
||||||
|
|
||||||
//When the user doesn't provide dispatcher or broadphase, create basic versions (and delete them in destructor)
|
//When the user doesn't provide dispatcher or broadphase, create basic versions (and delete them in destructor)
|
||||||
#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
|
#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
|
||||||
@@ -32,26 +33,22 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
btCollisionWorld::btCollisionWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache)
|
btCollisionWorld::btCollisionWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache, int stackSize)
|
||||||
:m_dispatcher1(dispatcher),
|
:m_dispatcher1(dispatcher),
|
||||||
m_broadphasePairCache(pairCache),
|
m_broadphasePairCache(pairCache),
|
||||||
m_ownsDispatcher(false),
|
m_ownsDispatcher(false),
|
||||||
m_ownsBroadphasePairCache(false)
|
m_ownsBroadphasePairCache(false)
|
||||||
{
|
{
|
||||||
}
|
m_stackAlloc = new btStackAlloc(stackSize);
|
||||||
|
m_dispatchInfo.m_stackAllocator = m_stackAlloc;
|
||||||
|
|
||||||
btCollisionWorld::btCollisionWorld()
|
|
||||||
: m_dispatcher1(new btCollisionDispatcher()),
|
|
||||||
m_broadphasePairCache(new btSimpleBroadphase()),
|
|
||||||
m_ownsDispatcher(true),
|
|
||||||
m_ownsBroadphasePairCache(true)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
btCollisionWorld::~btCollisionWorld()
|
btCollisionWorld::~btCollisionWorld()
|
||||||
{
|
{
|
||||||
|
m_stackAlloc->destroy();
|
||||||
|
delete m_stackAlloc;
|
||||||
|
|
||||||
//clean up remaining objects
|
//clean up remaining objects
|
||||||
std::vector<btCollisionObject*>::iterator i;
|
std::vector<btCollisionObject*>::iterator i;
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ subject to the following restrictions:
|
|||||||
#ifndef COLLISION_WORLD_H
|
#ifndef COLLISION_WORLD_H
|
||||||
#define COLLISION_WORLD_H
|
#define COLLISION_WORLD_H
|
||||||
|
|
||||||
|
class btStackAlloc;
|
||||||
class btCollisionShape;
|
class btCollisionShape;
|
||||||
class btBroadphaseInterface;
|
class btBroadphaseInterface;
|
||||||
#include "LinearMath/btVector3.h"
|
#include "LinearMath/btVector3.h"
|
||||||
@@ -88,6 +88,10 @@ protected:
|
|||||||
|
|
||||||
btDispatcher* m_dispatcher1;
|
btDispatcher* m_dispatcher1;
|
||||||
|
|
||||||
|
btDispatcherInfo m_dispatchInfo;
|
||||||
|
|
||||||
|
btStackAlloc* m_stackAlloc;
|
||||||
|
|
||||||
btOverlappingPairCache* m_broadphasePairCache;
|
btOverlappingPairCache* m_broadphasePairCache;
|
||||||
|
|
||||||
bool m_ownsDispatcher;
|
bool m_ownsDispatcher;
|
||||||
@@ -95,11 +99,8 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//this constructor will create and own a dispatcher and paircache and delete it at destruction
|
|
||||||
btCollisionWorld();
|
|
||||||
|
|
||||||
//this constructor doesn't own the dispatcher and paircache/broadphase
|
//this constructor doesn't own the dispatcher and paircache/broadphase
|
||||||
btCollisionWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache);
|
btCollisionWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache, int stackSize = 2*1024*1024);
|
||||||
|
|
||||||
virtual ~btCollisionWorld();
|
virtual ~btCollisionWorld();
|
||||||
|
|
||||||
@@ -238,6 +239,11 @@ public:
|
|||||||
|
|
||||||
virtual void performDiscreteCollisionDetection( btDispatcherInfo& dispatchInfo);
|
virtual void performDiscreteCollisionDetection( btDispatcherInfo& dispatchInfo);
|
||||||
|
|
||||||
|
btDispatcherInfo& getDispatchInfo()
|
||||||
|
{
|
||||||
|
return m_dispatchInfo;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -61,37 +61,28 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#endif //USE_HULL
|
#endif //USE_HULL
|
||||||
|
|
||||||
bool gUseEpa = true;
|
|
||||||
|
|
||||||
|
btConvexConvexAlgorithm::CreateFunc::CreateFunc()
|
||||||
|
{
|
||||||
|
m_ownsSolvers = true;
|
||||||
|
m_simplexSolver = new btVoronoiSimplexSolver();
|
||||||
|
m_pdSolver = new btGjkEpaPenetrationDepthSolver;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
btConvexConvexAlgorithm::CreateFunc::CreateFunc(btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
|
||||||
void DrawRasterizerLine(const float* from,const float* to,int color);
|
{
|
||||||
#endif
|
m_ownsSolvers = false;
|
||||||
|
m_simplexSolver = simplexSolver;
|
||||||
|
m_pdSolver = pdSolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
|
||||||
|
|
||||||
|
|
||||||
//#define PROCESS_SINGLE_CONTACT
|
|
||||||
#ifdef WIN32
|
|
||||||
bool gForceBoxBox = false;//false;//true;
|
|
||||||
|
|
||||||
#else
|
|
||||||
bool gForceBoxBox = false;//false;//true;
|
|
||||||
#endif
|
|
||||||
bool gBoxBoxUseGjk = true;//true;//false;
|
|
||||||
bool gDisableConvexCollision = false;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1)
|
|
||||||
: btCollisionAlgorithm(ci),
|
: btCollisionAlgorithm(ci),
|
||||||
m_gjkPairDetector(0,0,&m_simplexSolver,0),
|
m_gjkPairDetector(0,0,simplexSolver,pdSolver),
|
||||||
m_useEpa(!gUseEpa),
|
|
||||||
m_ownManifold (false),
|
m_ownManifold (false),
|
||||||
m_manifoldPtr(mf),
|
m_manifoldPtr(mf),
|
||||||
m_lowLevelOfDetail(false)
|
m_lowLevelOfDetail(false)
|
||||||
{
|
{
|
||||||
checkPenetrationDepthSolver();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,27 +106,6 @@ void btConvexConvexAlgorithm ::setLowLevelOfDetail(bool useLowLevel)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static btGjkEpaPenetrationDepthSolver gEpaPenetrationDepthSolver;
|
|
||||||
static btMinkowskiPenetrationDepthSolver gPenetrationDepthSolver;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void btConvexConvexAlgorithm::checkPenetrationDepthSolver()
|
|
||||||
{
|
|
||||||
if (m_useEpa != gUseEpa)
|
|
||||||
{
|
|
||||||
m_useEpa = gUseEpa;
|
|
||||||
if (m_useEpa)
|
|
||||||
{
|
|
||||||
m_gjkPairDetector.setPenetrationDepthSolver(&gEpaPenetrationDepthSolver);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
m_gjkPairDetector.setPenetrationDepthSolver(&gPenetrationDepthSolver);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Convex-Convex collision algorithm
|
// Convex-Convex collision algorithm
|
||||||
@@ -164,7 +134,6 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
|
|||||||
resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
|
resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
checkPenetrationDepthSolver();
|
|
||||||
|
|
||||||
btConvexShape* min0 = static_cast<btConvexShape*>(body0->getCollisionShape());
|
btConvexShape* min0 = static_cast<btConvexShape*>(body0->getCollisionShape());
|
||||||
btConvexShape* min1 = static_cast<btConvexShape*>(body1->getCollisionShape());
|
btConvexShape* min1 = static_cast<btConvexShape*>(body1->getCollisionShape());
|
||||||
@@ -176,6 +145,7 @@ void btConvexConvexAlgorithm ::processCollision (btCollisionObject* body0,btColl
|
|||||||
m_gjkPairDetector.setMinkowskiB(min1);
|
m_gjkPairDetector.setMinkowskiB(min1);
|
||||||
input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
|
input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
|
||||||
input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
|
input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
|
||||||
|
input.m_stackAlloc = dispatchInfo.m_stackAllocator;
|
||||||
|
|
||||||
// input.m_maximumDistanceSquared = 1e30f;
|
// input.m_maximumDistanceSquared = 1e30f;
|
||||||
|
|
||||||
@@ -209,7 +179,6 @@ float btConvexConvexAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btC
|
|||||||
if (disableCcd)
|
if (disableCcd)
|
||||||
return 1.f;
|
return 1.f;
|
||||||
|
|
||||||
checkPenetrationDepthSolver();
|
|
||||||
|
|
||||||
//An adhoc way of testing the Continuous Collision Detection algorithms
|
//An adhoc way of testing the Continuous Collision Detection algorithms
|
||||||
//One object is approximated as a sphere, to simplify things
|
//One object is approximated as a sphere, to simplify things
|
||||||
|
|||||||
@@ -28,23 +28,17 @@ class btConvexPenetrationDepthSolver;
|
|||||||
///ConvexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations.
|
///ConvexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations.
|
||||||
class btConvexConvexAlgorithm : public btCollisionAlgorithm
|
class btConvexConvexAlgorithm : public btCollisionAlgorithm
|
||||||
{
|
{
|
||||||
//ConvexPenetrationDepthSolver* m_penetrationDepthSolver;
|
|
||||||
btVoronoiSimplexSolver m_simplexSolver;
|
|
||||||
btGjkPairDetector m_gjkPairDetector;
|
btGjkPairDetector m_gjkPairDetector;
|
||||||
bool m_useEpa;
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool m_ownManifold;
|
bool m_ownManifold;
|
||||||
btPersistentManifold* m_manifoldPtr;
|
btPersistentManifold* m_manifoldPtr;
|
||||||
bool m_lowLevelOfDetail;
|
bool m_lowLevelOfDetail;
|
||||||
|
|
||||||
void checkPenetrationDepthSolver();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
|
btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
|
||||||
|
|
||||||
virtual ~btConvexConvexAlgorithm();
|
virtual ~btConvexConvexAlgorithm();
|
||||||
|
|
||||||
@@ -62,9 +56,16 @@ public:
|
|||||||
|
|
||||||
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
||||||
{
|
{
|
||||||
|
btConvexPenetrationDepthSolver* m_pdSolver;
|
||||||
|
btSimplexSolverInterface* m_simplexSolver;
|
||||||
|
bool m_ownsSolvers;
|
||||||
|
|
||||||
|
CreateFunc(btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
|
||||||
|
CreateFunc();
|
||||||
|
|
||||||
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
|
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
|
||||||
{
|
{
|
||||||
return new btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1);
|
return new btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ public:
|
|||||||
edgeVert1 = 7;
|
edgeVert1 = 7;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(0);
|
btAssert(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
//#define DISABLE_BVH
|
//#define DISABLE_BVH
|
||||||
|
|
||||||
|
|
||||||
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
|
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btOptimizedBvh.h"
|
#include "BulletCollision/CollisionShapes/btOptimizedBvh.h"
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ void btStridingMeshInterface::InternalProcessAllTriangles(btInternalTriangleInde
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
ASSERT((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
|
btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
|
||||||
}
|
}
|
||||||
|
|
||||||
unLockReadOnlyVertexBase(part);
|
unLockReadOnlyVertexBase(part);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ btTriangleIndexVertexArray::btTriangleIndexVertexArray(int numTriangles,int* tri
|
|||||||
|
|
||||||
void btTriangleIndexVertexArray::getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart)
|
void btTriangleIndexVertexArray::getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& vertexStride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart)
|
||||||
{
|
{
|
||||||
ASSERT(subpart< getNumSubParts() );
|
btAssert(subpart< getNumSubParts() );
|
||||||
|
|
||||||
btIndexedMesh& mesh = m_indexedMeshes[subpart];
|
btIndexedMesh& mesh = m_indexedMeshes[subpart];
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
|
|
||||||
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax)const
|
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax)const
|
||||||
{
|
{
|
||||||
// ASSERT(0);
|
// btAssert(0);
|
||||||
getAabbSlow(t,aabbMin,aabbMax);
|
getAabbSlow(t,aabbMin,aabbMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ public:
|
|||||||
|
|
||||||
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia)
|
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia)
|
||||||
{
|
{
|
||||||
ASSERT(0);
|
btAssert(0);
|
||||||
inertia.setValue(0.f,0.f,0.f);
|
inertia.setValue(0.f,0.f,0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ subject to the following restrictions:
|
|||||||
#ifndef CONVEX_PENETRATION_DEPTH_H
|
#ifndef CONVEX_PENETRATION_DEPTH_H
|
||||||
#define CONVEX_PENETRATION_DEPTH_H
|
#define CONVEX_PENETRATION_DEPTH_H
|
||||||
|
|
||||||
|
class btStackAlloc;
|
||||||
class btVector3;
|
class btVector3;
|
||||||
#include "btSimplexSolverInterface.h"
|
#include "btSimplexSolverInterface.h"
|
||||||
class btConvexShape;
|
class btConvexShape;
|
||||||
@@ -33,7 +34,7 @@ public:
|
|||||||
btConvexShape* convexA,btConvexShape* convexB,
|
btConvexShape* convexA,btConvexShape* convexB,
|
||||||
const btTransform& transA,const btTransform& transB,
|
const btTransform& transA,const btTransform& transB,
|
||||||
btVector3& v, btPoint3& pa, btPoint3& pb,
|
btVector3& v, btPoint3& pa, btPoint3& pb,
|
||||||
class btIDebugDraw* debugDraw
|
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ subject to the following restrictions:
|
|||||||
#define DISCRETE_COLLISION_DETECTOR1_INTERFACE_H
|
#define DISCRETE_COLLISION_DETECTOR1_INTERFACE_H
|
||||||
#include "LinearMath/btTransform.h"
|
#include "LinearMath/btTransform.h"
|
||||||
#include "LinearMath/btVector3.h"
|
#include "LinearMath/btVector3.h"
|
||||||
|
class btStackAlloc;
|
||||||
|
|
||||||
/// This interface is made to be used by an iterative approach to do TimeOfImpact calculations
|
/// This interface is made to be used by an iterative approach to do TimeOfImpact calculations
|
||||||
/// This interface allows to query for closest points and penetration depth between two (convex) objects
|
/// This interface allows to query for closest points and penetration depth between two (convex) objects
|
||||||
@@ -42,13 +42,15 @@ struct btDiscreteCollisionDetectorInterface
|
|||||||
struct ClosestPointInput
|
struct ClosestPointInput
|
||||||
{
|
{
|
||||||
ClosestPointInput()
|
ClosestPointInput()
|
||||||
:m_maximumDistanceSquared(1e30f)
|
:m_maximumDistanceSquared(1e30f),
|
||||||
|
m_stackAlloc(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
btTransform m_transformA;
|
btTransform m_transformA;
|
||||||
btTransform m_transformB;
|
btTransform m_transformB;
|
||||||
btScalar m_maximumDistanceSquared;
|
btScalar m_maximumDistanceSquared;
|
||||||
|
btStackAlloc* m_stackAlloc;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~btDiscreteCollisionDetectorInterface() {};
|
virtual ~btDiscreteCollisionDetectorInterface() {};
|
||||||
|
|||||||
@@ -26,6 +26,15 @@ Nov.2006
|
|||||||
|
|
||||||
#include "btGjkEpa.h"
|
#include "btGjkEpa.h"
|
||||||
#include <string.h> //for memset
|
#include <string.h> //for memset
|
||||||
|
#include <LinearMath/btStackAlloc.h>
|
||||||
|
|
||||||
|
#if defined(DEBUG) || defined (_DEBUG)
|
||||||
|
#include <stdio.h> //for debug printf
|
||||||
|
#ifdef __SPU__
|
||||||
|
#include <spu_printf.h>
|
||||||
|
#define printf spu_printf
|
||||||
|
#endif //__SPU__
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace gjkepa_impl
|
namespace gjkepa_impl
|
||||||
{
|
{
|
||||||
@@ -58,21 +67,18 @@ typedef btMatrix3x3 Rotation;
|
|||||||
// Const
|
// Const
|
||||||
//
|
//
|
||||||
|
|
||||||
static const U chkPrecision =1/U(sizeof(F)==4);
|
|
||||||
|
|
||||||
static const F cstInf =F(1/sin(0.));
|
#define cstInf SIMD_INFINITY
|
||||||
static const F cstPi =F(acos(-1.));
|
#define cstPi SIMD_PI
|
||||||
static const F cst2Pi =cstPi*2;
|
#define cst2Pi SIMD_2_PI
|
||||||
|
#define GJK_maxiterations (128)
|
||||||
static const U GJK_maxiterations =128;
|
#define GJK_hashsize (1<<6)
|
||||||
static const U GJK_hashsize =1<<6;
|
#define GJK_hashmask (GJK_hashsize-1)
|
||||||
static const U GJK_hashmask =GJK_hashsize-1;
|
#define GJK_insimplex_eps F(0.0001)
|
||||||
static const F GJK_insimplex_eps =F(0.0001);
|
#define GJK_sqinsimplex_eps (GJK_insimplex_eps*GJK_insimplex_eps)
|
||||||
static const F GJK_sqinsimplex_eps =GJK_insimplex_eps*GJK_insimplex_eps;
|
#define EPA_maxiterations 256
|
||||||
|
#define EPA_inface_eps F(0.01)
|
||||||
static const U EPA_maxiterations =256;
|
#define EPA_accuracy F(0.001)
|
||||||
static const F EPA_inface_eps =F(0.01);
|
|
||||||
static const F EPA_accuracy =F(0.001);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Utils
|
// Utils
|
||||||
@@ -95,80 +101,7 @@ throw(object); }
|
|||||||
template <typename T> static inline void Raise(const T&) {}
|
template <typename T> static inline void Raise(const T&) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct Block
|
|
||||||
{
|
|
||||||
Block* previous;
|
|
||||||
U1* address;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// StackAlloc
|
|
||||||
//
|
|
||||||
struct StackAlloc
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
StackAlloc() { ctor(); }
|
|
||||||
StackAlloc(U size) { ctor();Create(size); }
|
|
||||||
~StackAlloc() { Free(); }
|
|
||||||
void Create(U size)
|
|
||||||
{
|
|
||||||
Free();
|
|
||||||
data = new U1[size];
|
|
||||||
totalsize = size;
|
|
||||||
}
|
|
||||||
void Free()
|
|
||||||
{
|
|
||||||
if(usedsize==0)
|
|
||||||
{
|
|
||||||
if(!ischild) delete[] data;
|
|
||||||
data = 0;
|
|
||||||
usedsize = 0;
|
|
||||||
} else Raise(L"StackAlloc is still in use");
|
|
||||||
}
|
|
||||||
U1* Allocate(U size)
|
|
||||||
{
|
|
||||||
const U nus(usedsize+size);
|
|
||||||
if(nus<totalsize)
|
|
||||||
{
|
|
||||||
usedsize=nus;
|
|
||||||
return(data+(usedsize-size));
|
|
||||||
}
|
|
||||||
Raise(L"Not enough memory");
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
Block* BeginBlock()
|
|
||||||
{
|
|
||||||
Block* pb = (Block*)Allocate(sizeof(Block));
|
|
||||||
pb->previous = current;
|
|
||||||
pb->address = data+usedsize;
|
|
||||||
current = pb;
|
|
||||||
return(pb);
|
|
||||||
}
|
|
||||||
void EndBlock(Block* block)
|
|
||||||
{
|
|
||||||
if(block==current)
|
|
||||||
{
|
|
||||||
current = block->previous;
|
|
||||||
usedsize = (U)((block->address-data)-sizeof(Block));
|
|
||||||
} else Raise(L"Unmatched blocks");
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void ctor()
|
|
||||||
{
|
|
||||||
data = 0;
|
|
||||||
totalsize = 0;
|
|
||||||
usedsize = 0;
|
|
||||||
current = 0;
|
|
||||||
ischild = false;
|
|
||||||
}
|
|
||||||
U1* data;
|
|
||||||
U totalsize;
|
|
||||||
U usedsize;
|
|
||||||
Block* current;
|
|
||||||
Z ischild;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// GJK
|
// GJK
|
||||||
@@ -185,8 +118,8 @@ struct GJK
|
|||||||
Vector3 v;
|
Vector3 v;
|
||||||
He* n;
|
He* n;
|
||||||
};
|
};
|
||||||
StackAlloc* sa;
|
btStackAlloc* sa;
|
||||||
Block* sablock;
|
btBlock* sablock;
|
||||||
He* table[GJK_hashsize];
|
He* table[GJK_hashsize];
|
||||||
Rotation wrotations[2];
|
Rotation wrotations[2];
|
||||||
Vector3 positions[2];
|
Vector3 positions[2];
|
||||||
@@ -198,7 +131,7 @@ struct GJK
|
|||||||
F margin;
|
F margin;
|
||||||
Z failed;
|
Z failed;
|
||||||
//
|
//
|
||||||
GJK(StackAlloc* psa,
|
GJK(btStackAlloc* psa,
|
||||||
const Rotation& wrot0,const Vector3& pos0,const btConvexShape* shape0,
|
const Rotation& wrot0,const Vector3& pos0,const btConvexShape* shape0,
|
||||||
const Rotation& wrot1,const Vector3& pos1,const btConvexShape* shape1,
|
const Rotation& wrot1,const Vector3& pos1,const btConvexShape* shape1,
|
||||||
F pmargin=0)
|
F pmargin=0)
|
||||||
@@ -206,14 +139,14 @@ struct GJK
|
|||||||
wrotations[0]=wrot0;positions[0]=pos0;shapes[0]=shape0;
|
wrotations[0]=wrot0;positions[0]=pos0;shapes[0]=shape0;
|
||||||
wrotations[1]=wrot1;positions[1]=pos1;shapes[1]=shape1;
|
wrotations[1]=wrot1;positions[1]=pos1;shapes[1]=shape1;
|
||||||
sa =psa;
|
sa =psa;
|
||||||
sablock =sa->BeginBlock();
|
sablock =sa->beginBlock();
|
||||||
margin =pmargin;
|
margin =pmargin;
|
||||||
failed =false;
|
failed =false;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
~GJK()
|
~GJK()
|
||||||
{
|
{
|
||||||
sa->EndBlock(sablock);
|
sa->endBlock(sablock);
|
||||||
}
|
}
|
||||||
// vdh : very dumm hash
|
// vdh : very dumm hash
|
||||||
static inline U Hash(const Vector3& v)
|
static inline U Hash(const Vector3& v)
|
||||||
@@ -243,7 +176,7 @@ struct GJK
|
|||||||
const U h(Hash(ray));
|
const U h(Hash(ray));
|
||||||
He* e = (He*)(table[h]);
|
He* e = (He*)(table[h]);
|
||||||
while(e) { if(e->v==ray) { --order;return(false); } else e=e->n; }
|
while(e) { if(e->v==ray) { --order;return(false); } else e=e->n; }
|
||||||
e=(He*)sa->Allocate(sizeof(He));e->v=ray;e->n=table[h];table[h]=e;
|
e=(He*)sa->allocate(sizeof(He));e->v=ray;e->n=table[h];table[h]=e;
|
||||||
Support(ray,simplex[++order]);
|
Support(ray,simplex[++order]);
|
||||||
return(ray.dot(SPXW(order))>0);
|
return(ray.dot(SPXW(order))>0);
|
||||||
}
|
}
|
||||||
@@ -401,7 +334,7 @@ struct EPA
|
|||||||
};
|
};
|
||||||
//
|
//
|
||||||
GJK* gjk;
|
GJK* gjk;
|
||||||
StackAlloc* sa;
|
btStackAlloc* sa;
|
||||||
Face* root;
|
Face* root;
|
||||||
U nfaces;
|
U nfaces;
|
||||||
U iterations;
|
U iterations;
|
||||||
@@ -464,7 +397,7 @@ c) const
|
|||||||
//
|
//
|
||||||
inline Face* NewFace(const GJK::Mkv* a,const GJK::Mkv* b,const GJK::Mkv* c)
|
inline Face* NewFace(const GJK::Mkv* a,const GJK::Mkv* b,const GJK::Mkv* c)
|
||||||
{
|
{
|
||||||
Face* pf = (Face*)sa->Allocate(sizeof(Face));
|
Face* pf = (Face*)sa->allocate(sizeof(Face));
|
||||||
if(Set(pf,a,b,c))
|
if(Set(pf,a,b,c))
|
||||||
{
|
{
|
||||||
if(root) root->prev=pf;
|
if(root) root->prev=pf;
|
||||||
@@ -506,7 +439,7 @@ c) const
|
|||||||
//
|
//
|
||||||
GJK::Mkv* Support(const Vector3& w) const
|
GJK::Mkv* Support(const Vector3& w) const
|
||||||
{
|
{
|
||||||
GJK::Mkv* v =(GJK::Mkv*)sa->Allocate(sizeof(GJK::Mkv));
|
GJK::Mkv* v =(GJK::Mkv*)sa->allocate(sizeof(GJK::Mkv));
|
||||||
gjk->Support(w,*v);
|
gjk->Support(w,*v);
|
||||||
return(v);
|
return(v);
|
||||||
}
|
}
|
||||||
@@ -540,7 +473,7 @@ ff)
|
|||||||
//
|
//
|
||||||
inline F EvaluatePD(F accuracy=EPA_accuracy)
|
inline F EvaluatePD(F accuracy=EPA_accuracy)
|
||||||
{
|
{
|
||||||
Block* sablock = sa->BeginBlock();
|
btBlock* sablock = sa->beginBlock();
|
||||||
Face* bestface = 0;
|
Face* bestface = 0;
|
||||||
U markid(1);
|
U markid(1);
|
||||||
depth = -cstInf;
|
depth = -cstInf;
|
||||||
@@ -579,7 +512,7 @@ U eidx[9][4]={{0,0,4,0},{0,1,2,1},{0,2,1,2},{1,1,5,2},{1,0,2,0},{2,2,3,2},{3,1,5
|
|||||||
U i;
|
U i;
|
||||||
|
|
||||||
for( i=0;i<=gjk->order;++i) {
|
for( i=0;i<=gjk->order;++i) {
|
||||||
basemkv[i]=(GJK::Mkv*)sa->Allocate(sizeof(GJK::Mkv));*basemkv[i]=gjk->simplex[i];
|
basemkv[i]=(GJK::Mkv*)sa->allocate(sizeof(GJK::Mkv));*basemkv[i]=gjk->simplex[i];
|
||||||
}
|
}
|
||||||
for( i=0;i<nfidx;++i,pfidx+=3) {
|
for( i=0;i<nfidx;++i,pfidx+=3) {
|
||||||
basefaces[i]=NewFace(basemkv[pfidx[0]],basemkv[pfidx[1]],basemkv[pfidx[2]]);
|
basefaces[i]=NewFace(basemkv[pfidx[0]],basemkv[pfidx[1]],basemkv[pfidx[2]]);
|
||||||
@@ -589,7 +522,7 @@ Link(basefaces[peidx[0]],peidx[1],basefaces[peidx[2]],peidx[3]); }
|
|||||||
}
|
}
|
||||||
if(0==nfaces)
|
if(0==nfaces)
|
||||||
{
|
{
|
||||||
sa->EndBlock(sablock);
|
sa->endBlock(sablock);
|
||||||
return(depth);
|
return(depth);
|
||||||
}
|
}
|
||||||
/* Expand hull */
|
/* Expand hull */
|
||||||
@@ -632,7 +565,7 @@ nf+=BuildHorizon(markid,w,*bf->f[i],bf->e[i],cf,ff); }
|
|||||||
nearest[0] = features[0][0]*b.x()+features[0][1]*b.y()+features[0][2]*b.z();
|
nearest[0] = features[0][0]*b.x()+features[0][1]*b.y()+features[0][2]*b.z();
|
||||||
nearest[1] = features[1][0]*b.x()+features[1][1]*b.y()+features[1][2]*b.z();
|
nearest[1] = features[1][0]*b.x()+features[1][1]*b.y()+features[1][2]*b.z();
|
||||||
} else failed=true;
|
} else failed=true;
|
||||||
sa->EndBlock(sablock);
|
sa->endBlock(sablock);
|
||||||
return(depth);
|
return(depth);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -644,17 +577,17 @@ nf+=BuildHorizon(markid,w,*bf->f[i],bf->e[i],cf,ff); }
|
|||||||
|
|
||||||
using namespace gjkepa_impl;
|
using namespace gjkepa_impl;
|
||||||
|
|
||||||
/* Need some kind of stackalloc , create a static one till bullet provide
|
|
||||||
one. */
|
|
||||||
static const U g_sasize((1024<<10)*2);
|
|
||||||
static StackAlloc g_sa(g_sasize);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
bool btGjkEpaSolver::Collide(btConvexShape *shape0,const btTransform &wtrs0,
|
bool btGjkEpaSolver::Collide(btConvexShape *shape0,const btTransform &wtrs0,
|
||||||
btConvexShape *shape1,const btTransform &wtrs1,
|
btConvexShape *shape1,const btTransform &wtrs1,
|
||||||
btScalar radialmargin,
|
btScalar radialmargin,
|
||||||
|
btStackAlloc* stackAlloc,
|
||||||
sResults& results)
|
sResults& results)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/* Initialize */
|
/* Initialize */
|
||||||
results.witnesses[0] =
|
results.witnesses[0] =
|
||||||
results.witnesses[1] =
|
results.witnesses[1] =
|
||||||
@@ -664,7 +597,7 @@ results.status = sResults::Separated;
|
|||||||
results.epa_iterations = 0;
|
results.epa_iterations = 0;
|
||||||
results.gjk_iterations = 0;
|
results.gjk_iterations = 0;
|
||||||
/* Use GJK to locate origin */
|
/* Use GJK to locate origin */
|
||||||
GJK gjk(&g_sa,
|
GJK gjk(stackAlloc,
|
||||||
wtrs0.getBasis(),wtrs0.getOrigin(),shape0,
|
wtrs0.getBasis(),wtrs0.getOrigin(),shape0,
|
||||||
wtrs1.getBasis(),wtrs1.getOrigin(),shape1,
|
wtrs1.getBasis(),wtrs1.getOrigin(),shape1,
|
||||||
radialmargin+EPA_accuracy);
|
radialmargin+EPA_accuracy);
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ Nov.2006
|
|||||||
#define _05E48D53_04E0_49ad_BB0A_D74FE62E7366_
|
#define _05E48D53_04E0_49ad_BB0A_D74FE62E7366_
|
||||||
#include "BulletCollision/CollisionShapes/btConvexShape.h"
|
#include "BulletCollision/CollisionShapes/btConvexShape.h"
|
||||||
|
|
||||||
|
class btStackAlloc;
|
||||||
|
|
||||||
///btGjkEpaSolver contributed under zlib by Nathanael Presson
|
///btGjkEpaSolver contributed under zlib by Nathanael Presson
|
||||||
struct btGjkEpaSolver
|
struct btGjkEpaSolver
|
||||||
{
|
{
|
||||||
@@ -44,6 +46,7 @@ struct sResults
|
|||||||
static bool Collide(btConvexShape* shape0,const btTransform& wtrs0,
|
static bool Collide(btConvexShape* shape0,const btTransform& wtrs0,
|
||||||
btConvexShape* shape1,const btTransform& wtrs1,
|
btConvexShape* shape1,const btTransform& wtrs1,
|
||||||
btScalar radialmargin,
|
btScalar radialmargin,
|
||||||
|
btStackAlloc* stackAlloc,
|
||||||
sResults& results);
|
sResults& results);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& sim
|
|||||||
btConvexShape* pConvexA, btConvexShape* pConvexB,
|
btConvexShape* pConvexA, btConvexShape* pConvexB,
|
||||||
const btTransform& transformA, const btTransform& transformB,
|
const btTransform& transformA, const btTransform& transformB,
|
||||||
btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,
|
btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,
|
||||||
class btIDebugDraw* debugDraw )
|
class btIDebugDraw* debugDraw, btStackAlloc* stackAlloc )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ bool btGjkEpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& sim
|
|||||||
btGjkEpaSolver::sResults results;
|
btGjkEpaSolver::sResults results;
|
||||||
if(btGjkEpaSolver::Collide( pConvexA,transformA,
|
if(btGjkEpaSolver::Collide( pConvexA,transformA,
|
||||||
pConvexB,transformB,
|
pConvexB,transformB,
|
||||||
radialmargin,results))
|
radialmargin,stackAlloc,results))
|
||||||
{
|
{
|
||||||
// debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
|
// debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
|
||||||
//resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
|
//resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class btGjkEpaPenetrationDepthSolver : public btConvexPenetrationDepthSolver
|
|||||||
btConvexShape* pConvexA, btConvexShape* pConvexB,
|
btConvexShape* pConvexA, btConvexShape* pConvexB,
|
||||||
const btTransform& transformA, const btTransform& transformB,
|
const btTransform& transformA, const btTransform& transformB,
|
||||||
btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,
|
btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,
|
||||||
class btIDebugDraw* debugDraw );
|
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc );
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#if defined(DEBUG) || defined (_DEBUG)
|
#if defined(DEBUG) || defined (_DEBUG)
|
||||||
#include <stdio.h> //for debug printf
|
#include <stdio.h> //for debug printf
|
||||||
|
#ifdef __SPU__
|
||||||
|
#include <spu_printf.h>
|
||||||
|
#define printf spu_printf
|
||||||
|
#endif //__SPU__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//must be above the machine epsilon
|
//must be above the machine epsilon
|
||||||
@@ -29,10 +33,7 @@ subject to the following restrictions:
|
|||||||
int gNumDeepPenetrationChecks = 0;
|
int gNumDeepPenetrationChecks = 0;
|
||||||
int gNumGjkChecks = 0;
|
int gNumGjkChecks = 0;
|
||||||
|
|
||||||
#ifdef __SPU__
|
|
||||||
#include <spu_printf.h>
|
|
||||||
#define printf spu_printf
|
|
||||||
#endif //__SPU__
|
|
||||||
|
|
||||||
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(0.f,0.f,1.f),
|
||||||
@@ -202,7 +203,7 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
|
|||||||
normalInB *= rlen; //normalize
|
normalInB *= rlen; //normalize
|
||||||
btScalar s = btSqrt(squaredDistance);
|
btScalar s = btSqrt(squaredDistance);
|
||||||
|
|
||||||
ASSERT(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 = ((1.f/rlen) - margin);
|
||||||
@@ -236,7 +237,7 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
|
|||||||
m_minkowskiA,m_minkowskiB,
|
m_minkowskiA,m_minkowskiB,
|
||||||
localTransA,localTransB,
|
localTransA,localTransB,
|
||||||
m_cachedSeparatingAxis, tmpPointOnA, tmpPointOnB,
|
m_cachedSeparatingAxis, tmpPointOnA, tmpPointOnB,
|
||||||
debugDraw
|
debugDraw,input.m_stackAlloc
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isValid2)
|
if (isValid2)
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ bool btMinkowskiPenetrationDepthSolver::calcPenDepth(btSimplexSolverInterface& s
|
|||||||
btConvexShape* convexA,btConvexShape* convexB,
|
btConvexShape* convexA,btConvexShape* convexB,
|
||||||
const btTransform& transA,const btTransform& transB,
|
const btTransform& transA,const btTransform& transB,
|
||||||
btVector3& v, btPoint3& pa, btPoint3& pb,
|
btVector3& v, btPoint3& pa, btPoint3& pb,
|
||||||
class btIDebugDraw* debugDraw
|
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public:
|
|||||||
btConvexShape* convexA,btConvexShape* convexB,
|
btConvexShape* convexA,btConvexShape* convexB,
|
||||||
const btTransform& transA,const btTransform& transB,
|
const btTransform& transA,const btTransform& transB,
|
||||||
btVector3& v, btPoint3& pa, btPoint3& pb,
|
btVector3& v, btPoint3& pa, btPoint3& pb,
|
||||||
class btIDebugDraw* debugDraw
|
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -86,13 +86,13 @@ public:
|
|||||||
|
|
||||||
inline const btManifoldPoint& getContactPoint(int index) const
|
inline const btManifoldPoint& getContactPoint(int index) const
|
||||||
{
|
{
|
||||||
ASSERT(index < m_cachedPoints);
|
btAssert(index < m_cachedPoints);
|
||||||
return m_pointCache[index];
|
return m_pointCache[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline btManifoldPoint& getContactPoint(int index)
|
inline btManifoldPoint& getContactPoint(int index)
|
||||||
{
|
{
|
||||||
ASSERT(index < m_cachedPoints);
|
btAssert(index < m_cachedPoints);
|
||||||
return m_pointCache[index];
|
return m_pointCache[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
m_1MinvJt = inertiaInvB * m_bJ;
|
m_1MinvJt = inertiaInvB * m_bJ;
|
||||||
m_Adiag = massInvA + m_0MinvJt.dot(m_aJ) + massInvB + m_1MinvJt.dot(m_bJ);
|
m_Adiag = massInvA + m_0MinvJt.dot(m_aJ) + massInvB + m_1MinvJt.dot(m_bJ);
|
||||||
|
|
||||||
ASSERT(m_Adiag > 0.0f);
|
btAssert(m_Adiag > 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//angular constraint between two different rigidbodies
|
//angular constraint between two different rigidbodies
|
||||||
@@ -67,7 +67,7 @@ public:
|
|||||||
m_1MinvJt = inertiaInvB * m_bJ;
|
m_1MinvJt = inertiaInvB * m_bJ;
|
||||||
m_Adiag = m_0MinvJt.dot(m_aJ) + m_1MinvJt.dot(m_bJ);
|
m_Adiag = m_0MinvJt.dot(m_aJ) + m_1MinvJt.dot(m_bJ);
|
||||||
|
|
||||||
ASSERT(m_Adiag > 0.0f);
|
btAssert(m_Adiag > 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//angular constraint between two different rigidbodies
|
//angular constraint between two different rigidbodies
|
||||||
@@ -83,7 +83,7 @@ public:
|
|||||||
m_1MinvJt = inertiaInvB * m_bJ;
|
m_1MinvJt = inertiaInvB * m_bJ;
|
||||||
m_Adiag = m_0MinvJt.dot(m_aJ) + m_1MinvJt.dot(m_bJ);
|
m_Adiag = m_0MinvJt.dot(m_aJ) + m_1MinvJt.dot(m_bJ);
|
||||||
|
|
||||||
ASSERT(m_Adiag > 0.0f);
|
btAssert(m_Adiag > 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//constraint on one rigidbody
|
//constraint on one rigidbody
|
||||||
@@ -101,7 +101,7 @@ public:
|
|||||||
m_1MinvJt = btVector3(0.f,0.f,0.f);
|
m_1MinvJt = btVector3(0.f,0.f,0.f);
|
||||||
m_Adiag = massInvA + m_0MinvJt.dot(m_aJ);
|
m_Adiag = massInvA + m_0MinvJt.dot(m_aJ);
|
||||||
|
|
||||||
ASSERT(m_Adiag > 0.0f);
|
btAssert(m_Adiag > 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
btScalar getDiagonal() const { return m_Adiag; }
|
btScalar getDiagonal() const { return m_Adiag; }
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void btSolve2LinearConstraint::resolveUnilateralPairConstraint(
|
|||||||
if (fabs(len) >= SIMD_EPSILON)
|
if (fabs(len) >= SIMD_EPSILON)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ASSERT(len < SIMD_EPSILON);
|
btAssert(len < SIMD_EPSILON);
|
||||||
|
|
||||||
|
|
||||||
//this jacobian entry could be re-used for all iterations
|
//this jacobian entry could be re-used for all iterations
|
||||||
@@ -133,7 +133,7 @@ void btSolve2LinearConstraint::resolveBilateralPairConstraint(
|
|||||||
if (fabs(len) >= SIMD_EPSILON)
|
if (fabs(len) >= SIMD_EPSILON)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ASSERT(len < SIMD_EPSILON);
|
btAssert(len < SIMD_EPSILON);
|
||||||
|
|
||||||
|
|
||||||
//this jacobian entry could be re-used for all iterations
|
//this jacobian entry could be re-used for all iterations
|
||||||
|
|||||||
@@ -57,19 +57,6 @@ subject to the following restrictions:
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btConstraintSolver* constraintSolver)
|
|
||||||
:btDynamicsWorld(),
|
|
||||||
m_constraintSolver(constraintSolver? constraintSolver: new btSequentialImpulseConstraintSolver),
|
|
||||||
m_debugDrawer(0),
|
|
||||||
m_gravity(0,-10,0),
|
|
||||||
m_localTime(1.f/60.f),
|
|
||||||
m_profileTimings(0)
|
|
||||||
{
|
|
||||||
m_islandManager = new btSimulationIslandManager();
|
|
||||||
m_ownsIslandManager = true;
|
|
||||||
m_ownsConstraintSolver = (constraintSolver==0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver)
|
btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver)
|
||||||
:btDynamicsWorld(dispatcher,pairCache),
|
:btDynamicsWorld(dispatcher,pairCache),
|
||||||
@@ -267,27 +254,27 @@ void btDiscreteDynamicsWorld::internalSingleStepSimulation(float timeStep)
|
|||||||
///apply gravity, predict motion
|
///apply gravity, predict motion
|
||||||
predictUnconstraintMotion(timeStep);
|
predictUnconstraintMotion(timeStep);
|
||||||
|
|
||||||
btDispatcherInfo dispatchInfo;
|
btDispatcherInfo& dispatchInfo = getDispatchInfo();
|
||||||
|
|
||||||
dispatchInfo.m_timeStep = timeStep;
|
dispatchInfo.m_timeStep = timeStep;
|
||||||
dispatchInfo.m_stepCount = 0;
|
dispatchInfo.m_stepCount = 0;
|
||||||
dispatchInfo.m_debugDraw = getDebugDrawer();
|
dispatchInfo.m_debugDraw = getDebugDrawer();
|
||||||
|
|
||||||
|
|
||||||
///perform collision detection
|
///perform collision detection
|
||||||
performDiscreteCollisionDetection(dispatchInfo);
|
performDiscreteCollisionDetection(dispatchInfo);
|
||||||
|
|
||||||
calculateSimulationIslands();
|
calculateSimulationIslands();
|
||||||
|
|
||||||
btContactSolverInfo infoGlobal;
|
|
||||||
infoGlobal.m_timeStep = timeStep;
|
getSolverInfo().m_timeStep = timeStep;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///solve non-contact constraints
|
///solve non-contact constraints
|
||||||
solveNoncontactConstraints(infoGlobal);
|
solveNoncontactConstraints(getSolverInfo());
|
||||||
|
|
||||||
///solve contact constraints
|
///solve contact constraints
|
||||||
solveContactConstraints(infoGlobal);
|
solveContactConstraints(getSolverInfo());
|
||||||
|
|
||||||
///CallbackTriggers();
|
///CallbackTriggers();
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ class btOverlappingPairCache;
|
|||||||
class btConstraintSolver;
|
class btConstraintSolver;
|
||||||
class btSimulationIslandManager;
|
class btSimulationIslandManager;
|
||||||
class btTypedConstraint;
|
class btTypedConstraint;
|
||||||
struct btContactSolverInfo;
|
#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
|
||||||
|
|
||||||
class btRaycastVehicle;
|
class btRaycastVehicle;
|
||||||
class btIDebugDraw;
|
class btIDebugDraw;
|
||||||
|
|
||||||
@@ -52,6 +53,9 @@ protected:
|
|||||||
bool m_ownsIslandManager;
|
bool m_ownsIslandManager;
|
||||||
bool m_ownsConstraintSolver;
|
bool m_ownsConstraintSolver;
|
||||||
|
|
||||||
|
btContactSolverInfo m_solverInfo;
|
||||||
|
|
||||||
|
|
||||||
std::vector<btRaycastVehicle*> m_vehicles;
|
std::vector<btRaycastVehicle*> m_vehicles;
|
||||||
|
|
||||||
int m_profileTimings;
|
int m_profileTimings;
|
||||||
@@ -83,10 +87,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
///this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete those
|
///this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete those
|
||||||
btDiscreteDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver=0);
|
btDiscreteDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver);
|
||||||
|
|
||||||
///this btDiscreteDynamicsWorld will create and own dispatcher, pairCache and constraintSolver, and deletes it in the destructor.
|
|
||||||
btDiscreteDynamicsWorld(btConstraintSolver* constraintSolver = 0);
|
|
||||||
|
|
||||||
virtual ~btDiscreteDynamicsWorld();
|
virtual ~btDiscreteDynamicsWorld();
|
||||||
|
|
||||||
@@ -144,6 +145,11 @@ public:
|
|||||||
|
|
||||||
virtual const btTypedConstraint* getConstraint(int index) const;
|
virtual const btTypedConstraint* getConstraint(int index) const;
|
||||||
|
|
||||||
|
btContactSolverInfo& getSolverInfo()
|
||||||
|
{
|
||||||
|
return m_solverInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ class btDynamicsWorld : public btCollisionWorld
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
btDynamicsWorld()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
btDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache)
|
btDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache)
|
||||||
:btCollisionWorld(dispatcher,pairCache)
|
:btCollisionWorld(dispatcher,pairCache)
|
||||||
|
|||||||
@@ -22,13 +22,7 @@ subject to the following restrictions:
|
|||||||
#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
|
#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
|
||||||
|
|
||||||
|
|
||||||
btSimpleDynamicsWorld::btSimpleDynamicsWorld()
|
|
||||||
:m_constraintSolver(new btSequentialImpulseConstraintSolver),
|
|
||||||
m_ownsConstraintSolver(true),
|
|
||||||
m_debugDrawer(0),
|
|
||||||
m_gravity(0,0,-10)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
btSimpleDynamicsWorld::btSimpleDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver)
|
btSimpleDynamicsWorld::btSimpleDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver)
|
||||||
:btDynamicsWorld(dispatcher,pairCache),
|
:btDynamicsWorld(dispatcher,pairCache),
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ protected:
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
///this btSimpleDynamicsWorld constructor creates and owns dispatcher, broadphase pairCache and constraintSolver
|
|
||||||
btSimpleDynamicsWorld();
|
|
||||||
|
|
||||||
///this btSimpleDynamicsWorld constructor creates dispatcher, broadphase pairCache and constraintSolver
|
///this btSimpleDynamicsWorld constructor creates dispatcher, broadphase pairCache and constraintSolver
|
||||||
btSimpleDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver);
|
btSimpleDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver);
|
||||||
|
|||||||
@@ -386,21 +386,21 @@ void btRaycastVehicle::applyEngineForce(btScalar force, int wheel)
|
|||||||
|
|
||||||
const btWheelInfo& btRaycastVehicle::getWheelInfo(int index) const
|
const btWheelInfo& btRaycastVehicle::getWheelInfo(int index) const
|
||||||
{
|
{
|
||||||
ASSERT((index >= 0) && (index < getNumWheels()));
|
btAssert((index >= 0) && (index < getNumWheels()));
|
||||||
|
|
||||||
return m_wheelInfo[index];
|
return m_wheelInfo[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
btWheelInfo& btRaycastVehicle::getWheelInfo(int index)
|
btWheelInfo& btRaycastVehicle::getWheelInfo(int index)
|
||||||
{
|
{
|
||||||
ASSERT((index >= 0) && (index < getNumWheels()));
|
btAssert((index >= 0) && (index < getNumWheels()));
|
||||||
|
|
||||||
return m_wheelInfo[index];
|
return m_wheelInfo[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void btRaycastVehicle::setBrake(float brake,int wheelIndex)
|
void btRaycastVehicle::setBrake(float brake,int wheelIndex)
|
||||||
{
|
{
|
||||||
ASSERT((wheelIndex >= 0) && (wheelIndex < getNumWheels()));
|
btAssert((wheelIndex >= 0) && (wheelIndex < getNumWheels()));
|
||||||
getWheelInfo(wheelIndex).m_brake;
|
getWheelInfo(wheelIndex).m_brake;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ subject to the following restrictions:
|
|||||||
//#define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
|
//#define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
|
||||||
#define ATTRIBUTE_ALIGNED16(a) a
|
#define ATTRIBUTE_ALIGNED16(a) a
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#define ASSERT assert
|
#define btAssert assert
|
||||||
#else
|
#else
|
||||||
|
|
||||||
//non-windows systems
|
//non-windows systems
|
||||||
@@ -47,7 +47,7 @@ subject to the following restrictions:
|
|||||||
#ifndef assert
|
#ifndef assert
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#endif
|
#endif
|
||||||
#define ASSERT assert
|
#define btAssert assert
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user