re-organized memory (stack and pool) allocators. this lets the user pass in their own memory allocators.
This commit is contained in:
@@ -187,9 +187,9 @@ void BasicDemo::initPhysics()
|
||||
#ifdef USE_SIMPLE_DYNAMICS_WORLD
|
||||
//btSimpleDynamicsWorld doesn't support 'cache friendly' optimization, so disable this
|
||||
sol->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER);
|
||||
m_dynamicsWorld = new btSimpleDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver);
|
||||
m_dynamicsWorld = new btSimpleDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,collisionConfiguration);
|
||||
#else
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver);
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,collisionConfiguration);
|
||||
#endif //USE_SIMPLE_DYNAMICS_WORLD
|
||||
m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ void BspDemo::initPhysics(char* bspfilename)
|
||||
//btOverlappingPairCache* broadphase = new btSimpleBroadphase();
|
||||
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||
//ConstraintSolver* solver = new OdeConstraintSolver;
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration);
|
||||
|
||||
m_dynamicsWorld->setGravity(-m_cameraUp * 10);
|
||||
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
||||
|
||||
@@ -477,7 +477,7 @@ int maxNumOutstandingTasks = 4;
|
||||
solver->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER);
|
||||
#endif //USER_DEFINED_FRICTION_MODEL
|
||||
|
||||
btDiscreteDynamicsWorld* world = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver);
|
||||
btDiscreteDynamicsWorld* world = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
|
||||
m_dynamicsWorld = world;
|
||||
|
||||
#ifdef DO_BENCHMARK_PYRAMIDS
|
||||
|
||||
@@ -178,7 +178,7 @@ void ColladaDemo::initPhysics(const char* filename)
|
||||
btVector3 worldMax(1000,1000,1000);
|
||||
btBroadphaseInterface* pairCache = new btAxisSweep3(worldMin,worldMax);
|
||||
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration);
|
||||
|
||||
//m_dynamicsWorld = new btSimpleDynamicsWorld();
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ void CollisionInterfaceDemo::initPhysics()
|
||||
//SimpleBroadphase is a brute force alternative, performing N^2 aabb overlap tests
|
||||
//SimpleBroadphase* broadphase = new btSimpleBroadphase;
|
||||
|
||||
collisionWorld = new btCollisionWorld(dispatcher,broadphase);
|
||||
collisionWorld = new btCollisionWorld(dispatcher,broadphase,collisionConfiguration);
|
||||
|
||||
collisionWorld->addCollisionObject(&objects[0]);
|
||||
collisionWorld->addCollisionObject(&objects[1]);
|
||||
|
||||
@@ -270,7 +270,7 @@ btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollision
|
||||
btVector3 worldMax(1000,1000,1000);
|
||||
btBroadphaseInterface* pairCache = new btAxisSweep3(worldMin,worldMax);
|
||||
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration);
|
||||
#ifdef USE_PARALLEL_DISPATCHER
|
||||
m_dynamicsWorld->getDispatchInfo().m_enableSPU=true;
|
||||
#endif //USE_PARALLEL_DISPATCHER
|
||||
|
||||
@@ -84,7 +84,7 @@ void ConstraintDemo::initPhysics()
|
||||
//btBroadphaseInterface* broadphase = new btSimpleBroadphase();
|
||||
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||
//ConstraintSolver* solver = new OdeConstraintSolver;
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration);
|
||||
|
||||
//m_dynamicsWorld->setGravity(btVector3(0,0,0));
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
||||
//btBroadphaseInterface* broadphase = new btSimpleBroadphase();
|
||||
|
||||
btConstraintSolver* solver = new btSequentialImpulseConstraintSolver();
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver);
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);
|
||||
|
||||
#ifdef USE_PARALLEL_DISPATCHER
|
||||
m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
|
||||
|
||||
@@ -89,7 +89,7 @@ void DoublePrecisionDemo::initPhysics()
|
||||
|
||||
btAxisSweep3* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax);
|
||||
|
||||
collisionWorld = new btCollisionWorld(dispatcher,broadphase);
|
||||
collisionWorld = new btCollisionWorld(dispatcher,broadphase,collisionConfiguration);
|
||||
|
||||
collisionWorld->addCollisionObject(&objects[0]);
|
||||
collisionWorld->addCollisionObject(&objects[1]);
|
||||
|
||||
@@ -1,153 +1,153 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Ragdoll Demo
|
||||
Copyright (c) 2007 Starbreeze Studios
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library
|
||||
Ragdoll Demo
|
||||
Copyright (c) 2007 Starbreeze Studios
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Originally Written by: Marten Svanfeldt
|
||||
ReWritten by: Francisco Le<4C>n
|
||||
*/
|
||||
ReWritten by: Francisco Le<4C>n
|
||||
*/
|
||||
|
||||
//#define USE_ODE_QUICKSTEP 1
|
||||
|
||||
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "GlutStuff.h"
|
||||
#include "GL_ShapeDrawer.h"
|
||||
|
||||
|
||||
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "GlutStuff.h"
|
||||
#include "GL_ShapeDrawer.h"
|
||||
|
||||
#include "LinearMath/btIDebugDraw.h"
|
||||
|
||||
#include "GLDebugDrawer.h"
|
||||
#include "GLDebugDrawer.h"
|
||||
#include "GenericJointDemo.h"
|
||||
|
||||
#ifdef USE_ODE_QUICKSTEP
|
||||
#ifdef USE_ODE_QUICKSTEP
|
||||
#include "OdeConstraintSolver.h"
|
||||
#endif
|
||||
|
||||
|
||||
GLDebugDrawer debugDrawer;
|
||||
|
||||
|
||||
|
||||
int main(int argc,char* argv[])
|
||||
{
|
||||
|
||||
GLDebugDrawer debugDrawer;
|
||||
|
||||
|
||||
|
||||
int main(int argc,char* argv[])
|
||||
{
|
||||
GenericJointDemo demoApp;
|
||||
// demoApp.configDebugDrawer(&debugDrawer);
|
||||
|
||||
demoApp.initPhysics();
|
||||
demoApp.setCameraDistance(btScalar(10.));
|
||||
// demoApp.configDebugDrawer(&debugDrawer);
|
||||
|
||||
demoApp.initPhysics();
|
||||
demoApp.setCameraDistance(btScalar(10.));
|
||||
|
||||
#ifdef USE_ODE_QUICKSTEP
|
||||
return glutmain(argc, argv,640,480,"Joint 6DOF - ODE QuickStep Solver",&demoApp);
|
||||
#else
|
||||
return glutmain(argc, argv,640,480,"Joint 6DOF - Sequencial Impulse Solver",&demoApp);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GenericJointDemo::initPhysics()
|
||||
{
|
||||
// Setup the basic world
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GenericJointDemo::initPhysics()
|
||||
{
|
||||
// Setup the basic world
|
||||
|
||||
btDefaultCollisionConfiguration * collision_config = new btDefaultCollisionConfiguration();
|
||||
|
||||
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collision_config);
|
||||
|
||||
btPoint3 worldAabbMin(-10000,-10000,-10000);
|
||||
btPoint3 worldAabbMax(10000,10000,10000);
|
||||
btBroadphaseInterface* overlappingPairCache = new btAxisSweep3 (worldAabbMin, worldAabbMax);
|
||||
|
||||
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collision_config);
|
||||
|
||||
btPoint3 worldAabbMin(-10000,-10000,-10000);
|
||||
btPoint3 worldAabbMax(10000,10000,10000);
|
||||
btBroadphaseInterface* overlappingPairCache = new btAxisSweep3 (worldAabbMin, worldAabbMax);
|
||||
|
||||
#ifdef USE_ODE_QUICKSTEP
|
||||
btConstraintSolver* constraintSolver = new OdeConstraintSolver();
|
||||
#else
|
||||
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,overlappingPairCache,constraintSolver);
|
||||
|
||||
m_dynamicsWorld->setGravity(btVector3(0,-30,0));
|
||||
|
||||
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,overlappingPairCache,constraintSolver,collision_config);
|
||||
|
||||
m_dynamicsWorld->setGravity(btVector3(0,-30,0));
|
||||
|
||||
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
||||
|
||||
// Setup a big ground box
|
||||
{
|
||||
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(200.),btScalar(10.),btScalar(200.)));
|
||||
btTransform groundTransform;
|
||||
groundTransform.setIdentity();
|
||||
groundTransform.setOrigin(btVector3(0,-15,0));
|
||||
localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
|
||||
}
|
||||
|
||||
// Spawn one ragdoll
|
||||
spawnRagdoll();
|
||||
|
||||
clientResetScene();
|
||||
}
|
||||
|
||||
void GenericJointDemo::spawnRagdoll(bool random)
|
||||
{
|
||||
RagDoll* ragDoll = new RagDoll (m_dynamicsWorld, btVector3 (0,0,10),5.f);
|
||||
m_ragdolls.push_back(ragDoll);
|
||||
}
|
||||
|
||||
void GenericJointDemo::clientMoveAndDisplay()
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
//simple dynamics world doesn't handle fixed-time-stepping
|
||||
float ms = m_clock.getTimeMicroseconds();
|
||||
m_clock.reset();
|
||||
float minFPS = 1000000.f/60.f;
|
||||
if (ms > minFPS)
|
||||
ms = minFPS;
|
||||
|
||||
if (m_dynamicsWorld)
|
||||
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
|
||||
|
||||
renderme();
|
||||
|
||||
glFlush();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
void GenericJointDemo::displayCallback()
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if (m_dynamicsWorld)
|
||||
m_dynamicsWorld->updateAabbs();
|
||||
|
||||
renderme();
|
||||
|
||||
glFlush();
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
void GenericJointDemo::keyboardCallback(unsigned char key, int x, int y)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 'e':
|
||||
spawnRagdoll(true);
|
||||
break;
|
||||
default:
|
||||
DemoApplication::keyboardCallback(key, x, y);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Setup a big ground box
|
||||
{
|
||||
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(200.),btScalar(10.),btScalar(200.)));
|
||||
btTransform groundTransform;
|
||||
groundTransform.setIdentity();
|
||||
groundTransform.setOrigin(btVector3(0,-15,0));
|
||||
localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
|
||||
}
|
||||
|
||||
// Spawn one ragdoll
|
||||
spawnRagdoll();
|
||||
|
||||
clientResetScene();
|
||||
}
|
||||
|
||||
void GenericJointDemo::spawnRagdoll(bool random)
|
||||
{
|
||||
RagDoll* ragDoll = new RagDoll (m_dynamicsWorld, btVector3 (0,0,10),5.f);
|
||||
m_ragdolls.push_back(ragDoll);
|
||||
}
|
||||
|
||||
void GenericJointDemo::clientMoveAndDisplay()
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
//simple dynamics world doesn't handle fixed-time-stepping
|
||||
float ms = m_clock.getTimeMicroseconds();
|
||||
m_clock.reset();
|
||||
float minFPS = 1000000.f/60.f;
|
||||
if (ms > minFPS)
|
||||
ms = minFPS;
|
||||
|
||||
if (m_dynamicsWorld)
|
||||
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
|
||||
|
||||
renderme();
|
||||
|
||||
glFlush();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
void GenericJointDemo::displayCallback()
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if (m_dynamicsWorld)
|
||||
m_dynamicsWorld->updateAabbs();
|
||||
|
||||
renderme();
|
||||
|
||||
glFlush();
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
void GenericJointDemo::keyboardCallback(unsigned char key, int x, int y)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 'e':
|
||||
spawnRagdoll(true);
|
||||
break;
|
||||
default:
|
||||
DemoApplication::keyboardCallback(key, x, y);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ void GimpactConcaveDemo::initPhysics()
|
||||
|
||||
m_constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_constraintSolver);
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_constraintSolver,m_collisionConfiguration);
|
||||
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
||||
|
||||
//create trimesh model and shape
|
||||
|
||||
@@ -1652,7 +1652,7 @@ void ConcaveDemo::initPhysics()
|
||||
btBroadphaseInterface* broadphase = new btSimpleBroadphase();
|
||||
|
||||
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,constraintSolver);
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,constraintSolver,collisionConfiguration);
|
||||
|
||||
|
||||
//create trimesh model and shape
|
||||
|
||||
@@ -40,6 +40,12 @@ void GLDebugDrawer::setDebugMode(int debugMode)
|
||||
|
||||
}
|
||||
|
||||
void GLDebugDrawer::draw3dText(const btVector3& location,const char* textString)
|
||||
{
|
||||
glRasterPos3f(location.x(), location.y(), location.z());
|
||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),textString);
|
||||
}
|
||||
|
||||
void GLDebugDrawer::reportErrorWarning(const char* warningString)
|
||||
{
|
||||
printf(warningString);
|
||||
|
||||
@@ -20,6 +20,8 @@ public:
|
||||
|
||||
virtual void reportErrorWarning(const char* warningString);
|
||||
|
||||
virtual void draw3dText(const btVector3& location,const char* textString);
|
||||
|
||||
virtual void setDebugMode(int debugMode);
|
||||
|
||||
virtual int getDebugMode() const { return m_debugMode;}
|
||||
|
||||
@@ -328,7 +328,7 @@ void RagdollDemo::initPhysics()
|
||||
|
||||
btConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
|
||||
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,overlappingPairCache,solver);
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,overlappingPairCache,solver,collisionConfiguration);
|
||||
|
||||
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ void UserCollisionAlgorithm::initPhysics()
|
||||
dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE,GIMPACT_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc);
|
||||
|
||||
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,constraintSolver);
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,constraintSolver,collisionConfiguration);
|
||||
|
||||
float mass = 0.f;
|
||||
btTransform startTransform;
|
||||
|
||||
@@ -124,7 +124,7 @@ void VehicleDemo::setupPhysics()
|
||||
btVector3 worldMax(1000,1000,1000);
|
||||
btBroadphaseInterface* pairCache = new btAxisSweep3(worldMin,worldMax);
|
||||
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration);
|
||||
#ifdef FORCE_ZAXIS_UP
|
||||
m_dynamicsWorld->setGravity(btVector3(0,0,-10));
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user