- stop threads when exiting demo that uses multi threading

- improved friction model for parallel solver (align the friction direction with projected velocity, unless the projection is close to zero (only then use 2 arbitrary axis orthogonal to contact normal)
This commit is contained in:
ejcoumans
2007-11-11 22:48:08 +00:00
parent 232f41353f
commit 56c69bc42e
6 changed files with 76 additions and 19 deletions

View File

@@ -322,6 +322,9 @@ float myFrictionModel( btRigidBody& body1, btRigidBody& body2, btManifoldPoint&
void CcdPhysicsDemo::initPhysics()
{
m_threadSupportSolver = 0;
m_threadSupportCollision = 0;
//#define USE_GROUND_PLANE 1
#ifdef USE_GROUND_PLANE
m_collisionShapes.push_back(new btStaticPlaneShape(btVector3(0,1,0),0.5));
@@ -356,7 +359,7 @@ int maxNumOutstandingTasks = 4;
#ifdef USE_WIN32_THREADING
Win32ThreadSupport* threadSupportCollision = new Win32ThreadSupport(Win32ThreadSupport::Win32ThreadConstructionInfo(
m_threadSupportCollision = new Win32ThreadSupport(Win32ThreadSupport::Win32ThreadConstructionInfo(
"collision",
processCollisionTask,
createCollisionLocalStoreMemory,
@@ -389,7 +392,7 @@ int maxNumOutstandingTasks = 4;
#endif
m_dispatcher = new SpuGatheringCollisionDispatcher(threadSupportCollision,maxNumOutstandingTasks,m_collisionConfiguration);
m_dispatcher = new SpuGatheringCollisionDispatcher(m_threadSupportCollision,maxNumOutstandingTasks,m_collisionConfiguration);
// m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
#else
@@ -422,7 +425,7 @@ int maxNumOutstandingTasks = 4;
#ifdef USE_PARALLEL_SOLVER
Win32ThreadSupport* threadSupportSolver = new Win32ThreadSupport(Win32ThreadSupport::Win32ThreadConstructionInfo(
m_threadSupportSolver = new Win32ThreadSupport(Win32ThreadSupport::Win32ThreadConstructionInfo(
"solver",
processSolverTask,
createSolverLocalStoreMemory,
@@ -648,12 +651,22 @@ void CcdPhysicsDemo::exitPhysics()
//delete solver
delete m_solver;
if (m_threadSupportSolver)
{
delete m_threadSupportSolver;
}
//delete broadphase
delete m_broadphase;
//delete dispatcher
delete m_dispatcher;
if (m_threadSupportCollision)
{
delete m_threadSupportCollision;
}
delete m_collisionConfiguration;

View File

@@ -25,6 +25,7 @@ class btCollisionDispatcher;
class btConstraintSolver;
struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration;
class Win32ThreadSupport;
///CcdPhysicsDemo shows basic stacking using Bullet physics, and allows toggle of Ccd (using key '1')
class CcdPhysicsDemo : public DemoApplication
@@ -37,6 +38,10 @@ class CcdPhysicsDemo : public DemoApplication
btCollisionDispatcher* m_dispatcher;
Win32ThreadSupport* m_threadSupportCollision;
Win32ThreadSupport* m_threadSupportSolver;
btConstraintSolver* m_solver;
btCollisionAlgorithmCreateFunc* m_boxBoxCF;