demo cleanup part 2 (gimpact memory leaks)
This commit is contained in:
@@ -58,6 +58,20 @@ Real dts = 1.0 / 60.0;
|
|||||||
|
|
||||||
GimpactConcaveDemo::~GimpactConcaveDemo()
|
GimpactConcaveDemo::~GimpactConcaveDemo()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
|
||||||
|
{
|
||||||
|
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
|
||||||
|
btRigidBody* body = btRigidBody::upcast(obj);
|
||||||
|
if (body && body->getMotionState())
|
||||||
|
{
|
||||||
|
delete body->getMotionState();
|
||||||
|
}
|
||||||
|
m_dynamicsWorld->removeCollisionObject( obj );
|
||||||
|
delete obj;
|
||||||
|
}
|
||||||
|
|
||||||
delete m_dynamicsWorld;
|
delete m_dynamicsWorld;
|
||||||
|
|
||||||
delete m_indexVertexArrays;
|
delete m_indexVertexArrays;
|
||||||
@@ -66,6 +80,13 @@ GimpactConcaveDemo::~GimpactConcaveDemo()
|
|||||||
delete m_indexVertexArrays2;
|
delete m_indexVertexArrays2;
|
||||||
delete m_trimeshShape2;
|
delete m_trimeshShape2;
|
||||||
|
|
||||||
|
for (i=0;i<m_collisionShapes.size();i++)
|
||||||
|
{
|
||||||
|
btCollisionShape* shape = m_collisionShapes[i];
|
||||||
|
delete shape;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
delete m_gimpactCollisionCreateFunc;
|
delete m_gimpactCollisionCreateFunc;
|
||||||
|
|
||||||
delete m_collisionConfiguration;
|
delete m_collisionConfiguration;
|
||||||
@@ -77,65 +98,6 @@ GimpactConcaveDemo::~GimpactConcaveDemo()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= btCollisionObject::customMaterialCallback;
|
|
||||||
inline btScalar calculateCombinedFriction(float friction0,float friction1)
|
|
||||||
{
|
|
||||||
btScalar friction = friction0 * friction1;
|
|
||||||
|
|
||||||
const btScalar MAX_FRICTION = 10.f;
|
|
||||||
if (friction < -MAX_FRICTION)
|
|
||||||
friction = -MAX_FRICTION;
|
|
||||||
if (friction > MAX_FRICTION)
|
|
||||||
friction = MAX_FRICTION;
|
|
||||||
return friction;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
inline btScalar calculateCombinedRestitution(float restitution0,float restitution1)
|
|
||||||
{
|
|
||||||
return restitution0 * restitution1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
|
|
||||||
{
|
|
||||||
|
|
||||||
float friction0 = colObj0->getFriction();
|
|
||||||
float friction1 = colObj1->getFriction();
|
|
||||||
float restitution0 = colObj0->getRestitution();
|
|
||||||
float restitution1 = colObj1->getRestitution();
|
|
||||||
|
|
||||||
if (colObj0->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
|
|
||||||
{
|
|
||||||
friction0 = 1.0;//partId0,index0
|
|
||||||
restitution0 = 0.f;
|
|
||||||
}
|
|
||||||
if (colObj1->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
|
|
||||||
{
|
|
||||||
if (index1&1)
|
|
||||||
{
|
|
||||||
friction1 = 1.0f;//partId1,index1
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
friction1 = 0.f;
|
|
||||||
}
|
|
||||||
restitution1 = 0.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
cp.m_combinedFriction = calculateCombinedFriction(friction0,friction1);
|
|
||||||
cp.m_combinedRestitution = calculateCombinedRestitution(restitution0,restitution1);
|
|
||||||
|
|
||||||
//this return value is currently ignored, but to be on the safe side: return false if you don't calculate friction
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern ContactAddedCallback gContactAddedCallback;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void GimpactConcaveDemo::renderme()
|
void GimpactConcaveDemo::renderme()
|
||||||
@@ -373,19 +335,7 @@ void GimpactConcaveDemo::initGImpactCollision()
|
|||||||
btConcaveConcaveCollisionAlgorithm::registerAlgorithm(dispatcher);
|
btConcaveConcaveCollisionAlgorithm::registerAlgorithm(dispatcher);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// {
|
|
||||||
// //btGImpactCollisionAlgorithm::registerAlgorithm(dispatcher); /// Register GIMPACT !!!
|
|
||||||
// if(!m_gimpactCollisionCreateFunc) m_gimpactCollisionCreateFunc = new btGImpactCollisionAlgorithm::CreateFunc; /// NEW
|
|
||||||
//
|
|
||||||
// for (int i = 0;i < MAX_BROADPHASE_COLLISION_TYPES ;i++ )
|
|
||||||
// {
|
|
||||||
// m_dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE,i ,m_gimpactCollisionCreateFunc);
|
|
||||||
// }
|
|
||||||
// for (int i = 0;i < MAX_BROADPHASE_COLLISION_TYPES ;i++ )
|
|
||||||
// {
|
|
||||||
// m_dispatcher->registerCollisionCreateFunc(i,GIMPACT_SHAPE_PROXYTYPE ,m_gimpactCollisionCreateFunc);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BULLET_GIMPACT
|
#ifndef BULLET_GIMPACT
|
||||||
@@ -408,9 +358,6 @@ void GimpactConcaveDemo::initPhysics()
|
|||||||
setCameraDistance(45.f);
|
setCameraDistance(45.f);
|
||||||
|
|
||||||
|
|
||||||
gContactAddedCallback = CustomMaterialCombinerCallback;
|
|
||||||
|
|
||||||
|
|
||||||
/// Init Bullet
|
/// Init Bullet
|
||||||
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||||
|
|
||||||
@@ -432,40 +379,36 @@ void GimpactConcaveDemo::initPhysics()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Create Scene
|
/// Create Scene
|
||||||
float mass = 0.f;
|
float mass = 0.f;
|
||||||
btTransform startTransform;
|
btTransform startTransform;
|
||||||
startTransform.setIdentity();
|
startTransform.setIdentity();
|
||||||
|
|
||||||
|
|
||||||
btCollisionShape* staticboxShape1 = new btBoxShape(btVector3(200,1,200));//floor
|
btCollisionShape* staticboxShape1 = new btBoxShape(btVector3(200,1,200));//floor
|
||||||
btCollisionShape* staticboxShape2 = new btBoxShape(btVector3(1,50,200));//left wall
|
m_collisionShapes.push_back(staticboxShape1);
|
||||||
btCollisionShape* staticboxShape3 = new btBoxShape(btVector3(1,50,200));//right wall
|
|
||||||
btCollisionShape* staticboxShape4 = new btBoxShape(btVector3(200,50,1));//front wall
|
|
||||||
btCollisionShape* staticboxShape5 = new btBoxShape(btVector3(200,50,1));//back wall
|
|
||||||
|
|
||||||
btCompoundShape* staticScenario = new btCompoundShape();//static scenario
|
|
||||||
|
|
||||||
startTransform.setOrigin(btVector3(0,-10,0));
|
startTransform.setOrigin(btVector3(0,-10,0));
|
||||||
staticScenario->addChildShape(startTransform,staticboxShape1);
|
localCreateRigidBody(mass, startTransform,staticboxShape1);
|
||||||
|
|
||||||
|
btCollisionShape* staticboxShape2 = new btBoxShape(btVector3(1,50,200));//left wall
|
||||||
|
m_collisionShapes.push_back(staticboxShape2);
|
||||||
startTransform.setOrigin(btVector3(-200,15,0));
|
startTransform.setOrigin(btVector3(-200,15,0));
|
||||||
staticScenario->addChildShape(startTransform,staticboxShape2);
|
localCreateRigidBody(mass, startTransform,staticboxShape2);
|
||||||
|
|
||||||
|
btCollisionShape* staticboxShape3 = new btBoxShape(btVector3(1,50,200));//right wall
|
||||||
|
m_collisionShapes.push_back(staticboxShape3);
|
||||||
startTransform.setOrigin(btVector3(200,15,0));
|
startTransform.setOrigin(btVector3(200,15,0));
|
||||||
staticScenario->addChildShape(startTransform,staticboxShape3);
|
localCreateRigidBody(mass, startTransform,staticboxShape3);
|
||||||
|
|
||||||
|
btCollisionShape* staticboxShape4 = new btBoxShape(btVector3(200,50,1));//front wall
|
||||||
|
m_collisionShapes.push_back(staticboxShape4);
|
||||||
startTransform.setOrigin(btVector3(0,15,200));
|
startTransform.setOrigin(btVector3(0,15,200));
|
||||||
staticScenario->addChildShape(startTransform,staticboxShape4);
|
localCreateRigidBody(mass, startTransform,staticboxShape4);
|
||||||
|
|
||||||
|
btCollisionShape* staticboxShape5 = new btBoxShape(btVector3(200,50,1));//back wall
|
||||||
|
m_collisionShapes.push_back(staticboxShape5);
|
||||||
startTransform.setOrigin(btVector3(0,15,-200));
|
startTransform.setOrigin(btVector3(0,15,-200));
|
||||||
staticScenario->addChildShape(startTransform,staticboxShape5);
|
localCreateRigidBody(mass, startTransform,staticboxShape5);
|
||||||
|
|
||||||
startTransform.setOrigin(btVector3(0,0,0));
|
|
||||||
|
|
||||||
btRigidBody* staticBody = localCreateRigidBody(mass, startTransform,staticScenario);
|
|
||||||
|
|
||||||
staticBody->setCollisionFlags(staticBody->getCollisionFlags()|btCollisionObject::CF_STATIC_OBJECT);
|
|
||||||
staticBody->setActivationState(ISLAND_SLEEPING);
|
|
||||||
|
|
||||||
//enable custom material callback
|
|
||||||
staticBody->setCollisionFlags(staticBody->getCollisionFlags()|btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
|
||||||
|
|
||||||
|
|
||||||
//static plane
|
//static plane
|
||||||
@@ -473,29 +416,21 @@ void GimpactConcaveDemo::initPhysics()
|
|||||||
btVector3 normal(-0.5,0.5,0.0);
|
btVector3 normal(-0.5,0.5,0.0);
|
||||||
normal.normalize();
|
normal.normalize();
|
||||||
btCollisionShape* staticplaneShape6 = new btStaticPlaneShape(normal,0.0);// A plane
|
btCollisionShape* staticplaneShape6 = new btStaticPlaneShape(normal,0.0);// A plane
|
||||||
|
m_collisionShapes.push_back(staticplaneShape6);
|
||||||
startTransform.setOrigin(btVector3(0,-9,0));
|
startTransform.setOrigin(btVector3(0,-9,0));
|
||||||
|
|
||||||
btRigidBody* staticBody2 = localCreateRigidBody(mass, startTransform,staticplaneShape6 );
|
btRigidBody* staticBody2 = localCreateRigidBody(mass, startTransform,staticplaneShape6 );
|
||||||
|
|
||||||
staticBody2->setCollisionFlags(staticBody2->getCollisionFlags()|btCollisionObject::CF_STATIC_OBJECT);
|
|
||||||
staticBody2->setActivationState(ISLAND_SLEEPING);
|
|
||||||
|
|
||||||
|
|
||||||
//another static plane
|
//another static plane
|
||||||
|
|
||||||
normal.setValue(0.5,0.7,0.0);
|
normal.setValue(0.5,0.7,0.0);
|
||||||
//normal.normalize();
|
//normal.normalize();
|
||||||
btCollisionShape* staticplaneShape7 = new btStaticPlaneShape(normal,0.0);// A plane
|
btCollisionShape* staticplaneShape7 = new btStaticPlaneShape(normal,0.0);// A plane
|
||||||
|
m_collisionShapes.push_back(staticplaneShape7);
|
||||||
startTransform.setOrigin(btVector3(0,-10,0));
|
startTransform.setOrigin(btVector3(0,-10,0));
|
||||||
|
|
||||||
staticBody2 = localCreateRigidBody(mass, startTransform,staticplaneShape7 );
|
staticBody2 = localCreateRigidBody(mass, startTransform,staticplaneShape7 );
|
||||||
|
|
||||||
staticBody2->setCollisionFlags(staticBody2->getCollisionFlags()|btCollisionObject::CF_STATIC_OBJECT);
|
|
||||||
staticBody2->setActivationState(ISLAND_SLEEPING);
|
|
||||||
|
|
||||||
|
|
||||||
/// Create Static Torus
|
/// Create Static Torus
|
||||||
float height = 28;
|
float height = 28;
|
||||||
float step = 2.5;
|
float step = 2.5;
|
||||||
@@ -565,11 +500,14 @@ void GimpactConcaveDemo::initPhysics()
|
|||||||
for (int i=0;i<8;i++)
|
for (int i=0;i<8;i++)
|
||||||
{
|
{
|
||||||
btCollisionShape* boxShape = new btBoxShape(btVector3(1,1,1));
|
btCollisionShape* boxShape = new btBoxShape(btVector3(1,1,1));
|
||||||
|
m_collisionShapes.push_back(boxShape);
|
||||||
|
|
||||||
startTransform.setOrigin(btVector3(2*i-5,2,-3));
|
startTransform.setOrigin(btVector3(2*i-5,2,-3));
|
||||||
localCreateRigidBody(1, startTransform,boxShape);
|
localCreateRigidBody(1, startTransform,boxShape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//m_debugMode |= btIDebugDraw::DBG_DrawWireframe;
|
//m_debugMode |= btIDebugDraw::DBG_DrawWireframe;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -614,7 +552,7 @@ void GimpactConcaveDemo::clientMoveAndDisplay()
|
|||||||
//kinematic object
|
//kinematic object
|
||||||
btCollisionObject* colObj = kinematicTorus;
|
btCollisionObject* colObj = kinematicTorus;
|
||||||
//is this a rigidbody with a motionstate? then use the motionstate to update positions!
|
//is this a rigidbody with a motionstate? then use the motionstate to update positions!
|
||||||
if (btRigidBody::upcast(colObj) && btRigidBody::upcast(colObj)->getMotionState())
|
if (colObj && btRigidBody::upcast(colObj) && btRigidBody::upcast(colObj)->getMotionState())
|
||||||
{
|
{
|
||||||
btTransform newTrans;
|
btTransform newTrans;
|
||||||
btRigidBody::upcast(colObj)->getMotionState()->getWorldTransform(newTrans);
|
btRigidBody::upcast(colObj)->getMotionState()->getWorldTransform(newTrans);
|
||||||
@@ -719,153 +657,5 @@ void GimpactConcaveDemo::keyboardCallback(unsigned char key, int x, int y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void GimpactConcaveDemo::keyboardCallback(unsigned char key, int x, int y)
|
|
||||||
{
|
|
||||||
m_lastKey = 0;
|
|
||||||
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case 'q' :
|
|
||||||
case KEY_ESCAPE :
|
|
||||||
exit(0); break;
|
|
||||||
|
|
||||||
|
|
||||||
//GLUT_KEY_LEFT
|
|
||||||
case 'l' : stepLeft(); break;
|
|
||||||
case 'r' : stepRight(); break;
|
|
||||||
case 'f' : stepFront(); break;
|
|
||||||
case 'b' : stepBack(); break;
|
|
||||||
case 'z' : zoomIn(); break;
|
|
||||||
case 'x' : zoomOut(); break;
|
|
||||||
case 'i' : toggleIdle(); break;
|
|
||||||
case 'h':
|
|
||||||
if (m_debugMode & btIDebugDraw::DBG_NoHelpText)
|
|
||||||
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_NoHelpText);
|
|
||||||
else
|
|
||||||
m_debugMode |= btIDebugDraw::DBG_NoHelpText;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'w':
|
|
||||||
if (m_debugMode & btIDebugDraw::DBG_DrawWireframe)
|
|
||||||
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawWireframe);
|
|
||||||
else
|
|
||||||
m_debugMode |= btIDebugDraw::DBG_DrawWireframe;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'p':
|
|
||||||
if (m_debugMode & btIDebugDraw::DBG_ProfileTimings)
|
|
||||||
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_ProfileTimings);
|
|
||||||
else
|
|
||||||
m_debugMode |= btIDebugDraw::DBG_ProfileTimings;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'm':
|
|
||||||
if (m_debugMode & btIDebugDraw::DBG_EnableSatComparison)
|
|
||||||
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_EnableSatComparison);
|
|
||||||
else
|
|
||||||
m_debugMode |= btIDebugDraw::DBG_EnableSatComparison;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'n':
|
|
||||||
if (m_debugMode & btIDebugDraw::DBG_DisableBulletLCP)
|
|
||||||
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DisableBulletLCP);
|
|
||||||
else
|
|
||||||
m_debugMode |= btIDebugDraw::DBG_DisableBulletLCP;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 't' :
|
|
||||||
if (m_debugMode & btIDebugDraw::DBG_DrawText)
|
|
||||||
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawText);
|
|
||||||
else
|
|
||||||
m_debugMode |= btIDebugDraw::DBG_DrawText;
|
|
||||||
break;
|
|
||||||
case 'y':
|
|
||||||
if (m_debugMode & btIDebugDraw::DBG_DrawFeaturesText)
|
|
||||||
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawFeaturesText);
|
|
||||||
else
|
|
||||||
m_debugMode |= btIDebugDraw::DBG_DrawFeaturesText;
|
|
||||||
break;
|
|
||||||
case 'a':
|
|
||||||
if (m_debugMode & btIDebugDraw::DBG_DrawAabb){
|
|
||||||
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawAabb);
|
|
||||||
//printf("Not Draw AABB \n");
|
|
||||||
}else{
|
|
||||||
m_debugMode |= btIDebugDraw::DBG_DrawAabb;
|
|
||||||
//printf("Draw AABB \n");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'c' :
|
|
||||||
if (m_debugMode & btIDebugDraw::DBG_DrawContactPoints)
|
|
||||||
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawContactPoints);
|
|
||||||
else
|
|
||||||
m_debugMode |= btIDebugDraw::DBG_DrawContactPoints;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'd' :
|
|
||||||
if (m_debugMode & btIDebugDraw::DBG_NoDeactivation)
|
|
||||||
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_NoDeactivation);
|
|
||||||
else
|
|
||||||
m_debugMode |= btIDebugDraw::DBG_NoDeactivation;
|
|
||||||
if (m_debugMode | btIDebugDraw::DBG_NoDeactivation)
|
|
||||||
{
|
|
||||||
gDisableDeactivation = true;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
gDisableDeactivation = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case 'o' :
|
|
||||||
{
|
|
||||||
m_stepping = !m_stepping;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 's' : clientMoveAndDisplay(); break;
|
|
||||||
// case ' ' : newRandom(); break;
|
|
||||||
case ' ':
|
|
||||||
clientResetScene();
|
|
||||||
break;
|
|
||||||
case '1':
|
|
||||||
{
|
|
||||||
if (m_debugMode & btIDebugDraw::DBG_EnableCCD)
|
|
||||||
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_EnableCCD);
|
|
||||||
else
|
|
||||||
m_debugMode |= btIDebugDraw::DBG_EnableCCD;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case '.':
|
|
||||||
{
|
|
||||||
shootTrimesh(getCameraTargetPosition());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case '+':
|
|
||||||
{
|
|
||||||
m_ShootBoxInitialSpeed += 10.f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case '-':
|
|
||||||
{
|
|
||||||
m_ShootBoxInitialSpeed -= 10.f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
// std::cout << "unused key : " << key << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getDynamicsWorld() && getDynamicsWorld()->getDebugDrawer())
|
|
||||||
getDynamicsWorld()->getDebugDrawer()->setDebugMode(m_debugMode);
|
|
||||||
|
|
||||||
glutPostRedisplay();
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public:
|
|||||||
m_collisionConfiguration(NULL),
|
m_collisionConfiguration(NULL),
|
||||||
m_dispatcher(NULL),
|
m_dispatcher(NULL),
|
||||||
m_broadphase(NULL),
|
m_broadphase(NULL),
|
||||||
|
kinematicTorus(NULL),
|
||||||
m_constraintSolver(NULL),
|
m_constraintSolver(NULL),
|
||||||
m_gimpactCollisionCreateFunc(NULL),
|
m_gimpactCollisionCreateFunc(NULL),
|
||||||
m_steps_done(0)
|
m_steps_done(0)
|
||||||
@@ -99,6 +100,9 @@ public: ///data
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//keep the collision shapes, for deletion/cleanup
|
||||||
|
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
||||||
|
|
||||||
btTriangleIndexVertexArray *m_indexVertexArrays;
|
btTriangleIndexVertexArray *m_indexVertexArrays;
|
||||||
btTriangleIndexVertexArray *m_indexVertexArrays2;
|
btTriangleIndexVertexArray *m_indexVertexArrays2;
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ class GIM_ConvexDecomposition : public ConvexDecomposition::ConvexDecompInterfac
|
|||||||
protected:
|
protected:
|
||||||
btGImpactConvexDecompositionShape * m_compoundShape;
|
btGImpactConvexDecompositionShape * m_compoundShape;
|
||||||
|
|
||||||
|
btAlignedObjectArray<btCollisionShape*> m_convexShapes;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int mBaseCount;
|
int mBaseCount;
|
||||||
int mHullCount;
|
int mHullCount;
|
||||||
@@ -41,6 +44,17 @@ public:
|
|||||||
m_transformSubShapes = transformSubShapes;
|
m_transformSubShapes = transformSubShapes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ~GIM_ConvexDecomposition()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i=0;i<m_convexShapes.size();i++)
|
||||||
|
{
|
||||||
|
btCollisionShape* shape = m_convexShapes[i];
|
||||||
|
delete shape;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult &result)
|
virtual void ConvexDecompResult(ConvexDecomposition::ConvexResult &result)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -78,6 +92,7 @@ public:
|
|||||||
|
|
||||||
btCollisionShape* convexShape = new btConvexHullShape(
|
btCollisionShape* convexShape = new btConvexHullShape(
|
||||||
&(vertices[0].getX()),vertices.size(),sizeof(btVector3));
|
&(vertices[0].getX()),vertices.size(),sizeof(btVector3));
|
||||||
|
m_convexShapes.push_back(convexShape);
|
||||||
|
|
||||||
convexShape->setMargin(m_compoundShape->getMargin());
|
convexShape->setMargin(m_compoundShape->getMargin());
|
||||||
|
|
||||||
@@ -179,18 +194,22 @@ public:
|
|||||||
|
|
||||||
void btGImpactConvexDecompositionShape::buildConvexDecomposition(bool transformSubShapes)
|
void btGImpactConvexDecompositionShape::buildConvexDecomposition(bool transformSubShapes)
|
||||||
{
|
{
|
||||||
GIM_ConvexDecomposition decomposition(this,transformSubShapes);
|
|
||||||
|
m_decomposition = new GIM_ConvexDecomposition(this,transformSubShapes);
|
||||||
|
|
||||||
int part_count = m_trimeshInterfaces.size();
|
int part_count = m_trimeshInterfaces.size();
|
||||||
for (int i = 0;i<part_count ;i++ )
|
for (int i = 0;i<part_count ;i++ )
|
||||||
{
|
{
|
||||||
decomposition.processDecomposition(i);
|
m_decomposition->processDecomposition(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
postUpdate();
|
postUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btGImpactConvexDecompositionShape::~btGImpactConvexDecompositionShape()
|
||||||
|
{
|
||||||
|
delete m_decomposition;
|
||||||
|
}
|
||||||
void btGImpactConvexDecompositionShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
|
void btGImpactConvexDecompositionShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class btGImpactConvexDecompositionShape : public btGImpactCompoundShape
|
|||||||
protected:
|
protected:
|
||||||
btAlignedObjectArray<btGImpactMeshShapePart::TrimeshPrimitiveManager> m_trimeshInterfaces;
|
btAlignedObjectArray<btGImpactMeshShapePart::TrimeshPrimitiveManager> m_trimeshInterfaces;
|
||||||
|
|
||||||
|
class GIM_ConvexDecomposition* m_decomposition;
|
||||||
|
|
||||||
void buildConvexDecomposition(bool transformSubShapes);
|
void buildConvexDecomposition(bool transformSubShapes);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -63,13 +65,12 @@ public:
|
|||||||
m_trimeshInterfaces.push_back(triInterface);
|
m_trimeshInterfaces.push_back(triInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_decomposition = 0;
|
||||||
|
|
||||||
buildConvexDecomposition(children_has_transform);
|
buildConvexDecomposition(children_has_transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~btGImpactConvexDecompositionShape()
|
virtual ~btGImpactConvexDecompositionShape();
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SIMD_FORCE_INLINE btGImpactMeshShapePart::TrimeshPrimitiveManager * getTrimeshInterface(int part)
|
SIMD_FORCE_INLINE btGImpactMeshShapePart::TrimeshPrimitiveManager * getTrimeshInterface(int part)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user