support gravity factor for deformables

This commit is contained in:
Xuchen Han 2020-05-26 16:48:50 -07:00
parent 5233b72160
commit e89903a8ab
3 changed files with 9 additions and 1 deletions

View File

@ -68,7 +68,7 @@ public:
btSoftBody::Node& n = psb->m_nodes[j];
size_t id = n.index;
btScalar mass = (n.m_im == 0) ? 0 : 1. / n.m_im;
btVector3 scaled_force = scale * m_gravity * mass;
btVector3 scaled_force = scale * m_gravity * mass * m_softBodies[i]->m_gravityFactor;
force[id] += scaled_force;
}
}

View File

@ -228,6 +228,7 @@ void btSoftBody::initDefaults()
m_softSoftCollision = false;
m_maxSpeedSquared = 0;
m_repulsionStiffness = 0.5;
m_gravityFactor = 1;
m_fdbvnt = 0;
}
@ -3426,6 +3427,11 @@ void btSoftBody::setSpringStiffness(btScalar k)
m_repulsionStiffness = k;
}
void btSoftBody::setGravityFactor(btScalar gravFactor)
{
m_gravityFactor = gravFactor;
}
void btSoftBody::initializeDmInverse()
{
btScalar unit_simplex_measure = 1./6.;

View File

@ -821,6 +821,7 @@ public:
btScalar m_maxSpeedSquared;
btAlignedObjectArray<btVector3> m_quads; // quadrature points for collision detection
btScalar m_repulsionStiffness;
btScalar m_gravityFactor;
btAlignedObjectArray<btVector3> m_X; // initial positions
btAlignedObjectArray<btVector4> m_renderNodesInterpolationWeights;
@ -1168,6 +1169,7 @@ public:
void applyClusters(bool drift);
void dampClusters();
void setSpringStiffness(btScalar k);
void setGravityFactor(btScalar gravFactor);
void initializeDmInverse();
void updateDeformation();
void advanceDeformation();