Added a gCompoundChildShapePairCallback to filter (enable/disable) child shape collisions for a btCompoundShape.

Thanks to Rich McDaniel for the patch.
See MyCompoundChildShapeCallback in Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp for usage.
This commit is contained in:
erwin.coumans@gmail.com
2013-04-02 02:01:43 +00:00
parent 1f4f8c7e05
commit e8c2475c95
4 changed files with 57 additions and 4 deletions

View File

@@ -46,9 +46,12 @@ GLDebugDrawer gDebugDrawer;
#include "../../Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h"
#endif//USE_PARALLEL_DISPATCHER
#include "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h"//for the callback
bool MyCompoundChildShapeCallback(const btCollisionShape* pShape0, const btCollisionShape* pShape1)
{
return true;
}
#include "GLDebugFont.h"
#include <stdio.h> //printf debugging
@@ -80,6 +83,7 @@ void ConvexDecompositionDemo::initPhysics()
///MyContactCallback is just an example to show how to get access to the child shape that collided
bool MyContactCallback (
btManifoldPoint& cp,
@@ -113,6 +117,7 @@ void ConvexDecompositionDemo::setupEmptyDynamicsWorld()
{
m_collisionConfiguration = new btDefaultCollisionConfiguration();
#ifdef USE_PARALLEL_DISPATCHER
#ifdef USE_WIN32_THREADING
@@ -135,6 +140,7 @@ m_collisionConfiguration = new btDefaultCollisionConfiguration();
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
#endif//USE_PARALLEL_DISPATCHER
gCompoundChildShapePairCallback = MyCompoundChildShapeCallback;
convexDecompositionObjectOffset.setValue(10,0,0);
@@ -156,8 +162,6 @@ m_collisionConfiguration = new btDefaultCollisionConfiguration();
void ConvexDecompositionDemo::initPhysics(const char* filename)
{
sEnableSAT = !sEnableSAT;
gContactAddedCallback = &MyContactCallback;
setupEmptyDynamicsWorld();
@@ -754,3 +758,22 @@ void ConvexDecompositionDemo::clientResetScene()
exitPhysics();
initPhysics("file.obj");
}
void ConvexDecompositionDemo::keyboardCallback(unsigned char key, int x, int y)
{
if (key=='S')
{
sEnableSAT= !sEnableSAT;
if (sEnableSAT)
{
printf("SAT enabled after the next restart of the demo\n");
} else
{
printf("SAT disabled after the next restart of the demo\n");
}
} else
{
PlatformDemoApplication::keyboardCallback(key,x,y);
}
}