update examples to test different time stepping schemes (namely explicit, implicit and implicit with line search)/
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include "../Utils/b3ResourcePath.h"
|
#include "../Utils/b3ResourcePath.h"
|
||||||
|
|
||||||
///The DeformableContact shows the contact between deformable objects
|
///The DeformableContact shows the contact between deformable objects
|
||||||
|
|
||||||
class DeformableContact : public CommonRigidBodyBase
|
class DeformableContact : public CommonRigidBodyBase
|
||||||
{
|
{
|
||||||
btAlignedObjectArray<btDeformableLagrangianForce*> m_forces;
|
btAlignedObjectArray<btDeformableLagrangianForce*> m_forces;
|
||||||
@@ -149,12 +150,12 @@ void DeformableContact::initPhysics()
|
|||||||
20,20,
|
20,20,
|
||||||
1 + 2 + 4 + 8, true);
|
1 + 2 + 4 + 8, true);
|
||||||
|
|
||||||
psb->getCollisionShape()->setMargin(0.05);
|
psb->getCollisionShape()->setMargin(0.1);
|
||||||
psb->generateBendingConstraints(2);
|
psb->generateBendingConstraints(2);
|
||||||
psb->setTotalMass(1);
|
psb->setTotalMass(1);
|
||||||
psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects
|
psb->m_cfg.kKHR = 1; // collision hardness with kinematic objects
|
||||||
psb->m_cfg.kCHR = 1; // collision hardness with rigid body
|
psb->m_cfg.kCHR = 1; // collision hardness with rigid body
|
||||||
psb->m_cfg.kDF = 1;
|
psb->m_cfg.kDF = 0;
|
||||||
psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RD;
|
psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RD;
|
||||||
psb->m_cfg.collisions |= btSoftBody::fCollision::VF_DD;
|
psb->m_cfg.collisions |= btSoftBody::fCollision::VF_DD;
|
||||||
getDeformableDynamicsWorld()->addSoftBody(psb);
|
getDeformableDynamicsWorld()->addSoftBody(psb);
|
||||||
@@ -176,15 +177,15 @@ void DeformableContact::initPhysics()
|
|||||||
btVector3(+s, h, +s),
|
btVector3(+s, h, +s),
|
||||||
10,10,
|
10,10,
|
||||||
0, true);
|
0, true);
|
||||||
psb2->getCollisionShape()->setMargin(0.05);
|
psb2->getCollisionShape()->setMargin(0.1);
|
||||||
psb2->generateBendingConstraints(2);
|
psb2->generateBendingConstraints(2);
|
||||||
psb2->setTotalMass(1);
|
psb2->setTotalMass(1);
|
||||||
psb2->m_cfg.kKHR = 1; // collision hardness with kinematic objects
|
psb2->m_cfg.kKHR = 1; // collision hardness with kinematic objects
|
||||||
psb2->m_cfg.kCHR = 1; // collision hardness with rigid body
|
psb2->m_cfg.kCHR = 1; // collision hardness with rigid body
|
||||||
psb2->m_cfg.kDF = 1;
|
psb2->m_cfg.kDF = .1;
|
||||||
psb2->m_cfg.collisions = btSoftBody::fCollision::SDF_RD;
|
psb2->m_cfg.collisions = btSoftBody::fCollision::SDF_RD;
|
||||||
psb2->m_cfg.collisions |= btSoftBody::fCollision::VF_DD;
|
psb2->m_cfg.collisions |= btSoftBody::fCollision::VF_DD;
|
||||||
psb->translate(btVector3(3,0,0));
|
psb->translate(btVector3(3.5,0,0));
|
||||||
getDeformableDynamicsWorld()->addSoftBody(psb2);
|
getDeformableDynamicsWorld()->addSoftBody(psb2);
|
||||||
|
|
||||||
btDeformableMassSpringForce* mass_spring2 = new btDeformableMassSpringForce(10,1, true);
|
btDeformableMassSpringForce* mass_spring2 = new btDeformableMassSpringForce(10,1, true);
|
||||||
@@ -195,6 +196,8 @@ void DeformableContact::initPhysics()
|
|||||||
getDeformableDynamicsWorld()->addForce(psb2, gravity_force2);
|
getDeformableDynamicsWorld()->addForce(psb2, gravity_force2);
|
||||||
m_forces.push_back(gravity_force2);
|
m_forces.push_back(gravity_force2);
|
||||||
}
|
}
|
||||||
|
getDeformableDynamicsWorld()->setImplicit(true);
|
||||||
|
getDeformableDynamicsWorld()->setLineSearch(false);
|
||||||
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ void DeformableMultibody::initPhysics()
|
|||||||
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
|
getDeformableDynamicsWorld()->addForce(psb, gravity_force);
|
||||||
m_forces.push_back(gravity_force);
|
m_forces.push_back(gravity_force);
|
||||||
}
|
}
|
||||||
|
getDeformableDynamicsWorld()->setImplicit(false);
|
||||||
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,26 +346,23 @@ void DeformableMultibody::addColliders_testMultiDof(btMultiBody* pMultiBody, btM
|
|||||||
local_origin[0] = pMultiBody->getBasePos();
|
local_origin[0] = pMultiBody->getBasePos();
|
||||||
|
|
||||||
{
|
{
|
||||||
// float pos[4]={local_origin[0].x(),local_origin[0].y(),local_origin[0].z(),1};
|
|
||||||
btScalar quat[4] = {-world_to_local[0].x(), -world_to_local[0].y(), -world_to_local[0].z(), world_to_local[0].w()};
|
btScalar quat[4] = {-world_to_local[0].x(), -world_to_local[0].y(), -world_to_local[0].z(), world_to_local[0].w()};
|
||||||
|
|
||||||
if (1)
|
btCollisionShape* box = new btBoxShape(baseHalfExtents);
|
||||||
{
|
btMultiBodyLinkCollider* col = new btMultiBodyLinkCollider(pMultiBody, -1);
|
||||||
btCollisionShape* box = new btBoxShape(baseHalfExtents);
|
col->setCollisionShape(box);
|
||||||
btMultiBodyLinkCollider* col = new btMultiBodyLinkCollider(pMultiBody, -1);
|
|
||||||
col->setCollisionShape(box);
|
btTransform tr;
|
||||||
|
tr.setIdentity();
|
||||||
btTransform tr;
|
tr.setOrigin(local_origin[0]);
|
||||||
tr.setIdentity();
|
tr.setRotation(btQuaternion(quat[0], quat[1], quat[2], quat[3]));
|
||||||
tr.setOrigin(local_origin[0]);
|
col->setWorldTransform(tr);
|
||||||
tr.setRotation(btQuaternion(quat[0], quat[1], quat[2], quat[3]));
|
|
||||||
col->setWorldTransform(tr);
|
pWorld->addCollisionObject(col, 2, 1 + 2);
|
||||||
|
|
||||||
pWorld->addCollisionObject(col, 2, 1 + 2);
|
col->setFriction(friction);
|
||||||
|
pMultiBody->setBaseCollider(col);
|
||||||
col->setFriction(friction);
|
|
||||||
pMultiBody->setBaseCollider(col);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < pMultiBody->getNumLinks(); ++i)
|
for (int i = 0; i < pMultiBody->getNumLinks(); ++i)
|
||||||
@@ -378,7 +375,6 @@ void DeformableMultibody::addColliders_testMultiDof(btMultiBody* pMultiBody, btM
|
|||||||
for (int i = 0; i < pMultiBody->getNumLinks(); ++i)
|
for (int i = 0; i < pMultiBody->getNumLinks(); ++i)
|
||||||
{
|
{
|
||||||
btVector3 posr = local_origin[i + 1];
|
btVector3 posr = local_origin[i + 1];
|
||||||
// float pos[4]={posr.x(),posr.y(),posr.z(),1};
|
|
||||||
|
|
||||||
btScalar quat[4] = {-world_to_local[i + 1].x(), -world_to_local[i + 1].y(), -world_to_local[i + 1].z(), world_to_local[i + 1].w()};
|
btScalar quat[4] = {-world_to_local[i + 1].x(), -world_to_local[i + 1].y(), -world_to_local[i + 1].z(), world_to_local[i + 1].w()};
|
||||||
|
|
||||||
|
|||||||
@@ -231,6 +231,8 @@ void DeformableRigid::initPhysics()
|
|||||||
// add a few rigid bodies
|
// add a few rigid bodies
|
||||||
Ctor_RbUpStack(1);
|
Ctor_RbUpStack(1);
|
||||||
}
|
}
|
||||||
|
getDeformableDynamicsWorld()->setImplicit(true);
|
||||||
|
getDeformableDynamicsWorld()->setLineSearch(false);
|
||||||
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -329,6 +329,7 @@ void Pinch::initPhysics()
|
|||||||
// add a grippers
|
// add a grippers
|
||||||
createGrip();
|
createGrip();
|
||||||
}
|
}
|
||||||
|
getDeformableDynamicsWorld()->setImplicit(false);
|
||||||
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ void VolumetricDeformable::initPhysics()
|
|||||||
//add the ground to the dynamics world
|
//add the ground to the dynamics world
|
||||||
m_dynamicsWorld->addRigidBody(body);
|
m_dynamicsWorld->addRigidBody(body);
|
||||||
}
|
}
|
||||||
|
getDeformableDynamicsWorld()->setLineSearch(false);
|
||||||
|
|
||||||
createStaticBox(btVector3(1, 5, 5), btVector3(-5,0,0));
|
createStaticBox(btVector3(1, 5, 5), btVector3(-5,0,0));
|
||||||
createStaticBox(btVector3(1, 5, 5), btVector3(5,0,0));
|
createStaticBox(btVector3(1, 5, 5), btVector3(5,0,0));
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ btDeformableBodySolver::btDeformableBodySolver()
|
|||||||
, m_cg(20)
|
, m_cg(20)
|
||||||
, m_maxNewtonIterations(3)
|
, m_maxNewtonIterations(3)
|
||||||
, m_newtonTolerance(1e-4)
|
, m_newtonTolerance(1e-4)
|
||||||
, m_lineSearch(false)
|
, m_lineSearch(true)
|
||||||
{
|
{
|
||||||
m_objective = new btDeformableBackwardEulerObjective(m_softBodies, m_backupVelocity);
|
m_objective = new btDeformableBackwardEulerObjective(m_softBodies, m_backupVelocity);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user