diff options
author | Xuchen Han <xuchenhan@xuchenhan-macbookpro.roam.corp.google.com> | 2019-07-25 13:51:44 -0700 |
---|---|---|
committer | Xuchen Han <xuchenhan@xuchenhan-macbookpro.roam.corp.google.com> | 2019-08-02 13:15:06 -0700 |
commit | ec403f790d271af9b33eabaab07cd454eb1437c3 (patch) | |
tree | bdbb8b222d2ec2de529352d5916efa6aa56a155c /src/BulletSoftBody/btDeformableGravityForce.h | |
parent | 233a381e7cc39b1768771f0d3660f985dd1bcf95 (diff) | |
download | bullet3-ec403f790d271af9b33eabaab07cd454eb1437c3.tar.gz |
factor out force; now btDeformableLagrangianceForce can be specified at configuration time and to specific softbody
Diffstat (limited to 'src/BulletSoftBody/btDeformableGravityForce.h')
-rw-r--r-- | src/BulletSoftBody/btDeformableGravityForce.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/BulletSoftBody/btDeformableGravityForce.h b/src/BulletSoftBody/btDeformableGravityForce.h index d8571fa73..398662e1f 100644 --- a/src/BulletSoftBody/btDeformableGravityForce.h +++ b/src/BulletSoftBody/btDeformableGravityForce.h @@ -16,7 +16,7 @@ public: using TVStack = btDeformableLagrangianForce::TVStack; btVector3 m_gravity; - btDeformableGravityForce(const btAlignedObjectArray<btSoftBody *>& softBodies, const btVector3& g) : btDeformableLagrangianForce(softBodies), m_gravity(g) + btDeformableGravityForce(const btVector3& g) : m_gravity(g) { } @@ -39,14 +39,14 @@ public: virtual void addScaledGravityForce(btScalar scale, TVStack& force) { int numNodes = getNumNodes(); - btAssert(numNodes == force.size()) + btAssert(numNodes <= force.size()) for (int i = 0; i < m_softBodies.size(); ++i) { btSoftBody* psb = m_softBodies[i]; for (int j = 0; j < psb->m_nodes.size(); ++j) { btSoftBody::Node& n = psb->m_nodes[j]; - size_t id = m_indices[&n]; + size_t id = m_indices->at(&n); btScalar mass = (n.m_im == 0) ? 0 : 1. / n.m_im; btVector3 scaled_force = scale * m_gravity * mass; force[id] += scaled_force; @@ -54,7 +54,10 @@ public: } } - + virtual btDeformableLagrangianForceType getForceType() + { + return BT_GRAVITY_FORCE; + } }; |