delete forces in exitPhysics
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
///Generally it is best to leave the rolling friction coefficient zero (or close to zero).
|
||||
class DeformableRigid : public CommonRigidBodyBase
|
||||
{
|
||||
btAlignedObjectArray<btDeformableLagrangianForce*> forces;
|
||||
public:
|
||||
DeformableRigid(struct GUIHelperInterface* helper)
|
||||
: CommonRigidBodyBase(helper)
|
||||
@@ -233,9 +234,14 @@ void DeformableRigid::initPhysics()
|
||||
psb->m_cfg.kDF = 1;
|
||||
psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RD;
|
||||
getDeformableDynamicsWorld()->addSoftBody(psb);
|
||||
getDeformableDynamicsWorld()->addForce(psb, new btDeformableMassSpringForce(2, 0.01, false));
|
||||
getDeformableDynamicsWorld()->addForce(psb, new btDeformableGravityForce(gravity));
|
||||
|
||||
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(2,0.01, false);
|
||||
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
|
||||
forces.push_back(mass_spring);
|
||||
|
||||
btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity);
|
||||
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
|
||||
forces.push_back(gravity_force);
|
||||
// add a few rigid bodies
|
||||
Ctor_RbUpStack(1);
|
||||
}
|
||||
@@ -259,7 +265,12 @@ void DeformableRigid::exitPhysics()
|
||||
m_dynamicsWorld->removeCollisionObject(obj);
|
||||
delete obj;
|
||||
}
|
||||
|
||||
// delete forces
|
||||
for (int j = 0; j < forces.size(); j++)
|
||||
{
|
||||
btDeformableLagrangianForce* force = forces[j];
|
||||
delete force;
|
||||
}
|
||||
//delete collision shapes
|
||||
for (int j = 0; j < m_collisionShapes.size(); j++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user