Merge pull request #2509 from xhan0619/separate-bending-stiffness
Separate in-plane and bending stiffness for mass spring model
This commit is contained in:
@@ -23,14 +23,18 @@ class btDeformableMassSpringForce : public btDeformableLagrangianForce
|
||||
// If true, the damping force will be in the direction of the spring
|
||||
// If false, the damping force will be in the direction of the velocity
|
||||
bool m_momentum_conserving;
|
||||
btScalar m_elasticStiffness, m_dampingStiffness;
|
||||
btScalar m_elasticStiffness, m_dampingStiffness, m_bendingStiffness;
|
||||
public:
|
||||
typedef btAlignedObjectArray<btVector3> TVStack;
|
||||
btDeformableMassSpringForce() : m_momentum_conserving(false), m_elasticStiffness(1), m_dampingStiffness(0.05)
|
||||
{
|
||||
}
|
||||
btDeformableMassSpringForce(btScalar k, btScalar d, bool conserve_angular = true) : m_momentum_conserving(conserve_angular), m_elasticStiffness(k), m_dampingStiffness(d)
|
||||
btDeformableMassSpringForce(btScalar k, btScalar d, bool conserve_angular = true, double bending_k = -1) : m_momentum_conserving(conserve_angular), m_elasticStiffness(k), m_dampingStiffness(d), m_bendingStiffness(bending_k)
|
||||
{
|
||||
if (m_bendingStiffness < btScalar(0))
|
||||
{
|
||||
m_bendingStiffness = m_elasticStiffness;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void addScaledForces(btScalar scale, TVStack& force)
|
||||
@@ -103,7 +107,8 @@ public:
|
||||
// elastic force
|
||||
btVector3 dir = (node2->m_q - node1->m_q);
|
||||
btVector3 dir_normalized = (dir.norm() > SIMD_EPSILON) ? dir.normalized() : btVector3(0,0,0);
|
||||
btVector3 scaled_force = scale * m_elasticStiffness * (dir - dir_normalized * r);
|
||||
btScalar scaled_stiffness = scale * (link.m_bbending ? m_bendingStiffness : m_elasticStiffness);
|
||||
btVector3 scaled_force = scaled_stiffness * (dir - dir_normalized * r);
|
||||
force[id1] += scaled_force;
|
||||
force[id2] -= scaled_force;
|
||||
}
|
||||
@@ -212,7 +217,6 @@ public:
|
||||
{
|
||||
continue;
|
||||
}
|
||||
btScalar scaled_k = m_elasticStiffness * scale;
|
||||
for (int j = 0; j < psb->m_links.size(); ++j)
|
||||
{
|
||||
const btSoftBody::Link& link = psb->m_links[j];
|
||||
@@ -227,6 +231,7 @@ public:
|
||||
btVector3 dir_normalized = (dir_norm > SIMD_EPSILON) ? dir.normalized() : btVector3(0,0,0);
|
||||
btVector3 dx_diff = dx[id1] - dx[id2];
|
||||
btVector3 scaled_df = btVector3(0,0,0);
|
||||
btScalar scaled_k = scale * (link.m_bbending ? m_bendingStiffness : m_elasticStiffness);
|
||||
if (dir_norm > SIMD_EPSILON)
|
||||
{
|
||||
scaled_df -= scaled_k * dir_normalized.dot(dx_diff) * dir_normalized;
|
||||
|
||||
Reference in New Issue
Block a user