- removed warnings in GLUI, thanks Jorrit Tyberghein for the patch!
- removed memory leaks from BasicDemo and Bullet library (other demos needs to be cleaned up!) - added memory leak debugging functionality in btAlignedAlloc.h: #define BT_DEBUG_MEMORY_ALLOCATIONS
This commit is contained in:
@@ -18,31 +18,93 @@ subject to the following restrictions:
|
|||||||
#include "../CcdPhysicsDemo/CcdPhysicsDemo.h"
|
#include "../CcdPhysicsDemo/CcdPhysicsDemo.h"
|
||||||
#include "../BspDemo/BspDemo.h"
|
#include "../BspDemo/BspDemo.h"
|
||||||
#include "../BasicDemo/BasicDemo.h"
|
#include "../BasicDemo/BasicDemo.h"
|
||||||
#include "../ConcaveDemo/ConcaveDemo.h"
|
#include "../ConcaveDemo/ConcaveDemo.h"
|
||||||
#include "../ConvexDecompositionDemo/ConvexDecompositionDemo.h"
|
#include "../ConvexDecompositionDemo/ConvexDecompositionDemo.h"
|
||||||
#include "../RagdollDemo/RagdollDemo.h"
|
#include "../RagdollDemo/RagdollDemo.h"
|
||||||
#include "../GimpactTestDemo/GimpactTestDemo.h"
|
#include "../GimpactTestDemo/GimpactTestDemo.h"
|
||||||
#include "../Raytracer/Raytracer.h"
|
#include "../Raytracer/Raytracer.h"
|
||||||
#include "../GjkConvexCastDemo/LinearConvexCastDemo.h"
|
#include "../GjkConvexCastDemo/LinearConvexCastDemo.h"
|
||||||
#include "../VehicleDemo/VehicleDemo.h"
|
#include "../VehicleDemo/VehicleDemo.h"
|
||||||
#include "../ConstraintDemo/ConstraintDemo.h"
|
#include "../ConstraintDemo/ConstraintDemo.h"
|
||||||
|
|
||||||
|
#include "GlutStuff.h"//OpenGL stuff
|
||||||
|
#include "BMF_Api.h"//font stuff
|
||||||
|
|
||||||
|
extern int gNumAlignedAllocs;
|
||||||
|
extern int gNumAlignedFree;
|
||||||
|
extern int gTotalBytesAlignedAllocs;
|
||||||
|
|
||||||
|
class btEmptyDebugDemo : public DemoApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
btEmptyDebugDemo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void clientMoveAndDisplay()
|
||||||
|
{
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
float xOffset = 10.f;
|
||||||
|
float yStart = 20.f;
|
||||||
|
float yIncr = 20.f;
|
||||||
|
char buf[124];
|
||||||
|
|
||||||
|
|
||||||
|
glColor3f(0, 0, 0);
|
||||||
|
|
||||||
|
setOrthographicProjection();
|
||||||
|
|
||||||
|
glRasterPos3f(xOffset,yStart,0);
|
||||||
|
sprintf(buf,"gNumAlignedAllocs= %d",gNumAlignedAllocs);
|
||||||
|
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
||||||
|
yStart += yIncr;
|
||||||
|
|
||||||
|
glRasterPos3f(xOffset,yStart,0);
|
||||||
|
sprintf(buf,"gNumAlignedFree= %d",gNumAlignedFree);
|
||||||
|
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
||||||
|
yStart += yIncr;
|
||||||
|
|
||||||
|
glRasterPos3f(xOffset,yStart,0);
|
||||||
|
sprintf(buf,"# alloc-free = %d",gNumAlignedAllocs-gNumAlignedFree);
|
||||||
|
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
||||||
|
yStart += yIncr;
|
||||||
|
#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
|
||||||
|
glRasterPos3f(xOffset,yStart,0);
|
||||||
|
sprintf(buf,"gTotalBytesAlignedAllocs = %d",gTotalBytesAlignedAllocs);
|
||||||
|
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
||||||
|
yStart += yIncr;
|
||||||
|
#endif //BT_DEBUG_MEMORY_ALLOCATIONS
|
||||||
|
|
||||||
|
glFlush();
|
||||||
|
glutSwapBuffers();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static DemoApplication* Create()
|
||||||
|
{
|
||||||
|
btEmptyDebugDemo* demo = new btEmptyDebugDemo();
|
||||||
|
demo->myinit();
|
||||||
|
return demo;
|
||||||
|
}
|
||||||
|
|
||||||
btDemoEntry g_demoEntries[] =
|
};
|
||||||
{
|
|
||||||
{"RagdollDemo",RagdollDemo::Create},
|
btDemoEntry g_demoEntries[] =
|
||||||
{"ConvexDecomposition",ConvexDecompositionDemo::Create},
|
{
|
||||||
{"CcdPhysicsDemo", CcdPhysicsDemo::Create},
|
{"BasicDemo", BasicDemo::Create},
|
||||||
{"BasicDemo", BasicDemo::Create},
|
{"RagdollDemo",RagdollDemo::Create},
|
||||||
{"BspDemo", BspDemo::Create},
|
{"ConvexDecomposition",ConvexDecompositionDemo::Create},
|
||||||
{"ConcaveDemo",ConcaveDemo::Create},
|
{"CcdPhysicsDemo", CcdPhysicsDemo::Create},
|
||||||
{"Gimpact Test", GimpactConcaveDemo::Create},
|
{"BspDemo", BspDemo::Create},
|
||||||
{"Raytracer Test",Raytracer::Create},
|
{"ConcaveDemo",ConcaveDemo::Create},
|
||||||
{"GjkConvexCast",LinearConvexCastDemo::Create},
|
{"Gimpact Test", GimpactConcaveDemo::Create},
|
||||||
{"VehicleDemo",VehicleDemo::Create},
|
{"Raytracer Test",Raytracer::Create},
|
||||||
{"ConstraintDemo",ConstraintDemo::Create},
|
{"GjkConvexCast",LinearConvexCastDemo::Create},
|
||||||
{0, 0}
|
{"VehicleDemo",VehicleDemo::Create},
|
||||||
|
{"ConstraintDemo",ConstraintDemo::Create},
|
||||||
|
{"MemoryLeakChecker",btEmptyDebugDemo::Create},
|
||||||
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ void BasicDemo::initPhysics()
|
|||||||
setCameraDistance(btScalar(50.));
|
setCameraDistance(btScalar(50.));
|
||||||
|
|
||||||
|
|
||||||
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
|
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||||
|
|
||||||
#ifdef USE_PARALLEL_DISPATCHER
|
#ifdef USE_PARALLEL_DISPATCHER
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ void BasicDemo::initPhysics()
|
|||||||
|
|
||||||
m_dispatcher = new SpuGatheringCollisionDispatcher(threadSupport,maxNumOutstandingTasks,collisionConfiguration);
|
m_dispatcher = new SpuGatheringCollisionDispatcher(threadSupport,maxNumOutstandingTasks,collisionConfiguration);
|
||||||
#else
|
#else
|
||||||
m_dispatcher = new btCollisionDispatcher(collisionConfiguration);
|
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||||
#endif //USE_PARALLEL_DISPATCHER
|
#endif //USE_PARALLEL_DISPATCHER
|
||||||
|
|
||||||
#define USE_SWEEP_AND_PRUNE 1
|
#define USE_SWEEP_AND_PRUNE 1
|
||||||
@@ -172,9 +172,9 @@ void BasicDemo::initPhysics()
|
|||||||
#ifdef USE_SIMPLE_DYNAMICS_WORLD
|
#ifdef USE_SIMPLE_DYNAMICS_WORLD
|
||||||
//btSimpleDynamicsWorld doesn't support 'cache friendly' optimization, so disable this
|
//btSimpleDynamicsWorld doesn't support 'cache friendly' optimization, so disable this
|
||||||
sol->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER);
|
sol->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER);
|
||||||
m_dynamicsWorld = new btSimpleDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,collisionConfiguration);
|
m_dynamicsWorld = new btSimpleDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration);
|
||||||
#else
|
#else
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,collisionConfiguration);
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration);
|
||||||
#endif //USE_SIMPLE_DYNAMICS_WORLD
|
#endif //USE_SIMPLE_DYNAMICS_WORLD
|
||||||
m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
|
m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
|
||||||
|
|
||||||
@@ -246,6 +246,11 @@ void BasicDemo::exitPhysics()
|
|||||||
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
|
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
|
||||||
{
|
{
|
||||||
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
|
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
|
||||||
|
btRigidBody* body = btRigidBody::upcast(obj);
|
||||||
|
if (body && body->getMotionState())
|
||||||
|
{
|
||||||
|
delete body->getMotionState();
|
||||||
|
}
|
||||||
m_dynamicsWorld->removeCollisionObject( obj );
|
m_dynamicsWorld->removeCollisionObject( obj );
|
||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
@@ -269,6 +274,8 @@ void BasicDemo::exitPhysics()
|
|||||||
//delete dispatcher
|
//delete dispatcher
|
||||||
delete m_dispatcher;
|
delete m_dispatcher;
|
||||||
|
|
||||||
|
delete m_collisionConfiguration;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class btOverlappingPairCache;
|
|||||||
class btCollisionDispatcher;
|
class btCollisionDispatcher;
|
||||||
class btConstraintSolver;
|
class btConstraintSolver;
|
||||||
struct btCollisionAlgorithmCreateFunc;
|
struct btCollisionAlgorithmCreateFunc;
|
||||||
|
class btDefaultCollisionConfiguration;
|
||||||
|
|
||||||
///BasicDemo is good starting point for learning the code base and porting.
|
///BasicDemo is good starting point for learning the code base and porting.
|
||||||
class BasicDemo : public DemoApplication
|
class BasicDemo : public DemoApplication
|
||||||
@@ -42,8 +43,17 @@ class BasicDemo : public DemoApplication
|
|||||||
btCollisionAlgorithmCreateFunc* m_sphereBoxCF;
|
btCollisionAlgorithmCreateFunc* m_sphereBoxCF;
|
||||||
btCollisionAlgorithmCreateFunc* m_boxSphereCF;
|
btCollisionAlgorithmCreateFunc* m_boxSphereCF;
|
||||||
|
|
||||||
|
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
BasicDemo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~BasicDemo()
|
||||||
|
{
|
||||||
|
exitPhysics();
|
||||||
|
}
|
||||||
void initPhysics();
|
void initPhysics();
|
||||||
|
|
||||||
void exitPhysics();
|
void exitPhysics();
|
||||||
|
|||||||
@@ -116,39 +116,7 @@ int shapeIndex[maxNumObjects];
|
|||||||
// btPoint3(50,0,0));
|
// btPoint3(50,0,0));
|
||||||
static const int numShapes = 4;
|
static const int numShapes = 4;
|
||||||
|
|
||||||
btCollisionShape* shapePtr[numShapes] =
|
btCollisionShape* shapePtr[numShapes] = {0,0,0,0};
|
||||||
{
|
|
||||||
///Please don't make the box sizes larger then 1000: the collision detection will be inaccurate.
|
|
||||||
///See http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=346
|
|
||||||
|
|
||||||
//#define USE_GROUND_PLANE 1
|
|
||||||
#ifdef USE_GROUND_PLANE
|
|
||||||
new btStaticPlaneShape(btVector3(0,1,0),0.5),
|
|
||||||
#else
|
|
||||||
new btBoxShape (btVector3(200,CUBE_HALF_EXTENTS,200)),
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DO_BENCHMARK_PYRAMIDS
|
|
||||||
new btBoxShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS)),
|
|
||||||
#else
|
|
||||||
new btCylinderShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS)),
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//new btSphereShape (CUBE_HALF_EXTENTS),
|
|
||||||
//new btCapsuleShape(0.5*CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS),
|
|
||||||
//new btCylinderShape (btVector3(1-gCollisionMargin,CUBE_HALF_EXTENTS-gCollisionMargin,1-gCollisionMargin)),
|
|
||||||
//new btConeShapeX(CUBE_HALF_EXTENTS,2.f*CUBE_HALF_EXTENTS),
|
|
||||||
|
|
||||||
new btSphereShape (CUBE_HALF_EXTENTS),
|
|
||||||
|
|
||||||
//new btBU_Simplex1to4(btPoint3(-1,-1,-1),btPoint3(1,-1,-1),btPoint3(-1,1,-1),btPoint3(0,0,1)),
|
|
||||||
|
|
||||||
//new btEmptyShape(),
|
|
||||||
|
|
||||||
new btBoxShape (btVector3(0.4,1,0.8))
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void CcdPhysicsDemo::createStack( btCollisionShape* boxShape, float halfCubeSize, int size, float zPos )
|
void CcdPhysicsDemo::createStack( btCollisionShape* boxShape, float halfCubeSize, int size, float zPos )
|
||||||
{
|
{
|
||||||
@@ -363,6 +331,39 @@ float myFrictionModel( btRigidBody& body1, btRigidBody& body2, btManifoldPoint&
|
|||||||
void CcdPhysicsDemo::initPhysics()
|
void CcdPhysicsDemo::initPhysics()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
shapePtr[0] =
|
||||||
|
///Please don't make the box sizes larger then 1000: the collision detection will be inaccurate.
|
||||||
|
///See http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=346
|
||||||
|
|
||||||
|
//#define USE_GROUND_PLANE 1
|
||||||
|
#ifdef USE_GROUND_PLANE
|
||||||
|
new btStaticPlaneShape(btVector3(0,1,0),0.5);
|
||||||
|
#else
|
||||||
|
new btBoxShape (btVector3(200,CUBE_HALF_EXTENTS,200));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
shapePtr[1] =
|
||||||
|
#ifdef DO_BENCHMARK_PYRAMIDS
|
||||||
|
new btBoxShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS));
|
||||||
|
#else
|
||||||
|
new btCylinderShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
shapePtr[2] =
|
||||||
|
//new btSphereShape (CUBE_HALF_EXTENTS);
|
||||||
|
//new btCapsuleShape(0.5*CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS);
|
||||||
|
//new btCylinderShape (btVector3(1-gCollisionMargin,CUBE_HALF_EXTENTS-gCollisionMargin,1-gCollisionMargin));
|
||||||
|
//new btConeShapeX(CUBE_HALF_EXTENTS,2.f*CUBE_HALF_EXTENTS);
|
||||||
|
|
||||||
|
new btSphereShape (CUBE_HALF_EXTENTS);
|
||||||
|
|
||||||
|
//new btBU_Simplex1to4(btPoint3(-1,-1,-1),btPoint3(1,-1,-1),btPoint3(-1,1,-1),btPoint3(0,0,1));
|
||||||
|
|
||||||
|
//new btEmptyShape();
|
||||||
|
|
||||||
|
shapePtr[3] = new btBoxShape (btVector3(0.4,1,0.8));
|
||||||
|
|
||||||
|
|
||||||
#ifdef DO_BENCHMARK_PYRAMIDS
|
#ifdef DO_BENCHMARK_PYRAMIDS
|
||||||
setCameraDistance(2.5f);
|
setCameraDistance(2.5f);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ extern int gNumDeepPenetrationChecks;
|
|||||||
extern int gNumGjkChecks;
|
extern int gNumGjkChecks;
|
||||||
extern int gNumAlignedAllocs;
|
extern int gNumAlignedAllocs;
|
||||||
extern int gNumAlignedFree;
|
extern int gNumAlignedFree;
|
||||||
|
extern int gTotalBytesAlignedAllocs;
|
||||||
|
|
||||||
#endif //
|
#endif //
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ DemoApplication::DemoApplication()
|
|||||||
:
|
:
|
||||||
m_dynamicsWorld(0),
|
m_dynamicsWorld(0),
|
||||||
m_pickConstraint(0),
|
m_pickConstraint(0),
|
||||||
|
m_shootBoxShape(0),
|
||||||
m_cameraDistance(15.0),
|
m_cameraDistance(15.0),
|
||||||
m_debugMode(0),
|
m_debugMode(0),
|
||||||
m_ele(20.f),
|
m_ele(20.f),
|
||||||
@@ -75,6 +77,8 @@ m_pickConstraint(0),
|
|||||||
|
|
||||||
DemoApplication::~DemoApplication()
|
DemoApplication::~DemoApplication()
|
||||||
{
|
{
|
||||||
|
if (m_shootBoxShape)
|
||||||
|
delete m_shootBoxShape;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,14 +465,19 @@ void DemoApplication::shootBox(const btVector3& destination)
|
|||||||
startTransform.setIdentity();
|
startTransform.setIdentity();
|
||||||
btVector3 camPos = getCameraPosition();
|
btVector3 camPos = getCameraPosition();
|
||||||
startTransform.setOrigin(camPos);
|
startTransform.setOrigin(camPos);
|
||||||
//#define TEST_UNIFORM_SCALING_SHAPE 1
|
|
||||||
|
if (!m_shootBoxShape)
|
||||||
|
{
|
||||||
|
//#define TEST_UNIFORM_SCALING_SHAPE 1
|
||||||
#ifdef TEST_UNIFORM_SCALING_SHAPE
|
#ifdef TEST_UNIFORM_SCALING_SHAPE
|
||||||
btConvexShape* childShape = new btBoxShape(btVector3(1.f,1.f,1.f));
|
btConvexShape* childShape = new btBoxShape(btVector3(1.f,1.f,1.f));
|
||||||
btUniformScalingShape* boxShape = new btUniformScalingShape(childShape,0.5f);
|
m_shootBoxShape = new btUniformScalingShape(childShape,0.5f);
|
||||||
#else
|
#else
|
||||||
btCollisionShape* boxShape = new btBoxShape(btVector3(0.5f,0.5f,0.5f));
|
m_shootBoxShape = new btBoxShape(btVector3(0.5f,0.5f,0.5f));
|
||||||
#endif//
|
#endif//
|
||||||
btRigidBody* body = this->localCreateRigidBody(mass, startTransform,boxShape);
|
}
|
||||||
|
|
||||||
|
btRigidBody* body = this->localCreateRigidBody(mass, startTransform,m_shootBoxShape);
|
||||||
|
|
||||||
btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]);
|
btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]);
|
||||||
linVel.normalize();
|
linVel.normalize();
|
||||||
@@ -701,7 +710,8 @@ btRigidBody* DemoApplication::localCreateRigidBody(float mass, const btTransform
|
|||||||
btRigidBody* body = new btRigidBody(mass,myMotionState,shape,localInertia);
|
btRigidBody* body = new btRigidBody(mass,myMotionState,shape,localInertia);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
btRigidBody* body = new btRigidBody(mass,startTransform,shape,localInertia);
|
btRigidBody* body = new btRigidBody(mass,0,shape,localInertia);
|
||||||
|
body->setWorldTransform(startTransform);
|
||||||
#endif//
|
#endif//
|
||||||
m_dynamicsWorld->addRigidBody(body);
|
m_dynamicsWorld->addRigidBody(body);
|
||||||
|
|
||||||
@@ -923,6 +933,28 @@ void DemoApplication::renderme()
|
|||||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
||||||
yStart += yIncr;
|
yStart += yIncr;
|
||||||
|
|
||||||
|
//enable BT_DEBUG_MEMORY_ALLOCATIONS define in Bullet/src/LinearMath/btAlignedAllocator.h for memory leak detection
|
||||||
|
#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
|
||||||
|
glRasterPos3f(xOffset,yStart,0);
|
||||||
|
sprintf(buf,"gTotalBytesAlignedAllocs = %d",gTotalBytesAlignedAllocs);
|
||||||
|
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
||||||
|
yStart += yIncr;
|
||||||
|
#endif //BT_DEBUG_MEMORY_ALLOCATIONS
|
||||||
|
|
||||||
|
if (getDynamicsWorld())
|
||||||
|
{
|
||||||
|
glRasterPos3f(xOffset,yStart,0);
|
||||||
|
sprintf(buf,"# objects = %d",getDynamicsWorld()->getNumCollisionObjects());
|
||||||
|
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
||||||
|
yStart += yIncr;
|
||||||
|
glRasterPos3f(xOffset,yStart,0);
|
||||||
|
sprintf(buf,"# pairs = %d",getDynamicsWorld()->getBroadphase()->getOverlappingPairCache()->getNumOverlappingPairs());
|
||||||
|
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
|
||||||
|
yStart += yIncr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif //SHOW_NUM_DEEP_PENETRATIONS
|
#endif //SHOW_NUM_DEEP_PENETRATIONS
|
||||||
|
|
||||||
resetPerspectiveProjection();
|
resetPerspectiveProjection();
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ class DemoApplication
|
|||||||
///constraint for mouse picking
|
///constraint for mouse picking
|
||||||
btTypedConstraint* m_pickConstraint;
|
btTypedConstraint* m_pickConstraint;
|
||||||
|
|
||||||
|
btCollisionShape* m_shootBoxShape;
|
||||||
|
|
||||||
float m_cameraDistance;
|
float m_cameraDistance;
|
||||||
int m_debugMode;
|
int m_debugMode;
|
||||||
|
|
||||||
|
|||||||
@@ -757,7 +757,7 @@ public:
|
|||||||
void *font;
|
void *font;
|
||||||
int curr_modifiers;
|
int curr_modifiers;
|
||||||
|
|
||||||
void adjust_glut_xy( int &x, int &y ) { x; y = h-y; }
|
void adjust_glut_xy( int &x, int &y ) { (void)x; y = h-y; }
|
||||||
void activate_control( GLUI_Control *control, int how );
|
void activate_control( GLUI_Control *control, int how );
|
||||||
void align_controls( GLUI_Control *control );
|
void align_controls( GLUI_Control *control );
|
||||||
void deactivate_current_control( void );
|
void deactivate_current_control( void );
|
||||||
@@ -884,19 +884,19 @@ public:
|
|||||||
virtual int get_id( void ) const { return user_id; }
|
virtual int get_id( void ) const { return user_id; }
|
||||||
virtual void set_id( int id ) { user_id=id; }
|
virtual void set_id( int id ) { user_id=id; }
|
||||||
|
|
||||||
virtual int mouse_down_handler( int local_x, int local_y ) { local_x; local_y; return false; }
|
virtual int mouse_down_handler( int local_x, int local_y ) { (void)local_x; (void)local_y; return false; }
|
||||||
virtual int mouse_up_handler( int local_x, int local_y, bool inside ) { local_x; local_y; inside; return false; }
|
virtual int mouse_up_handler( int local_x, int local_y, bool inside ) { (void)local_x; (void)local_y; (void)inside; return false; }
|
||||||
virtual int mouse_held_down_handler( int local_x, int local_y, bool inside) { local_x; local_y; inside; return false; }
|
virtual int mouse_held_down_handler( int local_x, int local_y, bool inside) { (void)local_x; (void)local_y; (void)inside; return false; }
|
||||||
virtual int key_handler( unsigned char key, int modifiers ) { key; modifiers; return false; }
|
virtual int key_handler( unsigned char key, int modifiers ) { (void)key; (void)modifiers; return false; }
|
||||||
virtual int special_handler( int key,int modifiers ) { key; modifiers; return false; }
|
virtual int special_handler( int key,int modifiers ) { (void)key; (void)modifiers; return false; }
|
||||||
|
|
||||||
virtual void update_size( void ) { }
|
virtual void update_size( void ) { }
|
||||||
virtual void idle( void ) { }
|
virtual void idle( void ) { }
|
||||||
virtual int mouse_over( int state, int x, int y ) { state; x; y; return false; }
|
virtual int mouse_over( int state, int x, int y ) { (void)state; (void)x; (void)y; return false; }
|
||||||
|
|
||||||
virtual void enable( void );
|
virtual void enable( void );
|
||||||
virtual void disable( void );
|
virtual void disable( void );
|
||||||
virtual void activate( int how ) { how; active = true; }
|
virtual void activate( int how ) { (void)how; active = true; }
|
||||||
virtual void deactivate( void ) { active = false; }
|
virtual void deactivate( void ) { active = false; }
|
||||||
|
|
||||||
/** Hide (shrink into a rollout) and unhide (expose from a rollout) */
|
/** Hide (shrink into a rollout) and unhide (expose from a rollout) */
|
||||||
@@ -955,7 +955,7 @@ public:
|
|||||||
void sync_live( int recurse, int draw ); /* Reads live variable */
|
void sync_live( int recurse, int draw ); /* Reads live variable */
|
||||||
void init_live( void );
|
void init_live( void );
|
||||||
void output_live( int update_main_gfx ); /** Writes live variable **/
|
void output_live( int update_main_gfx ); /** Writes live variable **/
|
||||||
virtual void set_text( const char *t ) { t; }
|
virtual void set_text( const char *t ) { (void)t; }
|
||||||
void execute_callback( void );
|
void execute_callback( void );
|
||||||
void get_this_column_dims( int *col_x, int *col_y,
|
void get_this_column_dims( int *col_x, int *col_y,
|
||||||
int *col_w, int *col_h,
|
int *col_w, int *col_h,
|
||||||
|
|||||||
@@ -288,6 +288,7 @@ btAxisSweep3Internal<BP_FP_INT_TYPE>::~btAxisSweep3Internal()
|
|||||||
|
|
||||||
if (m_ownsPairCache)
|
if (m_ownsPairCache)
|
||||||
{
|
{
|
||||||
|
m_pairCache->~btOverlappingPairCache();
|
||||||
btAlignedFree(m_pairCache);
|
btAlignedFree(m_pairCache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,30 +124,52 @@ btDefaultCollisionConfiguration::~btDefaultCollisionConfiguration()
|
|||||||
if (m_ownsStackAllocator)
|
if (m_ownsStackAllocator)
|
||||||
{
|
{
|
||||||
m_stackAlloc->destroy();
|
m_stackAlloc->destroy();
|
||||||
|
m_stackAlloc->~btStackAlloc();
|
||||||
btAlignedFree(m_stackAlloc);
|
btAlignedFree(m_stackAlloc);
|
||||||
}
|
}
|
||||||
if (m_ownsCollisionAlgorithmPool)
|
if (m_ownsCollisionAlgorithmPool)
|
||||||
{
|
{
|
||||||
|
m_collisionAlgorithmPool->~btPoolAllocator();
|
||||||
btAlignedFree(m_collisionAlgorithmPool);
|
btAlignedFree(m_collisionAlgorithmPool);
|
||||||
}
|
}
|
||||||
if (m_ownsPersistentManifoldPool)
|
if (m_ownsPersistentManifoldPool)
|
||||||
{
|
{
|
||||||
|
m_persistentManifoldPool->~btPoolAllocator();
|
||||||
btAlignedFree(m_persistentManifoldPool);
|
btAlignedFree(m_persistentManifoldPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_convexConvexCreateFunc->~btCollisionAlgorithmCreateFunc();
|
||||||
btAlignedFree( m_convexConvexCreateFunc);
|
btAlignedFree( m_convexConvexCreateFunc);
|
||||||
|
|
||||||
|
m_convexConcaveCreateFunc->~btCollisionAlgorithmCreateFunc();
|
||||||
btAlignedFree( m_convexConcaveCreateFunc);
|
btAlignedFree( m_convexConcaveCreateFunc);
|
||||||
|
m_swappedConvexConcaveCreateFunc->~btCollisionAlgorithmCreateFunc();
|
||||||
btAlignedFree( m_swappedConvexConcaveCreateFunc);
|
btAlignedFree( m_swappedConvexConcaveCreateFunc);
|
||||||
|
|
||||||
|
m_compoundCreateFunc->~btCollisionAlgorithmCreateFunc();
|
||||||
btAlignedFree( m_compoundCreateFunc);
|
btAlignedFree( m_compoundCreateFunc);
|
||||||
|
|
||||||
|
m_swappedCompoundCreateFunc->~btCollisionAlgorithmCreateFunc();
|
||||||
btAlignedFree( m_swappedCompoundCreateFunc);
|
btAlignedFree( m_swappedCompoundCreateFunc);
|
||||||
|
|
||||||
|
m_emptyCreateFunc->~btCollisionAlgorithmCreateFunc();
|
||||||
btAlignedFree( m_emptyCreateFunc);
|
btAlignedFree( m_emptyCreateFunc);
|
||||||
|
|
||||||
|
m_sphereSphereCF->~btCollisionAlgorithmCreateFunc();
|
||||||
btAlignedFree( m_sphereSphereCF);
|
btAlignedFree( m_sphereSphereCF);
|
||||||
|
|
||||||
|
m_sphereBoxCF->~btCollisionAlgorithmCreateFunc();
|
||||||
btAlignedFree( m_sphereBoxCF);
|
btAlignedFree( m_sphereBoxCF);
|
||||||
|
m_boxSphereCF->~btCollisionAlgorithmCreateFunc();
|
||||||
btAlignedFree( m_boxSphereCF);
|
btAlignedFree( m_boxSphereCF);
|
||||||
|
m_sphereTriangleCF->~btCollisionAlgorithmCreateFunc();
|
||||||
btAlignedFree( m_sphereTriangleCF);
|
btAlignedFree( m_sphereTriangleCF);
|
||||||
|
m_triangleSphereCF->~btCollisionAlgorithmCreateFunc();
|
||||||
btAlignedFree( m_triangleSphereCF);
|
btAlignedFree( m_triangleSphereCF);
|
||||||
|
|
||||||
|
m_simplexSolver->~btVoronoiSimplexSolver();
|
||||||
btAlignedFree(m_simplexSolver);
|
btAlignedFree(m_simplexSolver);
|
||||||
|
m_pdSolver->~btGjkEpaPenetrationDepthSolver();
|
||||||
btAlignedFree(m_pdSolver);
|
btAlignedFree(m_pdSolver);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -124,6 +124,10 @@ m_btSeed2(0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btSequentialImpulseConstraintSolver::~btSequentialImpulseConstraintSolver()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void initSolverBody(btSolverBody* solverBody, btRigidBody* rigidbody)
|
void initSolverBody(btSolverBody* solverBody, btRigidBody* rigidbody)
|
||||||
{
|
{
|
||||||
@@ -360,18 +364,14 @@ btScalar resolveSingleFrictionCacheFriendly(
|
|||||||
|
|
||||||
#endif //NO_FRICTION_TANGENTIALS
|
#endif //NO_FRICTION_TANGENTIALS
|
||||||
|
|
||||||
btAlignedObjectArray<btSolverBody> tmpSolverBodyPool;
|
|
||||||
btAlignedObjectArray<btSolverConstraint> tmpSolverConstraintPool;
|
|
||||||
btAlignedObjectArray<btSolverConstraint> tmpSolverFrictionConstraintPool;
|
|
||||||
btAlignedObjectArray<int> gOrderTmpConstraintPool;
|
|
||||||
btAlignedObjectArray<int> gOrderFrictionConstraintPool;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void addFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btRigidBody* rb0,btRigidBody* rb1, btScalar relaxation)
|
|
||||||
|
void btSequentialImpulseConstraintSolver::addFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btRigidBody* rb0,btRigidBody* rb1, btScalar relaxation)
|
||||||
{
|
{
|
||||||
|
|
||||||
btSolverConstraint& solverConstraint = tmpSolverFrictionConstraintPool.expand();
|
btSolverConstraint& solverConstraint = m_tmpSolverFrictionConstraintPool.expand();
|
||||||
solverConstraint.m_contactNormal = normalAxis;
|
solverConstraint.m_contactNormal = normalAxis;
|
||||||
|
|
||||||
solverConstraint.m_solverBodyIdA = solverBodyIdA;
|
solverConstraint.m_solverBodyIdA = solverBodyIdA;
|
||||||
@@ -469,7 +469,7 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
|
|||||||
//todo: use stack allocator for this temp memory
|
//todo: use stack allocator for this temp memory
|
||||||
int minReservation = numManifolds*2;
|
int minReservation = numManifolds*2;
|
||||||
|
|
||||||
//tmpSolverBodyPool.reserve(minReservation);
|
//m_tmpSolverBodyPool.reserve(minReservation);
|
||||||
|
|
||||||
//don't convert all bodies, only the one we need so solver the constraints
|
//don't convert all bodies, only the one we need so solver the constraints
|
||||||
/*
|
/*
|
||||||
@@ -480,8 +480,8 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
|
|||||||
if (rb && (rb->getIslandTag() >= 0))
|
if (rb && (rb->getIslandTag() >= 0))
|
||||||
{
|
{
|
||||||
btAssert(rb->getCompanionId() < 0);
|
btAssert(rb->getCompanionId() < 0);
|
||||||
int solverBodyId = tmpSolverBodyPool.size();
|
int solverBodyId = m_tmpSolverBodyPool.size();
|
||||||
btSolverBody& solverBody = tmpSolverBodyPool.expand();
|
btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
|
||||||
initSolverBody(&solverBody,rb);
|
initSolverBody(&solverBody,rb);
|
||||||
rb->setCompanionId(solverBodyId);
|
rb->setCompanionId(solverBodyId);
|
||||||
}
|
}
|
||||||
@@ -489,8 +489,8 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//tmpSolverConstraintPool.reserve(minReservation);
|
//m_tmpSolverConstraintPool.reserve(minReservation);
|
||||||
//tmpSolverFrictionConstraintPool.reserve(minReservation);
|
//m_tmpSolverFrictionConstraintPool.reserve(minReservation);
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -519,16 +519,16 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
|
|||||||
solverBodyIdA = rb0->getCompanionId();
|
solverBodyIdA = rb0->getCompanionId();
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
solverBodyIdA = tmpSolverBodyPool.size();
|
solverBodyIdA = m_tmpSolverBodyPool.size();
|
||||||
btSolverBody& solverBody = tmpSolverBodyPool.expand();
|
btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
|
||||||
initSolverBody(&solverBody,rb0);
|
initSolverBody(&solverBody,rb0);
|
||||||
rb0->setCompanionId(solverBodyIdA);
|
rb0->setCompanionId(solverBodyIdA);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
//create a static body
|
//create a static body
|
||||||
solverBodyIdA = tmpSolverBodyPool.size();
|
solverBodyIdA = m_tmpSolverBodyPool.size();
|
||||||
btSolverBody& solverBody = tmpSolverBodyPool.expand();
|
btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
|
||||||
initSolverBody(&solverBody,rb0);
|
initSolverBody(&solverBody,rb0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,16 +539,16 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
|
|||||||
solverBodyIdB = rb1->getCompanionId();
|
solverBodyIdB = rb1->getCompanionId();
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
solverBodyIdB = tmpSolverBodyPool.size();
|
solverBodyIdB = m_tmpSolverBodyPool.size();
|
||||||
btSolverBody& solverBody = tmpSolverBodyPool.expand();
|
btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
|
||||||
initSolverBody(&solverBody,rb1);
|
initSolverBody(&solverBody,rb1);
|
||||||
rb1->setCompanionId(solverBodyIdB);
|
rb1->setCompanionId(solverBodyIdB);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
//create a static body
|
//create a static body
|
||||||
solverBodyIdB = tmpSolverBodyPool.size();
|
solverBodyIdB = m_tmpSolverBodyPool.size();
|
||||||
btSolverBody& solverBody = tmpSolverBodyPool.expand();
|
btSolverBody& solverBody = m_tmpSolverBodyPool.expand();
|
||||||
initSolverBody(&solverBody,rb1);
|
initSolverBody(&solverBody,rb1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -580,10 +580,10 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
|
|||||||
btScalar rel_vel;
|
btScalar rel_vel;
|
||||||
btVector3 vel;
|
btVector3 vel;
|
||||||
|
|
||||||
int frictionIndex = tmpSolverConstraintPool.size();
|
int frictionIndex = m_tmpSolverConstraintPool.size();
|
||||||
|
|
||||||
{
|
{
|
||||||
btSolverConstraint& solverConstraint = tmpSolverConstraintPool.expand();
|
btSolverConstraint& solverConstraint = m_tmpSolverConstraintPool.expand();
|
||||||
|
|
||||||
solverConstraint.m_solverBodyIdA = solverBodyIdA;
|
solverConstraint.m_solverBodyIdA = solverBodyIdA;
|
||||||
solverConstraint.m_solverBodyIdB = solverBodyIdB;
|
solverConstraint.m_solverBodyIdB = solverBodyIdB;
|
||||||
@@ -690,21 +690,21 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int numConstraintPool = tmpSolverConstraintPool.size();
|
int numConstraintPool = m_tmpSolverConstraintPool.size();
|
||||||
int numFrictionPool = tmpSolverFrictionConstraintPool.size();
|
int numFrictionPool = m_tmpSolverFrictionConstraintPool.size();
|
||||||
|
|
||||||
///todo: use stack allocator for such temporarily memory, same for solver bodies/constraints
|
///todo: use stack allocator for such temporarily memory, same for solver bodies/constraints
|
||||||
gOrderTmpConstraintPool.resize(numConstraintPool);
|
m_orderTmpConstraintPool.resize(numConstraintPool);
|
||||||
gOrderFrictionConstraintPool.resize(numFrictionPool);
|
m_orderFrictionConstraintPool.resize(numFrictionPool);
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<numConstraintPool;i++)
|
for (i=0;i<numConstraintPool;i++)
|
||||||
{
|
{
|
||||||
gOrderTmpConstraintPool[i] = i;
|
m_orderTmpConstraintPool[i] = i;
|
||||||
}
|
}
|
||||||
for (i=0;i<numFrictionPool;i++)
|
for (i=0;i<numFrictionPool;i++)
|
||||||
{
|
{
|
||||||
gOrderFrictionConstraintPool[i] = i;
|
m_orderFrictionConstraintPool[i] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -719,8 +719,8 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol
|
|||||||
btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc)
|
btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc)
|
||||||
{
|
{
|
||||||
BEGIN_PROFILE("solveConstraintsIterations");
|
BEGIN_PROFILE("solveConstraintsIterations");
|
||||||
int numConstraintPool = tmpSolverConstraintPool.size();
|
int numConstraintPool = m_tmpSolverConstraintPool.size();
|
||||||
int numFrictionPool = tmpSolverFrictionConstraintPool.size();
|
int numFrictionPool = m_tmpSolverFrictionConstraintPool.size();
|
||||||
|
|
||||||
//should traverse the contacts random order...
|
//should traverse the contacts random order...
|
||||||
int iteration;
|
int iteration;
|
||||||
@@ -733,17 +733,17 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(
|
|||||||
{
|
{
|
||||||
if ((iteration & 7) == 0) {
|
if ((iteration & 7) == 0) {
|
||||||
for (j=0; j<numConstraintPool; ++j) {
|
for (j=0; j<numConstraintPool; ++j) {
|
||||||
int tmp = gOrderTmpConstraintPool[j];
|
int tmp = m_orderTmpConstraintPool[j];
|
||||||
int swapi = btRandInt2(j+1);
|
int swapi = btRandInt2(j+1);
|
||||||
gOrderTmpConstraintPool[j] = gOrderTmpConstraintPool[swapi];
|
m_orderTmpConstraintPool[j] = m_orderTmpConstraintPool[swapi];
|
||||||
gOrderTmpConstraintPool[swapi] = tmp;
|
m_orderTmpConstraintPool[swapi] = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j=0; j<numFrictionPool; ++j) {
|
for (j=0; j<numFrictionPool; ++j) {
|
||||||
int tmp = gOrderFrictionConstraintPool[j];
|
int tmp = m_orderFrictionConstraintPool[j];
|
||||||
int swapi = btRandInt2(j+1);
|
int swapi = btRandInt2(j+1);
|
||||||
gOrderFrictionConstraintPool[j] = gOrderFrictionConstraintPool[swapi];
|
m_orderFrictionConstraintPool[j] = m_orderFrictionConstraintPool[swapi];
|
||||||
gOrderFrictionConstraintPool[swapi] = tmp;
|
m_orderFrictionConstraintPool[swapi] = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -755,47 +755,47 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(
|
|||||||
|
|
||||||
if ((constraint->getRigidBodyA().getIslandTag() >= 0) && (constraint->getRigidBodyA().getCompanionId() >= 0))
|
if ((constraint->getRigidBodyA().getIslandTag() >= 0) && (constraint->getRigidBodyA().getCompanionId() >= 0))
|
||||||
{
|
{
|
||||||
tmpSolverBodyPool[constraint->getRigidBodyA().getCompanionId()].writebackVelocity();
|
m_tmpSolverBodyPool[constraint->getRigidBodyA().getCompanionId()].writebackVelocity();
|
||||||
}
|
}
|
||||||
if ((constraint->getRigidBodyB().getIslandTag() >= 0) && (constraint->getRigidBodyB().getCompanionId() >= 0))
|
if ((constraint->getRigidBodyB().getIslandTag() >= 0) && (constraint->getRigidBodyB().getCompanionId() >= 0))
|
||||||
{
|
{
|
||||||
tmpSolverBodyPool[constraint->getRigidBodyB().getCompanionId()].writebackVelocity();
|
m_tmpSolverBodyPool[constraint->getRigidBodyB().getCompanionId()].writebackVelocity();
|
||||||
}
|
}
|
||||||
|
|
||||||
constraint->solveConstraint(infoGlobal.m_timeStep);
|
constraint->solveConstraint(infoGlobal.m_timeStep);
|
||||||
|
|
||||||
if ((constraint->getRigidBodyA().getIslandTag() >= 0) && (constraint->getRigidBodyA().getCompanionId() >= 0))
|
if ((constraint->getRigidBodyA().getIslandTag() >= 0) && (constraint->getRigidBodyA().getCompanionId() >= 0))
|
||||||
{
|
{
|
||||||
tmpSolverBodyPool[constraint->getRigidBodyA().getCompanionId()].readVelocity();
|
m_tmpSolverBodyPool[constraint->getRigidBodyA().getCompanionId()].readVelocity();
|
||||||
}
|
}
|
||||||
if ((constraint->getRigidBodyB().getIslandTag() >= 0) && (constraint->getRigidBodyB().getCompanionId() >= 0))
|
if ((constraint->getRigidBodyB().getIslandTag() >= 0) && (constraint->getRigidBodyB().getCompanionId() >= 0))
|
||||||
{
|
{
|
||||||
tmpSolverBodyPool[constraint->getRigidBodyB().getCompanionId()].readVelocity();
|
m_tmpSolverBodyPool[constraint->getRigidBodyB().getCompanionId()].readVelocity();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int numPoolConstraints = tmpSolverConstraintPool.size();
|
int numPoolConstraints = m_tmpSolverConstraintPool.size();
|
||||||
for (j=0;j<numPoolConstraints;j++)
|
for (j=0;j<numPoolConstraints;j++)
|
||||||
{
|
{
|
||||||
const btSolverConstraint& solveManifold = tmpSolverConstraintPool[gOrderTmpConstraintPool[j]];
|
const btSolverConstraint& solveManifold = m_tmpSolverConstraintPool[m_orderTmpConstraintPool[j]];
|
||||||
resolveSingleCollisionCombinedCacheFriendly(tmpSolverBodyPool[solveManifold.m_solverBodyIdA],
|
resolveSingleCollisionCombinedCacheFriendly(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],
|
||||||
tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold,infoGlobal);
|
m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold,infoGlobal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int numFrictionPoolConstraints = tmpSolverFrictionConstraintPool.size();
|
int numFrictionPoolConstraints = m_tmpSolverFrictionConstraintPool.size();
|
||||||
|
|
||||||
for (j=0;j<numFrictionPoolConstraints;j++)
|
for (j=0;j<numFrictionPoolConstraints;j++)
|
||||||
{
|
{
|
||||||
const btSolverConstraint& solveManifold = tmpSolverFrictionConstraintPool[gOrderFrictionConstraintPool[j]];
|
const btSolverConstraint& solveManifold = m_tmpSolverFrictionConstraintPool[m_orderFrictionConstraintPool[j]];
|
||||||
|
|
||||||
|
|
||||||
resolveSingleFrictionCacheFriendly(tmpSolverBodyPool[solveManifold.m_solverBodyIdA],
|
resolveSingleFrictionCacheFriendly(m_tmpSolverBodyPool[solveManifold.m_solverBodyIdA],
|
||||||
tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold,infoGlobal,
|
m_tmpSolverBodyPool[solveManifold.m_solverBodyIdB],solveManifold,infoGlobal,
|
||||||
tmpSolverConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse);
|
m_tmpSolverConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -819,29 +819,29 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendly(btCollisio
|
|||||||
|
|
||||||
BEGIN_PROFILE("solveWriteBackVelocity");
|
BEGIN_PROFILE("solveWriteBackVelocity");
|
||||||
|
|
||||||
for ( i=0;i<tmpSolverBodyPool.size();i++)
|
for ( i=0;i<m_tmpSolverBodyPool.size();i++)
|
||||||
{
|
{
|
||||||
tmpSolverBodyPool[i].writebackVelocity();
|
m_tmpSolverBodyPool[i].writebackVelocity();
|
||||||
}
|
}
|
||||||
|
|
||||||
END_PROFILE("solveWriteBackVelocity");
|
END_PROFILE("solveWriteBackVelocity");
|
||||||
|
|
||||||
// printf("tmpSolverConstraintPool.size() = %i\n",tmpSolverConstraintPool.size());
|
// printf("m_tmpSolverConstraintPool.size() = %i\n",m_tmpSolverConstraintPool.size());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
printf("tmpSolverBodyPool.size() = %i\n",tmpSolverBodyPool.size());
|
printf("m_tmpSolverBodyPool.size() = %i\n",m_tmpSolverBodyPool.size());
|
||||||
printf("tmpSolverConstraintPool.size() = %i\n",tmpSolverConstraintPool.size());
|
printf("m_tmpSolverConstraintPool.size() = %i\n",m_tmpSolverConstraintPool.size());
|
||||||
printf("tmpSolverFrictionConstraintPool.size() = %i\n",tmpSolverFrictionConstraintPool.size());
|
printf("m_tmpSolverFrictionConstraintPool.size() = %i\n",m_tmpSolverFrictionConstraintPool.size());
|
||||||
|
|
||||||
|
|
||||||
printf("tmpSolverBodyPool.capacity() = %i\n",tmpSolverBodyPool.capacity());
|
printf("m_tmpSolverBodyPool.capacity() = %i\n",m_tmpSolverBodyPool.capacity());
|
||||||
printf("tmpSolverConstraintPool.capacity() = %i\n",tmpSolverConstraintPool.capacity());
|
printf("m_tmpSolverConstraintPool.capacity() = %i\n",m_tmpSolverConstraintPool.capacity());
|
||||||
printf("tmpSolverFrictionConstraintPool.capacity() = %i\n",tmpSolverFrictionConstraintPool.capacity());
|
printf("m_tmpSolverFrictionConstraintPool.capacity() = %i\n",m_tmpSolverFrictionConstraintPool.capacity());
|
||||||
*/
|
*/
|
||||||
|
|
||||||
tmpSolverBodyPool.resize(0);
|
m_tmpSolverBodyPool.resize(0);
|
||||||
tmpSolverConstraintPool.resize(0);
|
m_tmpSolverConstraintPool.resize(0);
|
||||||
tmpSolverFrictionConstraintPool.resize(0);
|
m_tmpSolverFrictionConstraintPool.resize(0);
|
||||||
|
|
||||||
|
|
||||||
return 0.f;
|
return 0.f;
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ subject to the following restrictions:
|
|||||||
#include "btConstraintSolver.h"
|
#include "btConstraintSolver.h"
|
||||||
class btIDebugDraw;
|
class btIDebugDraw;
|
||||||
#include "btContactConstraint.h"
|
#include "btContactConstraint.h"
|
||||||
|
#include "btSolverBody.h"
|
||||||
|
#include "btSolverConstraint.h"
|
||||||
|
|
||||||
|
|
||||||
/// btSequentialImpulseConstraintSolver uses a Propagation Method and Sequentially applies impulses
|
/// btSequentialImpulseConstraintSolver uses a Propagation Method and Sequentially applies impulses
|
||||||
@@ -29,10 +30,18 @@ class btIDebugDraw;
|
|||||||
class btSequentialImpulseConstraintSolver : public btConstraintSolver
|
class btSequentialImpulseConstraintSolver : public btConstraintSolver
|
||||||
{
|
{
|
||||||
|
|
||||||
|
btAlignedObjectArray<btSolverBody> m_tmpSolverBodyPool;
|
||||||
|
btAlignedObjectArray<btSolverConstraint> m_tmpSolverConstraintPool;
|
||||||
|
btAlignedObjectArray<btSolverConstraint> m_tmpSolverFrictionConstraintPool;
|
||||||
|
btAlignedObjectArray<int> m_orderTmpConstraintPool;
|
||||||
|
btAlignedObjectArray<int> m_orderFrictionConstraintPool;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
btScalar solve(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);
|
btScalar solve(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);
|
||||||
btScalar solveFriction(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);
|
btScalar solveFriction(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);
|
||||||
void prepareConstraints(btPersistentManifold* manifoldPtr, const btContactSolverInfo& info,btIDebugDraw* debugDrawer);
|
void prepareConstraints(btPersistentManifold* manifoldPtr, const btContactSolverInfo& info,btIDebugDraw* debugDrawer);
|
||||||
|
void addFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btRigidBody* rb0,btRigidBody* rb1, btScalar relaxation);
|
||||||
|
|
||||||
ContactSolverFunc m_contactDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES];
|
ContactSolverFunc m_contactDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES];
|
||||||
ContactSolverFunc m_frictionDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES];
|
ContactSolverFunc m_frictionDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES];
|
||||||
@@ -68,7 +77,7 @@ public:
|
|||||||
m_frictionDispatch[type0][type1] = func;
|
m_frictionDispatch[type0][type1] = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~btSequentialImpulseConstraintSolver() {}
|
virtual ~btSequentialImpulseConstraintSolver();
|
||||||
|
|
||||||
virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher);
|
virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher);
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ m_gravity(0,-10,0),
|
|||||||
m_localTime(btScalar(1.)/btScalar(60.)),
|
m_localTime(btScalar(1.)/btScalar(60.)),
|
||||||
m_profileTimings(0)
|
m_profileTimings(0)
|
||||||
{
|
{
|
||||||
if (m_constraintSolver)
|
if (!m_constraintSolver)
|
||||||
{
|
{
|
||||||
void* mem = btAlignedAlloc(sizeof(btSequentialImpulseConstraintSolver),16);
|
void* mem = btAlignedAlloc(sizeof(btSequentialImpulseConstraintSolver),16);
|
||||||
m_constraintSolver = new (mem) btSequentialImpulseConstraintSolver;
|
m_constraintSolver = new (mem) btSequentialImpulseConstraintSolver;
|
||||||
@@ -88,9 +88,16 @@ btDiscreteDynamicsWorld::~btDiscreteDynamicsWorld()
|
|||||||
{
|
{
|
||||||
//only delete it when we created it
|
//only delete it when we created it
|
||||||
if (m_ownsIslandManager)
|
if (m_ownsIslandManager)
|
||||||
|
{
|
||||||
|
m_islandManager->~btSimulationIslandManager();
|
||||||
btAlignedFree( m_islandManager);
|
btAlignedFree( m_islandManager);
|
||||||
|
}
|
||||||
if (m_ownsConstraintSolver)
|
if (m_ownsConstraintSolver)
|
||||||
btAlignedFree(m_constraintSolver);
|
{
|
||||||
|
|
||||||
|
m_constraintSolver->~btConstraintSolver();
|
||||||
|
btAlignedFree(m_constraintSolver);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void btDiscreteDynamicsWorld::saveKinematicState(btScalar timeStep)
|
void btDiscreteDynamicsWorld::saveKinematicState(btScalar timeStep)
|
||||||
|
|||||||
@@ -17,6 +17,60 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
int gNumAlignedAllocs = 0;
|
int gNumAlignedAllocs = 0;
|
||||||
int gNumAlignedFree = 0;
|
int gNumAlignedFree = 0;
|
||||||
|
int gTotalBytesAlignedAllocs = 0;//detect memory leaks
|
||||||
|
|
||||||
|
#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
|
||||||
|
//this generic allocator provides the total allocated number of bytes
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filename)
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
char *real;
|
||||||
|
unsigned long offset;
|
||||||
|
|
||||||
|
gTotalBytesAlignedAllocs += size;
|
||||||
|
gNumAlignedAllocs++;
|
||||||
|
|
||||||
|
printf("allocation#%d from %s,line %d, size %d\n",gNumAlignedAllocs,filename,line,size);
|
||||||
|
real = (char *)malloc(size + 2*sizeof(void *) + (alignment-1));
|
||||||
|
if (real) {
|
||||||
|
offset = (alignment - (unsigned long)(real + 2*sizeof(void *))) &
|
||||||
|
(alignment-1);
|
||||||
|
ret = (void *)((real + 2*sizeof(void *)) + offset);
|
||||||
|
*((void **)(ret)-1) = (void *)(real);
|
||||||
|
*((int*)(ret)-2) = size;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ret = (void *)(real);//??
|
||||||
|
}
|
||||||
|
int* ptr = (int*)ret;
|
||||||
|
*ptr = 12;
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
#include <stdio.h>
|
||||||
|
void btAlignedFreeInternal (void* ptr,int line,char* filename)
|
||||||
|
{
|
||||||
|
|
||||||
|
void* real;
|
||||||
|
gNumAlignedFree++;
|
||||||
|
|
||||||
|
if (ptr) {
|
||||||
|
real = *((void **)(ptr)-1);
|
||||||
|
int size = *((int*)(ptr)-2);
|
||||||
|
gTotalBytesAlignedAllocs -= size;
|
||||||
|
|
||||||
|
printf("free #%d from %s,line %d, size %d\n",gNumAlignedFree,filename,line,size);
|
||||||
|
|
||||||
|
free(real);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
printf("NULL ptr\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else //BT_DEBUG_MEMORY_ALLOCATIONS
|
||||||
|
|
||||||
|
|
||||||
#if defined (BT_HAS_ALIGNED_ALLOCATOR)
|
#if defined (BT_HAS_ALIGNED_ALLOCATOR)
|
||||||
|
|
||||||
@@ -25,19 +79,19 @@ int gNumAlignedFree = 0;
|
|||||||
|
|
||||||
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
void* btAlignedAlloc (size_t size, int alignment)
|
void* btAlignedAllocInternal (size_t size, int alignment)
|
||||||
{
|
{
|
||||||
gNumAlignedAllocs++;
|
gNumAlignedAllocs++;
|
||||||
|
|
||||||
void* ptr = _aligned_malloc(size,alignment);
|
void* ptr = _aligned_malloc(size,alignment);
|
||||||
// printf("btAlignedAlloc %d, %x\n",size,ptr);
|
// printf("btAlignedAllocInternal %d, %x\n",size,ptr);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void btAlignedFree (void* ptr)
|
void btAlignedFreeInternal (void* ptr)
|
||||||
{
|
{
|
||||||
gNumAlignedFree++;
|
gNumAlignedFree++;
|
||||||
// printf("btAlignedFree %x\n",ptr);
|
// printf("btAlignedFreeInternal %x\n",ptr);
|
||||||
_aligned_free(ptr);
|
_aligned_free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,13 +103,13 @@ void btAlignedFree (void* ptr)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void* btAlignedAlloc (size_t size, int alignment)
|
void* btAlignedAllocInternal (size_t size, int alignment)
|
||||||
{
|
{
|
||||||
gNumAlignedAllocs++;
|
gNumAlignedAllocs++;
|
||||||
return memalign(alignment, size);
|
return memalign(alignment, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void btAlignedFree (void* ptr)
|
void btAlignedFreeInternal (void* ptr)
|
||||||
{
|
{
|
||||||
gNumAlignedFree++;
|
gNumAlignedFree++;
|
||||||
free(ptr);
|
free(ptr);
|
||||||
@@ -63,7 +117,7 @@ void btAlignedFree (void* ptr)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void* btAlignedAlloc (size_t size, int alignment)
|
void* btAlignedAllocInternal (size_t size, int alignment)
|
||||||
{
|
{
|
||||||
void *ret;
|
void *ret;
|
||||||
char *real;
|
char *real;
|
||||||
@@ -82,7 +136,7 @@ void* btAlignedAlloc (size_t size, int alignment)
|
|||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
void btAlignedFree (void* ptr)
|
void btAlignedFreeInternal (void* ptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
void* real;
|
void* real;
|
||||||
@@ -97,4 +151,5 @@ void btAlignedFree (void* ptr)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif //BT_DEBUG_MEMORY_ALLOCATIONS
|
||||||
|
|
||||||
|
|||||||
@@ -21,12 +21,26 @@ subject to the following restrictions:
|
|||||||
///that is better portable and more predictable
|
///that is better portable and more predictable
|
||||||
|
|
||||||
#include "btScalar.h"
|
#include "btScalar.h"
|
||||||
|
//#define BT_DEBUG_MEMORY_ALLOCATIONS 1
|
||||||
|
#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
|
||||||
|
|
||||||
void* btAlignedAlloc (size_t size, int alignment);
|
#define btAlignedAlloc(a,b) \
|
||||||
|
btAlignedAllocInternal(a,b,__LINE__,__FILE__)
|
||||||
|
|
||||||
void btAlignedFree (void* ptr);
|
#define btAlignedFree(ptr) \
|
||||||
|
btAlignedFreeInternal(ptr,__LINE__,__FILE__)
|
||||||
|
|
||||||
|
void* btAlignedAllocInternal (size_t size, int alignment,int line,char* filename);
|
||||||
|
|
||||||
|
void btAlignedFreeInternal (void* ptr,int line,char* filename);
|
||||||
|
|
||||||
|
#else
|
||||||
|
void* btAlignedAllocInternal (size_t size, int alignment);
|
||||||
|
void btAlignedFreeInternal (void* ptr);
|
||||||
|
|
||||||
|
#define btAlignedAlloc(a,b) btAlignedAllocInternal(a,b)
|
||||||
|
#define btAlignedFree(ptr) btAlignedFreeInternal(ptr)
|
||||||
|
#endif
|
||||||
typedef int size_type;
|
typedef int size_type;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
|
|
||||||
if(usedsize==0)
|
if(usedsize==0)
|
||||||
{
|
{
|
||||||
if(!ischild)
|
if(!ischild && data)
|
||||||
btAlignedFree(data);
|
btAlignedFree(data);
|
||||||
|
|
||||||
data = 0;
|
data = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user