clean up forces

This commit is contained in:
Xuchen Han
2019-08-26 16:01:29 -07:00
parent 0b391798b7
commit 7c39052163
5 changed files with 35 additions and 29 deletions

View File

@@ -59,7 +59,7 @@ static bool supportsJointMotor(btMultiBody* mb, int mbLinkIndex)
class GraspDeformable : public CommonRigidBodyBase
{
btAlignedObjectArray<btDeformableLagrangianForce*> forces;
btAlignedObjectArray<btDeformableLagrangianForce*> m_forces;
public:
GraspDeformable(struct GUIHelperInterface* helper)
: CommonRigidBodyBase(helper)
@@ -359,15 +359,15 @@ void GraspDeformable::initPhysics()
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(.5,0.04, true);
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
forces.push_back(mass_spring);
m_forces.push_back(mass_spring);
btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity);
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
forces.push_back(gravity_force);
m_forces.push_back(gravity_force);
btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(2,10);
getDeformableDynamicsWorld()->addForce(psb, neohookean);
forces.push_back(neohookean);
m_forces.push_back(neohookean);
}
// // create a piece of cloth
@@ -440,11 +440,13 @@ void GraspDeformable::exitPhysics()
delete obj;
}
// delete forces
for (int j = 0; j < forces.size(); j++)
for (int j = 0; j < m_forces.size(); j++)
{
btDeformableLagrangianForce* force = forces[j];
btDeformableLagrangianForce* force = m_forces[j];
delete force;
}
m_forces.clear();
//delete collision shapes
for (int j = 0; j < m_collisionShapes.size(); j++)
{