clean up forces
This commit is contained in:
@@ -49,7 +49,7 @@ static bool g_floatingBase = true;
|
|||||||
static float friction = 1.;
|
static float friction = 1.;
|
||||||
class DeformableMultibody : public CommonMultiBodyBase
|
class DeformableMultibody : public CommonMultiBodyBase
|
||||||
{
|
{
|
||||||
btAlignedObjectArray<btDeformableLagrangianForce*> forces;
|
btAlignedObjectArray<btDeformableLagrangianForce*> m_forces;
|
||||||
public:
|
public:
|
||||||
DeformableMultibody(struct GUIHelperInterface* helper)
|
DeformableMultibody(struct GUIHelperInterface* helper)
|
||||||
: CommonMultiBodyBase(helper)
|
: CommonMultiBodyBase(helper)
|
||||||
@@ -229,11 +229,11 @@ void DeformableMultibody::initPhysics()
|
|||||||
|
|
||||||
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(2, 0.01, false);
|
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(2, 0.01, false);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
|
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
|
||||||
forces.push_back(mass_spring);
|
m_forces.push_back(mass_spring);
|
||||||
|
|
||||||
btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity);
|
btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
|
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
|
||||||
forces.push_back(gravity_force);
|
m_forces.push_back(gravity_force);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
||||||
@@ -257,11 +257,12 @@ void DeformableMultibody::exitPhysics()
|
|||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
// delete forces
|
// 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;
|
delete force;
|
||||||
}
|
}
|
||||||
|
m_forces.clear();
|
||||||
//delete collision shapes
|
//delete collision shapes
|
||||||
for (int j = 0; j < m_collisionShapes.size(); j++)
|
for (int j = 0; j < m_collisionShapes.size(); j++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
///Generally it is best to leave the rolling friction coefficient zero (or close to zero).
|
///Generally it is best to leave the rolling friction coefficient zero (or close to zero).
|
||||||
class DeformableRigid : public CommonRigidBodyBase
|
class DeformableRigid : public CommonRigidBodyBase
|
||||||
{
|
{
|
||||||
btAlignedObjectArray<btDeformableLagrangianForce*> forces;
|
btAlignedObjectArray<btDeformableLagrangianForce*> m_forces;
|
||||||
public:
|
public:
|
||||||
DeformableRigid(struct GUIHelperInterface* helper)
|
DeformableRigid(struct GUIHelperInterface* helper)
|
||||||
: CommonRigidBodyBase(helper)
|
: CommonRigidBodyBase(helper)
|
||||||
@@ -240,11 +240,11 @@ void DeformableRigid::initPhysics()
|
|||||||
|
|
||||||
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(2,0.01, false);
|
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(2,0.01, false);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
|
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
|
||||||
forces.push_back(mass_spring);
|
m_forces.push_back(mass_spring);
|
||||||
|
|
||||||
btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity);
|
btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
|
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
|
||||||
forces.push_back(gravity_force);
|
m_forces.push_back(gravity_force);
|
||||||
// add a few rigid bodies
|
// add a few rigid bodies
|
||||||
Ctor_RbUpStack(1);
|
Ctor_RbUpStack(1);
|
||||||
}
|
}
|
||||||
@@ -269,11 +269,12 @@ void DeformableRigid::exitPhysics()
|
|||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
// delete forces
|
// 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;
|
delete force;
|
||||||
}
|
}
|
||||||
|
m_forces.clear();
|
||||||
//delete collision shapes
|
//delete collision shapes
|
||||||
for (int j = 0; j < m_collisionShapes.size(); j++)
|
for (int j = 0; j < m_collisionShapes.size(); j++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ static bool supportsJointMotor(btMultiBody* mb, int mbLinkIndex)
|
|||||||
|
|
||||||
class GraspDeformable : public CommonRigidBodyBase
|
class GraspDeformable : public CommonRigidBodyBase
|
||||||
{
|
{
|
||||||
btAlignedObjectArray<btDeformableLagrangianForce*> forces;
|
btAlignedObjectArray<btDeformableLagrangianForce*> m_forces;
|
||||||
public:
|
public:
|
||||||
GraspDeformable(struct GUIHelperInterface* helper)
|
GraspDeformable(struct GUIHelperInterface* helper)
|
||||||
: CommonRigidBodyBase(helper)
|
: CommonRigidBodyBase(helper)
|
||||||
@@ -359,15 +359,15 @@ void GraspDeformable::initPhysics()
|
|||||||
|
|
||||||
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(.5,0.04, true);
|
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(.5,0.04, true);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
|
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
|
||||||
forces.push_back(mass_spring);
|
m_forces.push_back(mass_spring);
|
||||||
|
|
||||||
btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity);
|
btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
|
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
|
||||||
forces.push_back(gravity_force);
|
m_forces.push_back(gravity_force);
|
||||||
|
|
||||||
btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(2,10);
|
btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(2,10);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, neohookean);
|
getDeformableDynamicsWorld()->addForce(psb, neohookean);
|
||||||
forces.push_back(neohookean);
|
m_forces.push_back(neohookean);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // create a piece of cloth
|
// // create a piece of cloth
|
||||||
@@ -440,11 +440,13 @@ void GraspDeformable::exitPhysics()
|
|||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
// delete forces
|
// 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;
|
delete force;
|
||||||
}
|
}
|
||||||
|
m_forces.clear();
|
||||||
|
|
||||||
//delete collision shapes
|
//delete collision shapes
|
||||||
for (int j = 0; j < m_collisionShapes.size(); j++)
|
for (int j = 0; j < m_collisionShapes.size(); j++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ struct TetraBunny
|
|||||||
|
|
||||||
class Pinch : public CommonRigidBodyBase
|
class Pinch : public CommonRigidBodyBase
|
||||||
{
|
{
|
||||||
btAlignedObjectArray<btDeformableLagrangianForce*> forces;
|
btAlignedObjectArray<btDeformableLagrangianForce*> m_forces;
|
||||||
public:
|
public:
|
||||||
Pinch(struct GUIHelperInterface* helper)
|
Pinch(struct GUIHelperInterface* helper)
|
||||||
: CommonRigidBodyBase(helper)
|
: CommonRigidBodyBase(helper)
|
||||||
@@ -339,15 +339,15 @@ void Pinch::initPhysics()
|
|||||||
|
|
||||||
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(1,0.05);
|
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(1,0.05);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
|
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
|
||||||
forces.push_back(mass_spring);
|
m_forces.push_back(mass_spring);
|
||||||
|
|
||||||
btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity);
|
btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
|
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
|
||||||
forces.push_back(gravity_force);
|
m_forces.push_back(gravity_force);
|
||||||
|
|
||||||
btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(.2,1);
|
btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(.2,1);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, neohookean);
|
getDeformableDynamicsWorld()->addForce(psb, neohookean);
|
||||||
forces.push_back(neohookean);
|
m_forces.push_back(neohookean);
|
||||||
// add a grippers
|
// add a grippers
|
||||||
createGrip();
|
createGrip();
|
||||||
}
|
}
|
||||||
@@ -372,11 +372,12 @@ void Pinch::exitPhysics()
|
|||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
// delete forces
|
// 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;
|
delete force;
|
||||||
}
|
}
|
||||||
|
m_forces.clear();
|
||||||
//delete collision shapes
|
//delete collision shapes
|
||||||
for (int j = 0; j < m_collisionShapes.size(); j++)
|
for (int j = 0; j < m_collisionShapes.size(); j++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ struct TetraCube
|
|||||||
|
|
||||||
class VolumetricDeformable : public CommonRigidBodyBase
|
class VolumetricDeformable : public CommonRigidBodyBase
|
||||||
{
|
{
|
||||||
btAlignedObjectArray<btDeformableLagrangianForce*> forces;
|
btAlignedObjectArray<btDeformableLagrangianForce*> m_forces;
|
||||||
public:
|
public:
|
||||||
VolumetricDeformable(struct GUIHelperInterface* helper)
|
VolumetricDeformable(struct GUIHelperInterface* helper)
|
||||||
: CommonRigidBodyBase(helper)
|
: CommonRigidBodyBase(helper)
|
||||||
@@ -238,15 +238,15 @@ void VolumetricDeformable::initPhysics()
|
|||||||
|
|
||||||
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(0,0.03);
|
btDeformableMassSpringForce* mass_spring = new btDeformableMassSpringForce(0,0.03);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
|
getDeformableDynamicsWorld()->addForce(psb, mass_spring);
|
||||||
forces.push_back(mass_spring);
|
m_forces.push_back(mass_spring);
|
||||||
|
|
||||||
btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity);
|
btDeformableGravityForce* gravity_force = new btDeformableGravityForce(gravity);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
|
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
|
||||||
forces.push_back(gravity_force);
|
m_forces.push_back(gravity_force);
|
||||||
|
|
||||||
btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(.5,2.5);
|
btDeformableNeoHookeanForce* neohookean = new btDeformableNeoHookeanForce(.5,2.5);
|
||||||
getDeformableDynamicsWorld()->addForce(psb, neohookean);
|
getDeformableDynamicsWorld()->addForce(psb, neohookean);
|
||||||
forces.push_back(neohookean);
|
m_forces.push_back(neohookean);
|
||||||
|
|
||||||
}
|
}
|
||||||
// add a few rigid bodies
|
// add a few rigid bodies
|
||||||
@@ -273,12 +273,13 @@ void VolumetricDeformable::exitPhysics()
|
|||||||
delete obj;
|
delete obj;
|
||||||
}
|
}
|
||||||
// delete forces
|
// 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;
|
delete force;
|
||||||
}
|
}
|
||||||
|
m_forces.clear();
|
||||||
|
|
||||||
//delete collision shapes
|
//delete collision shapes
|
||||||
for (int j = 0; j < m_collisionShapes.size(); j++)
|
for (int j = 0; j < m_collisionShapes.size(); j++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user