From d49aeb9dff3db4689307e1be342416d955ef9b4f Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Thu, 29 May 2008 03:33:32 +0000 Subject: [PATCH] + improved split impulse constraint solver option + improved friction warm starting + made constraint solver configuration more consistent (moved m_solverMode into btContactSolverInfo) + reset timing in CDTestFramework after initialization (SAP init destorts timings) + make it easier to change default sizes for stack allocator in btDefaultCollisionConfiguration --- Demos/AllBulletDemos/DemoEntries.cpp | 1 + Demos/AllBulletDemos/Main.cpp | 165 +++++++++++++++--- Demos/Benchmarks/BenchmarkDemo.cpp | 2 +- Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp | 26 +-- Demos/SoftDemo/SoftDemo.cpp | 14 +- Extras/CDTestFramework/Bin/Opcode.dll | Bin 425984 -> 425984 bytes .../BulletSAPCompleteBoxPruningTest.cpp | 8 +- Extras/CDTestFramework/CDTestFramework.cpp | 6 +- Extras/CDTestFramework/Profiling.h | 8 + Extras/COLLADA_DOM/include/dae/daeDom.h | 7 + Extras/COLLADA_DOM/include/dae/daeTypes.h | 3 + .../btDefaultCollisionConfiguration.cpp | 37 ++-- .../btDefaultCollisionConfiguration.h | 28 ++- .../NarrowPhaseCollision/btManifoldPoint.h | 12 +- .../btPersistentManifold.h | 9 + .../ConstraintSolver/btContactSolverInfo.h | 26 ++- .../btOdeQuickstepConstraintSolver.cpp | 12 -- .../btSequentialImpulseConstraintSolver.cpp | 107 ++++++++---- .../btSequentialImpulseConstraintSolver.h | 23 +-- .../ConstraintSolver/btSolverBody.h | 2 +- .../ConstraintSolver/btSolverConstraint.h | 2 - .../Dynamics/btDiscreteDynamicsWorld.h | 12 +- src/BulletDynamics/Dynamics/btDynamicsWorld.h | 19 +- ...oftBodyRigidBodyCollisionConfiguration.cpp | 4 +- ...tSoftBodyRigidBodyCollisionConfiguration.h | 2 +- 25 files changed, 386 insertions(+), 149 deletions(-) diff --git a/Demos/AllBulletDemos/DemoEntries.cpp b/Demos/AllBulletDemos/DemoEntries.cpp index 276fbaf8a..b0c284c48 100644 --- a/Demos/AllBulletDemos/DemoEntries.cpp +++ b/Demos/AllBulletDemos/DemoEntries.cpp @@ -102,6 +102,7 @@ public: btDemoEntry g_demoEntries[] = { + {"SoftBody Cloth",SoftDemo0::Create}, {"SoftBody Pressure",SoftDemo1::Create}, {"SoftBody Volume",SoftDemo2::Create}, diff --git a/Demos/AllBulletDemos/Main.cpp b/Demos/AllBulletDemos/Main.cpp index f54d0bef1..2eb367c53 100644 --- a/Demos/AllBulletDemos/Main.cpp +++ b/Demos/AllBulletDemos/Main.cpp @@ -21,7 +21,7 @@ #include "glui/GL/glui.h" #include "LinearMath/btScalar.h" #include "LinearMath/btMinMax.h" - +#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" #include "DemoApplication.h" #include "DemoEntries.h" #include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h" @@ -34,25 +34,83 @@ namespace { - int testIndex = 0; - int testSelection = 0; + int testIndex=0; + int testSelection=0; btDemoEntry* entry; DemoApplication* demo; - int iterationCount = 10; - int width = 640; - int height = 480; - int framePeriod = 16;//todo: test if this value should be 0 + int iterationCount; + int width; + int height; + int framePeriod;//todo: test if this value should be 0 int mainWindow; GLUI *glui; float hz; - float viewZoom = 20.0f; - float viewX = 0.0f; - float viewY = 0.0f; + float viewZoom=20.f; + float viewX; + float viewY; int tx, ty, tw, th; - int gDrawAabb=0; - int gWireFrame=0; - int gDebugContacts=0; - int gDebugNoDeactivation = 0; + int gDrawAabb; + int gWireFrame; + int gDebugContacts; + int gDebugNoDeactivation; + int gUseWarmstarting; + int gRandomizeConstraints; + int gUseSplitImpulse; + float gErp; + float gSlop; + float gErp2; + float gWarmStartingParameter; +} + + +void setDefaultSettings() +{ + viewX = 0.0f; + viewY = 0.0f; + framePeriod = 16;//todo: test if this value should be 0 + + width = 640; + height = 480; + iterationCount = 10; + gDrawAabb=0; + gWireFrame=0; + gDebugContacts=0; + gDebugNoDeactivation = 0; + gUseSplitImpulse = 0; + gUseWarmstarting = 1; + gRandomizeConstraints = 1; + gErp = 0.2f; + gSlop=0.0f; + gErp2 = 0.1f; + gWarmStartingParameter = 0.85f; + +} + +void setDefaultSettingsAndSync() +{ + setDefaultSettings(); + glui->sync_live(); +} + + +void TogglePause() +{ + if (demo) + demo->toggleIdle(); +} + +void ResetScene() +{ + if (demo) + demo->clientResetScene(); +} + + + +void SingleSimulationStep() +{ + if (demo) + demo->clientMoveAndDisplay(); } @@ -136,6 +194,7 @@ void SimulationLoop() demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawContactPoints)); } + if (gDebugNoDeactivation) { demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_NoDeactivation); @@ -148,8 +207,31 @@ void SimulationLoop() { btDiscreteDynamicsWorld* discreteWorld = (btDiscreteDynamicsWorld*) demo->getDynamicsWorld(); discreteWorld->getSolverInfo().m_numIterations = iterationCount; - } + discreteWorld->getSolverInfo().m_erp = gErp; + discreteWorld->getSolverInfo().m_erp2 = gErp2; + + discreteWorld->getSolverInfo().m_linearSlop = gSlop; + + discreteWorld->getSolverInfo().m_warmstartingFactor = gWarmStartingParameter; + discreteWorld->getSolverInfo().m_splitImpulse = gUseSplitImpulse; + btSequentialImpulseConstraintSolver* solver = ((btSequentialImpulseConstraintSolver*) discreteWorld->getConstraintSolver()); + + if (gUseWarmstarting) + { + discreteWorld->getSolverInfo().m_solverMode |= SOLVER_USE_WARMSTARTING; + } else + { + discreteWorld->getSolverInfo().m_solverMode &= (~SOLVER_USE_WARMSTARTING); + } + if (gRandomizeConstraints) + { + discreteWorld->getSolverInfo().m_solverMode |= SOLVER_RANDMIZE_ORDER; + } else + { + discreteWorld->getSolverInfo().m_solverMode &= (~SOLVER_RANDMIZE_ORDER); + } + } if (!demo->isIdle()) { @@ -176,6 +258,19 @@ void SimulationLoop() } } +void RestartScene() +{ + if (demo->getDynamicsWorld() && demo->getDynamicsWorld()->getDebugDrawer()) + delete demo->getDynamicsWorld()->getDebugDrawer(); + delete demo; + entry = g_demoEntries + testIndex; + demo = CreatDemo(entry); + viewZoom = 20.0f; + viewX = 0.0f; + viewY = 0.0f; + Resize(width, height); +} + void Keyboard(unsigned char key, int x, int y) { @@ -234,7 +329,7 @@ void MouseMotion(int x, int y) int main(int argc, char** argv) { - + setDefaultSettings(); int bulletVersion = btGetVersion(); printf("Bullet version %d\n",bulletVersion); @@ -260,6 +355,8 @@ int main(int argc, char** argv) glui = GLUI_Master.create_glui_subwindow( mainWindow, GLUI_SUBWINDOW_RIGHT ); + + glui->add_statictext("Tests"); GLUI_Listbox* testList = glui->add_listbox("", &testSelection); @@ -268,20 +365,35 @@ int main(int argc, char** argv) GLUI_Spinner* iterationSpinner = glui->add_spinner("Iterations", GLUI_SPINNER_INT, &iterationCount); - iterationSpinner->set_int_limits(1, 100); + iterationSpinner->set_int_limits(1, 250); /* GLUI_Spinner* hertzSpinner = glui->add_spinner("Hertz", GLUI_SPINNER_FLOAT, &hz); hertzSpinner->set_float_limits(5.0f, 200.0f); */ -// glui->add_checkbox("Position Correction", &settings.enablePositionCorrection); -// glui->add_checkbox("Warm Starting", &settings.enablePositionCorrection); + glui->add_checkbox("DisableDeactivation", &gDebugNoDeactivation); + glui->add_checkbox("Split Impulse", &gUseSplitImpulse); + GLUI_Spinner* spinner = 0; + spinner = glui->add_spinner("ERP", GLUI_SPINNER_FLOAT, &gErp); + spinner->set_float_limits(0.f,1.f); + spinner = glui->add_spinner("ERP2", GLUI_SPINNER_FLOAT, &gErp2); + spinner->set_float_limits(0.f,1.f); + spinner = glui->add_spinner("Slop", GLUI_SPINNER_FLOAT, &gSlop); + spinner->set_float_limits(0.f,1.f); + + spinner = glui->add_spinner("WSP", GLUI_SPINNER_FLOAT,&gWarmStartingParameter); + spinner->set_float_limits (0.f,1.0); + glui->add_checkbox("Warmstarting", &gUseWarmstarting); + glui->add_checkbox("Randomize Constraints", &gRandomizeConstraints); + + + glui->add_button("Reset Defaults", 0,(GLUI_Update_CB)setDefaultSettingsAndSync); glui->add_separator(); - GLUI_Panel* drawPanel = glui->add_panel("Draw"); + GLUI_Panel* drawPanel = glui->add_panel("Debug Draw"); glui->add_checkbox_to_panel(drawPanel, "AABBs", &gDrawAabb); glui->add_checkbox_to_panel(drawPanel, "Wireframe", &gWireFrame); @@ -299,8 +411,19 @@ int main(int argc, char** argv) ++testCount; ++e; } + + glui->add_separator(); + + glui->add_button("Toggle Pause", 0,(GLUI_Update_CB)TogglePause); + + glui->add_button("Single Step", 0,(GLUI_Update_CB)SingleSimulationStep); + glui->add_button("Reset Scene", 0,(GLUI_Update_CB)ResetScene); + glui->add_button("Restart Scene", 0,(GLUI_Update_CB)RestartScene); + + glui->add_separator(); + + glui->add_button("Exit", 0,(GLUI_Update_CB)exit); - glui->add_button("Quit", 0,(GLUI_Update_CB)exit); glui->set_main_gfx_window( mainWindow ); // Use a timer to control the frame rate. diff --git a/Demos/Benchmarks/BenchmarkDemo.cpp b/Demos/Benchmarks/BenchmarkDemo.cpp index 7bb6eb1d2..a575d7459 100644 --- a/Demos/Benchmarks/BenchmarkDemo.cpp +++ b/Demos/Benchmarks/BenchmarkDemo.cpp @@ -277,7 +277,7 @@ void BenchmarkDemo::initPhysics() ///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded) btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver; - sol->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_CACHE_FRIENDLY); + m_solver = sol; m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration); diff --git a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp index 6ffacea4a..79f08a3a5 100644 --- a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp +++ b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp @@ -25,8 +25,9 @@ subject to the following restrictions: //#define CENTER_OF_MASS_SHIFT 1 //#define VERBOSE_TIMESTEPPING_CONSOLEOUTPUT 1 -//#define USE_PARALLEL_SOLVER 1 //experimental parallel solver //#define USE_PARALLEL_DISPATCHER 1 +//#define USE_PARALLEL_SOLVER 1 //experimental parallel solver + //from Bullet 2.68 onwards ODE Quickstep constraint solver is optional part of Bullet, re-distributed under the ZLib license with permission of Russell L. Smith //#define COMPARE_WITH_QUICKSTEP 1 @@ -338,6 +339,7 @@ void CcdPhysicsDemo::initPhysics() #ifdef DO_BENCHMARK_PYRAMIDS m_collisionShapes.push_back(new btBoxShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS))); #else +// m_collisionShapes.push_back(new btBoxShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS))); m_collisionShapes.push_back(new btCylinderShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS))); #endif @@ -432,22 +434,24 @@ int maxNumOutstandingTasks = 4; #else btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver(); - m_solver = solver; - //default solverMode is SOLVER_RANDMIZE_ORDER. Warmstarting seems not to improve convergence, see - //solver->setSolverMode(0);//btSequentialImpulseConstraintSolver::SOLVER_USE_WARMSTARTING | btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER); + m_solver = solver;//new btOdeQuickstepConstraintSolver(); #endif //USE_PARALLEL_SOLVER #endif -#ifdef USER_DEFINED_FRICTION_MODEL - //user defined friction model is not supported in 'cache friendly' solver yet, so switch to old solver - m_solver->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER); -#endif //USER_DEFINED_FRICTION_MODEL + btDiscreteDynamicsWorld* world = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration); m_dynamicsWorld = world; +#ifdef USER_DEFINED_FRICTION_MODEL + //user defined friction model is not supported in 'cache friendly' solver yet, so switch to old solver + + world->getSolverInfo().m_solverMode = SOLVER_RANDMIZE_ORDER; + +#endif //USER_DEFINED_FRICTION_MODEL + #ifdef DO_BENCHMARK_PYRAMIDS world->getSolverInfo().m_numIterations = 4; #endif //DO_BENCHMARK_PYRAMIDS @@ -460,9 +464,9 @@ int maxNumOutstandingTasks = 4; #ifdef USER_DEFINED_FRICTION_MODEL { //m_solver->setContactSolverFunc(ContactSolverFunc func,USER_CONTACT_SOLVER_TYPE1,DEFAULT_CONTACT_SOLVER_TYPE); - m_solver->SetFrictionSolverFunc(myFrictionModel,USER_CONTACT_SOLVER_TYPE1,DEFAULT_CONTACT_SOLVER_TYPE); - m_solver->SetFrictionSolverFunc(myFrictionModel,DEFAULT_CONTACT_SOLVER_TYPE,USER_CONTACT_SOLVER_TYPE1); - m_solver->SetFrictionSolverFunc(myFrictionModel,USER_CONTACT_SOLVER_TYPE1,USER_CONTACT_SOLVER_TYPE1); + solver->SetFrictionSolverFunc(myFrictionModel,USER_CONTACT_SOLVER_TYPE1,DEFAULT_CONTACT_SOLVER_TYPE); + solver->SetFrictionSolverFunc(myFrictionModel,DEFAULT_CONTACT_SOLVER_TYPE,USER_CONTACT_SOLVER_TYPE1); + solver->SetFrictionSolverFunc(myFrictionModel,USER_CONTACT_SOLVER_TYPE1,USER_CONTACT_SOLVER_TYPE1); //m_physicsEnvironmentPtr->setNumIterations(2); } #endif //USER_DEFINED_FRICTION_MODEL diff --git a/Demos/SoftDemo/SoftDemo.cpp b/Demos/SoftDemo/SoftDemo.cpp index b7d7e6f3b..75c24696b 100644 --- a/Demos/SoftDemo/SoftDemo.cpp +++ b/Demos/SoftDemo/SoftDemo.cpp @@ -132,18 +132,18 @@ void SoftDemo::clientMoveAndDisplay() m_node->m_v+=(m_goal-m_node->m_x)/dt; } -#define FIXED_STEP +//#define FIXED_STEP #ifdef FIXED_STEP m_dynamicsWorld->stepSimulation(dt=1.0f/60.f,0); #else - //during idle mode, just run 1 simulation step maximum - int maxSimSubSteps = m_idle ? 1 : 1; - if (m_idle) - dt = 1.0/420.f; + //during idle mode, just run 1 simulation step maximum, otherwise 4 at max + int maxSimSubSteps = m_idle ? 1 : 4; + //if (m_idle) + // dt = 1.0/420.f; - int numSimSteps = 0; - numSimSteps = m_dynamicsWorld->stepSimulation(dt,maxSimSubSteps); + int numSimSteps; + numSimSteps = m_dynamicsWorld->stepSimulation(dt); #ifdef VERBOSE_TIMESTEPPING_CONSOLEOUTPUT if (!numSimSteps) diff --git a/Extras/CDTestFramework/Bin/Opcode.dll b/Extras/CDTestFramework/Bin/Opcode.dll index 6f5df98c98470af9398c02ffd2e08190db2a8fb2..edc82f030bda6ee0d3bfb0c30346e3e7a7e9691a 100644 GIT binary patch delta 59 zcmZo@kZNd #elif defined( __GCC__ ) diff --git a/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp b/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp index f4f0a5e21..f19e16011 100644 --- a/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp +++ b/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp @@ -1,4 +1,3 @@ - /* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ @@ -26,6 +25,7 @@ subject to the following restrictions: #include "BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h" #include "BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h" #include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h" +#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h" #include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" @@ -35,17 +35,24 @@ subject to the following restrictions: -#define DEFAULT_MAX_OVERLAPPING_PAIRS 65535 -#define DEFAULT_STACK_ALLOCATOR_SIZE (5*1024*1024) -btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(btStackAlloc* stackAlloc,btPoolAllocator* persistentManifoldPool,btPoolAllocator* collisionAlgorithmPool) +btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo) +//btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(btStackAlloc* stackAlloc,btPoolAllocator* persistentManifoldPool,btPoolAllocator* collisionAlgorithmPool) { void* mem = btAlignedAlloc(sizeof(btVoronoiSimplexSolver),16); m_simplexSolver = new (mem)btVoronoiSimplexSolver(); + +#define USE_EPA 1 +#ifdef USE_EPA mem = btAlignedAlloc(sizeof(btGjkEpaPenetrationDepthSolver),16); m_pdSolver = new (mem)btGjkEpaPenetrationDepthSolver; +#else + mem = btAlignedAlloc(sizeof(btMinkowskiPenetrationDepthSolver),16); + m_pdSolver = new (mem)btMinkowskiPenetrationDepthSolver; +#endif//USE_EPA + //default CreationFunctions, filling the m_doubleDispatch table mem = btAlignedAlloc(sizeof(btConvexConvexAlgorithm::CreateFunc),16); @@ -94,37 +101,37 @@ btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(btStackAlloc* s collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3); collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize4); - if (stackAlloc) + if (constructionInfo.m_stackAlloc) { m_ownsStackAllocator = false; - this->m_stackAlloc = stackAlloc; + this->m_stackAlloc = constructionInfo.m_stackAlloc; } else { m_ownsStackAllocator = true; void* mem = btAlignedAlloc(sizeof(btStackAlloc),16); - m_stackAlloc = new(mem)btStackAlloc(DEFAULT_STACK_ALLOCATOR_SIZE); + m_stackAlloc = new(mem)btStackAlloc(constructionInfo.m_defaultStackAllocatorSize); } - if (persistentManifoldPool) + if (constructionInfo.m_persistentManifoldPool) { m_ownsPersistentManifoldPool = false; - m_persistentManifoldPool = persistentManifoldPool; + m_persistentManifoldPool = constructionInfo.m_persistentManifoldPool; } else { m_ownsPersistentManifoldPool = true; void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16); - m_persistentManifoldPool = new (mem) btPoolAllocator(sizeof(btPersistentManifold),DEFAULT_MAX_OVERLAPPING_PAIRS); + m_persistentManifoldPool = new (mem) btPoolAllocator(sizeof(btPersistentManifold),constructionInfo.m_defaultMaxPersistentManifoldPoolSize); } - if (collisionAlgorithmPool) + if (constructionInfo.m_collisionAlgorithmPool) { m_ownsCollisionAlgorithmPool = false; - m_collisionAlgorithmPool = collisionAlgorithmPool; + m_collisionAlgorithmPool = constructionInfo.m_collisionAlgorithmPool; } else { m_ownsCollisionAlgorithmPool = true; void* mem = btAlignedAlloc(sizeof(btPoolAllocator),16); - m_collisionAlgorithmPool = new(mem) btPoolAllocator(collisionAlgorithmMaxElementSize,DEFAULT_MAX_OVERLAPPING_PAIRS); + m_collisionAlgorithmPool = new(mem) btPoolAllocator(collisionAlgorithmMaxElementSize,constructionInfo.m_defaultMaxCollisionAlgorithmPoolSize); } @@ -187,7 +194,9 @@ btDefaultCollisionConfiguration::~btDefaultCollisionConfiguration() m_simplexSolver->~btVoronoiSimplexSolver(); btAlignedFree(m_simplexSolver); - m_pdSolver->~btGjkEpaPenetrationDepthSolver(); + + m_pdSolver->~btConvexPenetrationDepthSolver(); + btAlignedFree(m_pdSolver); diff --git a/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h b/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h index ebac071c8..0b274d394 100644 --- a/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h +++ b/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h @@ -18,7 +18,28 @@ subject to the following restrictions: #include "btCollisionConfiguration.h" class btVoronoiSimplexSolver; -class btGjkEpaPenetrationDepthSolver; +class btConvexPenetrationDepthSolver; + +struct btDefaultCollisionConstructionInfo +{ + btStackAlloc* m_stackAlloc; + btPoolAllocator* m_persistentManifoldPool; + btPoolAllocator* m_collisionAlgorithmPool; + int m_defaultMaxPersistentManifoldPoolSize; + int m_defaultMaxCollisionAlgorithmPoolSize; + int m_defaultStackAllocatorSize; + + btDefaultCollisionConstructionInfo() + :m_stackAlloc(0), + m_persistentManifoldPool(0), + m_collisionAlgorithmPool(0), + m_defaultMaxPersistentManifoldPoolSize(65535), + m_defaultMaxCollisionAlgorithmPoolSize(65535), + m_defaultStackAllocatorSize(5*1024*1024) + { + } +}; + ///btCollisionConfiguration allows to configure Bullet collision detection @@ -40,7 +61,7 @@ class btDefaultCollisionConfiguration : public btCollisionConfiguration //default simplex/penetration depth solvers btVoronoiSimplexSolver* m_simplexSolver; - btGjkEpaPenetrationDepthSolver* m_pdSolver; + btConvexPenetrationDepthSolver* m_pdSolver; //default CreationFunctions, filling the m_doubleDispatch table btCollisionAlgorithmCreateFunc* m_convexConvexCreateFunc; @@ -60,7 +81,8 @@ class btDefaultCollisionConfiguration : public btCollisionConfiguration public: - btDefaultCollisionConfiguration(btStackAlloc* stackAlloc=0,btPoolAllocator* persistentManifoldPool=0,btPoolAllocator* collisionAlgorithmPool=0); + + btDefaultCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo = btDefaultCollisionConstructionInfo()); virtual ~btDefaultCollisionConfiguration(); diff --git a/src/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h b/src/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h index 46090aee4..e75fc1bee 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h +++ b/src/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h @@ -31,6 +31,7 @@ class btManifoldPoint btManifoldPoint() :m_userPersistentData(0), m_appliedImpulse(0.f), + m_lateralFrictionInitialized(false), m_lifeTime(0) { } @@ -46,6 +47,9 @@ class btManifoldPoint m_combinedRestitution(btScalar(0.)), m_userPersistentData(0), m_appliedImpulse(0.f), + m_lateralFrictionInitialized(false), + m_appliedImpulseLateral1(0.f), + m_appliedImpulseLateral2(0.f), m_lifeTime(0) { @@ -74,8 +78,14 @@ class btManifoldPoint mutable void* m_userPersistentData; btScalar m_appliedImpulse; - int m_lifeTime;//lifetime of the contactpoint in frames + bool m_lateralFrictionInitialized; + btScalar m_appliedImpulseLateral1; + btScalar m_appliedImpulseLateral2; + int m_lifeTime;//lifetime of the contactpoint in frames + btVector3 m_lateralFrictionDir1; + btVector3 m_lateralFrictionDir2; + btScalar getDistance() const { return m_distance1; diff --git a/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h b/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h index 3722d1afd..2c83e1dfe 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h +++ b/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h @@ -125,6 +125,9 @@ public: //get rid of duplicated userPersistentData pointer m_pointCache[lastUsedIndex].m_userPersistentData = 0; m_pointCache[lastUsedIndex].m_appliedImpulse = 0.f; + m_pointCache[lastUsedIndex].m_lateralFrictionInitialized = false; + m_pointCache[lastUsedIndex].m_appliedImpulseLateral1 = 0.f; + m_pointCache[lastUsedIndex].m_appliedImpulseLateral2 = 0.f; m_pointCache[lastUsedIndex].m_lifeTime = 0; } @@ -139,6 +142,9 @@ public: #ifdef MAINTAIN_PERSISTENCY int lifeTime = m_pointCache[insertIndex].getLifeTime(); btScalar appliedImpulse = m_pointCache[insertIndex].m_appliedImpulse; + btScalar appliedLateralImpulse1 = m_pointCache[insertIndex].m_appliedImpulseLateral1; + btScalar appliedLateralImpulse2 = m_pointCache[insertIndex].m_appliedImpulseLateral2; + btAssert(lifeTime>=0); void* cache = m_pointCache[insertIndex].m_userPersistentData; @@ -146,6 +152,9 @@ public: m_pointCache[insertIndex].m_userPersistentData = cache; m_pointCache[insertIndex].m_appliedImpulse = appliedImpulse; + m_pointCache[insertIndex].m_appliedImpulseLateral1 = appliedLateralImpulse1; + m_pointCache[insertIndex].m_appliedImpulseLateral2 = appliedLateralImpulse2; + m_pointCache[insertIndex].m_lifeTime = lifeTime; #else clearUserCache(m_pointCache[insertIndex]); diff --git a/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h b/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h index 7b44d3da7..916d4581f 100644 --- a/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h +++ b/src/BulletDynamics/ConstraintSolver/btContactSolverInfo.h @@ -16,8 +16,18 @@ subject to the following restrictions: #ifndef CONTACT_SOLVER_INFO #define CONTACT_SOLVER_INFO +enum btSolverMode +{ + SOLVER_RANDMIZE_ORDER = 1, + SOLVER_FRICTION_SEPARATE = 2, + SOLVER_USE_WARMSTARTING = 4, + SOLVER_CACHE_FRIENDLY = 8 +}; + struct btContactSolverInfoData { + + btScalar m_tau; btScalar m_damping; btScalar m_friction; @@ -27,10 +37,13 @@ struct btContactSolverInfoData btScalar m_maxErrorReduction; btScalar m_sor; btScalar m_erp;//used as Baumgarte factor - bool m_splitImpulse; + btScalar m_erp2;//used in Split Impulse + int m_splitImpulse; btScalar m_splitImpulsePenetrationThreshold; btScalar m_linearSlop; + btScalar m_warmstartingFactor; + int m_solverMode; }; @@ -38,6 +51,8 @@ struct btContactSolverInfoData struct btContactSolverInfo : public btContactSolverInfoData { + + inline btContactSolverInfo() { m_tau = btScalar(0.6); @@ -47,10 +62,13 @@ struct btContactSolverInfo : public btContactSolverInfoData m_maxErrorReduction = btScalar(20.); m_numIterations = 10; m_erp = btScalar(0.2); + m_erp2 = btScalar(0.1); m_sor = btScalar(1.3); - m_splitImpulse = true; - m_splitImpulsePenetrationThreshold = 1.f; - m_linearSlop = 0.0002f; + m_splitImpulse = false; + m_splitImpulsePenetrationThreshold = -0.02f; + m_linearSlop = btScalar(0.0); + m_warmstartingFactor=btScalar(0.85); + m_solverMode = SOLVER_RANDMIZE_ORDER | SOLVER_CACHE_FRIENDLY | SOLVER_USE_WARMSTARTING; } }; diff --git a/src/BulletDynamics/ConstraintSolver/btOdeQuickstepConstraintSolver.cpp b/src/BulletDynamics/ConstraintSolver/btOdeQuickstepConstraintSolver.cpp index eb8052c25..c83864794 100644 --- a/src/BulletDynamics/ConstraintSolver/btOdeQuickstepConstraintSolver.cpp +++ b/src/BulletDynamics/ConstraintSolver/btOdeQuickstepConstraintSolver.cpp @@ -297,18 +297,6 @@ void btOdeQuickstepConstraintSolver::ConvertConstraint(btPersistentManifold* man for (i=0;igetContactPoint(i); - - debugDrawer->drawContactPoint( - cp.m_positionWorldOnB, - cp.m_normalWorldOnB, - cp.getDistance(), - cp.getLifeTime(), - color); - - } //assert (m_CurJoint < ODE_MAX_SOLVER_JOINTS); // if (manifold->getContactPoint(i).getDistance() < 0.0f) diff --git a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp index 81bd4ff59..e853ea238 100644 --- a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp +++ b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp @@ -106,8 +106,7 @@ bool MyContactDestroyedCallback(void* userPersistentData) btSequentialImpulseConstraintSolver::btSequentialImpulseConstraintSolver() -:m_solverMode(SOLVER_RANDMIZE_ORDER | SOLVER_CACHE_FRIENDLY | SOLVER_USE_WARMSTARTING ), -m_btSeed2(0) +:m_btSeed2(0) { gContactDestroyedCallback = &MyContactDestroyedCallback; @@ -154,6 +153,8 @@ void initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject solverBody->m_turnVelocity.setValue(0.f,0.f,0.f); } + + int gNumSplitImpulseRecoveries = 0; btScalar restitutionCurve(btScalar rel_vel, btScalar restitution); @@ -179,7 +180,7 @@ void resolveSplitPenetrationImpulseCacheFriendly( { (void)solverInfo; - if (contactConstraint.m_penetration > solverInfo.m_splitImpulsePenetrationThreshold) + if (contactConstraint.m_penetration < solverInfo.m_splitImpulsePenetrationThreshold) { gNumSplitImpulseRecoveries++; @@ -200,7 +201,7 @@ void resolveSplitPenetrationImpulseCacheFriendly( rel_vel = vel1Dotn-vel2Dotn; - btScalar positionalError = contactConstraint.m_penetration; + btScalar positionalError = -contactConstraint.m_penetration * solverInfo.m_erp2/solverInfo.m_timeStep; // btScalar positionalError = contactConstraint.m_penetration; btScalar velocityError = contactConstraint.m_restitution - rel_vel;// * damping; @@ -264,9 +265,9 @@ btScalar resolveSingleCollisionCombinedCacheFriendly( rel_vel = vel1Dotn-vel2Dotn; btScalar positionalError = 0.f; - if (!solverInfo.m_splitImpulse || (contactConstraint.m_penetration solverInfo.m_splitImpulsePenetrationThreshold)) { - positionalError = contactConstraint.m_penetration; + positionalError = -contactConstraint.m_penetration * solverInfo.m_erp/solverInfo.m_timeStep; } btScalar velocityError = contactConstraint.m_restitution - rel_vel;// * damping; @@ -725,8 +726,10 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol solverConstraint.m_restitution = 0.f; }; + btScalar penVel = -solverConstraint.m_penetration/infoGlobal.m_timeStep; - solverConstraint.m_penetration *= -(infoGlobal.m_erp/infoGlobal.m_timeStep); + + if (solverConstraint.m_restitution > penVel) { @@ -736,42 +739,78 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol ///warm starting (or zero if disabled) - if (m_solverMode & SOLVER_USE_WARMSTARTING) + if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) { - solverConstraint.m_appliedImpulse = cp.m_appliedImpulse; + solverConstraint.m_appliedImpulse = cp.m_appliedImpulse * infoGlobal.m_warmstartingFactor; if (rb0) - m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA].internalApplyImpulse(solverConstraint.m_contactNormal*rb0->getInvMass(),solverConstraint.m_angularComponentA,cp.m_appliedImpulse); + m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA].internalApplyImpulse(solverConstraint.m_contactNormal*rb0->getInvMass(),solverConstraint.m_angularComponentA,solverConstraint.m_appliedImpulse); if (rb1) - m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB].internalApplyImpulse(solverConstraint.m_contactNormal*rb1->getInvMass(),solverConstraint.m_angularComponentB,-cp.m_appliedImpulse); + m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB].internalApplyImpulse(solverConstraint.m_contactNormal*rb1->getInvMass(),solverConstraint.m_angularComponentB,-solverConstraint.m_appliedImpulse); } else { solverConstraint.m_appliedImpulse = 0.f; } solverConstraint.m_appliedPushImpulse = 0.f; - } - - { - btVector3 frictionDir1 = vel - cp.m_normalWorldOnB * rel_vel; - btScalar lat_rel_vel = frictionDir1.length2(); - if (lat_rel_vel > SIMD_EPSILON)//0.0f) + + solverConstraint.m_frictionIndex = m_tmpSolverFrictionConstraintPool.size(); + if (!cp.m_lateralFrictionInitialized) { - frictionDir1 /= btSqrt(lat_rel_vel); - addFrictionConstraint(frictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); - btVector3 frictionDir2 = frictionDir1.cross(cp.m_normalWorldOnB); - frictionDir2.normalize();//?? - addFrictionConstraint(frictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + cp.m_lateralFrictionDir1 = vel - cp.m_normalWorldOnB * rel_vel; + btScalar lat_rel_vel = cp.m_lateralFrictionDir1.length2(); + if (lat_rel_vel > SIMD_EPSILON)//0.0f) + { + cp.m_lateralFrictionDir1 /= btSqrt(lat_rel_vel); + addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB); + cp.m_lateralFrictionDir2.normalize();//?? + addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + } else + { + //re-calculate friction direction every frame, todo: check if this is really needed + + btPlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2); + addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + } + cp.m_lateralFrictionInitialized = true; + } else { - //re-calculate friction direction every frame, todo: check if this is really needed - btVector3 frictionDir1,frictionDir2; - btPlaneSpace1(cp.m_normalWorldOnB,frictionDir1,frictionDir2); - addFrictionConstraint(frictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); - addFrictionConstraint(frictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyIdA,solverBodyIdB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); } + { + btSolverConstraint& frictionConstraint1 = m_tmpSolverFrictionConstraintPool[solverConstraint.m_frictionIndex]; + if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) + { + frictionConstraint1.m_appliedImpulse = cp.m_appliedImpulseLateral1 * infoGlobal.m_warmstartingFactor; + if (rb0) + m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA].internalApplyImpulse(frictionConstraint1.m_contactNormal*rb0->getInvMass(),frictionConstraint1.m_angularComponentA,frictionConstraint1.m_appliedImpulse); + if (rb1) + m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB].internalApplyImpulse(frictionConstraint1.m_contactNormal*rb1->getInvMass(),frictionConstraint1.m_angularComponentB,-frictionConstraint1.m_appliedImpulse); + } else + { + frictionConstraint1.m_appliedImpulse = 0.f; + } + } + { + btSolverConstraint& frictionConstraint2 = m_tmpSolverFrictionConstraintPool[solverConstraint.m_frictionIndex+1]; + if (infoGlobal.m_solverMode & SOLVER_USE_WARMSTARTING) + { + frictionConstraint2.m_appliedImpulse = cp.m_appliedImpulseLateral2 * infoGlobal.m_warmstartingFactor; + if (rb0) + m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdA].internalApplyImpulse(frictionConstraint2.m_contactNormal*rb0->getInvMass(),frictionConstraint2.m_angularComponentA,frictionConstraint2.m_appliedImpulse); + if (rb1) + m_tmpSolverBodyPool[solverConstraint.m_solverBodyIdB].internalApplyImpulse(frictionConstraint2.m_contactNormal*rb1->getInvMass(),frictionConstraint2.m_angularComponentB,-frictionConstraint2.m_appliedImpulse); + } else + { + frictionConstraint2.m_appliedImpulse = 0.f; + } + } } - + } } @@ -829,7 +868,7 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations( { int j; - if (m_solverMode & SOLVER_RANDMIZE_ORDER) + if (infoGlobal.m_solverMode & SOLVER_RANDMIZE_ORDER) { if ((iteration & 7) == 0) { for (j=0; jm_appliedImpulse = solveManifold.m_appliedImpulse; + pt->m_appliedImpulseLateral1 = m_tmpSolverFrictionConstraintPool[solveManifold.m_frictionIndex].m_appliedImpulse; + pt->m_appliedImpulseLateral1 = m_tmpSolverFrictionConstraintPool[solveManifold.m_frictionIndex+1].m_appliedImpulse; + //do a callback here? } @@ -989,7 +1032,7 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendly(btCollisio btScalar btSequentialImpulseConstraintSolver::solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc,btDispatcher* /*dispatcher*/) { BT_PROFILE("solveGroup"); - if (getSolverMode() & SOLVER_CACHE_FRIENDLY) + if (infoGlobal.m_solverMode & SOLVER_CACHE_FRIENDLY) { //you need to provide at least some bodies //btSimpleDynamicsWorld needs to switch off SOLVER_CACHE_FRIENDLY @@ -1040,7 +1083,7 @@ btScalar btSequentialImpulseConstraintSolver::solveGroup(btCollisionObject** bod for ( iteration = 0;iterationm_appliedImpulse *= relaxation; } else diff --git a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h index a4067fb55..7143bc419 100644 --- a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h +++ b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h @@ -46,21 +46,13 @@ protected: ContactSolverFunc m_contactDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES]; ContactSolverFunc m_frictionDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES]; - //choose between several modes, different friction model etc. - int m_solverMode; + ///m_btSeed2 is used for re-arranging the constraint rows. improves convergence/quality of friction unsigned long m_btSeed2; public: - enum eSolverMode - { - SOLVER_RANDMIZE_ORDER = 1, - SOLVER_FRICTION_SEPARATE = 2, - SOLVER_USE_WARMSTARTING = 4, - SOLVER_CACHE_FRIENDLY = 8 - }; - + btSequentialImpulseConstraintSolver(); ///Advanced: Override the default contact solving function for contacts, for certain types of rigidbody @@ -92,16 +84,7 @@ public: btScalar solveCombinedContactFriction(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer); - void setSolverMode(int mode) - { - m_solverMode = mode; - } - - int getSolverMode() const - { - return m_solverMode; - } - + unsigned long btRand2(); int btRandInt2 (int n); diff --git a/src/BulletDynamics/ConstraintSolver/btSolverBody.h b/src/BulletDynamics/ConstraintSolver/btSolverBody.h index a4147f3be..c84fda61c 100644 --- a/src/BulletDynamics/ConstraintSolver/btSolverBody.h +++ b/src/BulletDynamics/ConstraintSolver/btSolverBody.h @@ -64,8 +64,8 @@ ATTRIBUTE_ALIGNED16 (struct) btSolverBody m_turnVelocity += angularComponent*(impulseMagnitude*m_angularFactor); } } - + void writebackVelocity() { if (m_invMass) diff --git a/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h b/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h index 206d9bb67..2c71360c5 100644 --- a/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h +++ b/src/BulletDynamics/ConstraintSolver/btSolverConstraint.h @@ -1,5 +1,3 @@ - - /* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ diff --git a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h index 2e8c9bef2..ddd0e90c4 100644 --- a/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h +++ b/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h @@ -23,7 +23,7 @@ class btOverlappingPairCache; class btConstraintSolver; class btSimulationIslandManager; class btTypedConstraint; -#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" + class btRaycastVehicle; class btIDebugDraw; @@ -52,9 +52,7 @@ protected: bool m_ownsIslandManager; bool m_ownsConstraintSolver; - btContactSolverInfo m_solverInfo; - - + btAlignedObjectArray m_vehicles; int m_profileTimings; @@ -140,11 +138,7 @@ public: virtual const btTypedConstraint* getConstraint(int index) const; - btContactSolverInfo& getSolverInfo() - { - return m_solverInfo; - } - + virtual btDynamicsWorldType getWorldType() const { return BT_DISCRETE_DYNAMICS_WORLD; diff --git a/src/BulletDynamics/Dynamics/btDynamicsWorld.h b/src/BulletDynamics/Dynamics/btDynamicsWorld.h index 6c9b476e0..2c42ea4a1 100644 --- a/src/BulletDynamics/Dynamics/btDynamicsWorld.h +++ b/src/BulletDynamics/Dynamics/btDynamicsWorld.h @@ -17,11 +17,13 @@ subject to the following restrictions: #define BT_DYNAMICS_WORLD_H #include "BulletCollision/CollisionDispatch/btCollisionWorld.h" +#include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h" + class btTypedConstraint; class btRaycastVehicle; class btConstraintSolver; - class btDynamicsWorld; + /// Type for the callback for each tick typedef void (*btInternalTickCallback)(const btDynamicsWorld *world, btScalar timeStep); @@ -35,7 +37,13 @@ enum btDynamicsWorldType ///btDynamicsWorld is the baseclass for several dynamics implementation, basic, discrete, parallel, and continuous class btDynamicsWorld : public btCollisionWorld { - public: + +protected: + btInternalTickCallback m_internalTickCallback; + + btContactSolverInfo m_solverInfo; + +public: btDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* broadphase,btCollisionConfiguration* collisionConfiguration) @@ -89,8 +97,11 @@ class btDynamicsWorld : public btCollisionWorld /// Set the callback for when an internal tick (simulation substep) happens void setInternalTickCallback(btInternalTickCallback cb) { m_internalTickCallback = cb; } - - btInternalTickCallback m_internalTickCallback; + + btContactSolverInfo& getSolverInfo() + { + return m_solverInfo; + } }; diff --git a/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp b/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp index cb37f8cf1..dfc5244d2 100644 --- a/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp +++ b/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.cpp @@ -20,8 +20,8 @@ subject to the following restrictions: #define ENABLE_SOFTBODY_CONCAVE_COLLISIONS 1 -btSoftBodyRigidBodyCollisionConfiguration::btSoftBodyRigidBodyCollisionConfiguration(btStackAlloc* stackAlloc,btPoolAllocator* persistentManifoldPool,btPoolAllocator* collisionAlgorithmPool) -:btDefaultCollisionConfiguration(stackAlloc,persistentManifoldPool,collisionAlgorithmPool) +btSoftBodyRigidBodyCollisionConfiguration::btSoftBodyRigidBodyCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo) +:btDefaultCollisionConfiguration(constructionInfo) { void* mem; diff --git a/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h b/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h index 10049ecfe..b098604ed 100644 --- a/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h +++ b/src/BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h @@ -35,7 +35,7 @@ class btSoftBodyRigidBodyCollisionConfiguration : public btDefaultCollisionConfi public: - btSoftBodyRigidBodyCollisionConfiguration(btStackAlloc* stackAlloc=0,btPoolAllocator* persistentManifoldPool=0,btPoolAllocator* collisionAlgorithmPool=0); + btSoftBodyRigidBodyCollisionConfiguration(const btDefaultCollisionConstructionInfo& constructionInfo = btDefaultCollisionConstructionInfo()); virtual ~btSoftBodyRigidBodyCollisionConfiguration();