From ec403f790d271af9b33eabaab07cd454eb1437c3 Mon Sep 17 00:00:00 2001 From: Xuchen Han Date: Thu, 25 Jul 2019 13:51:44 -0700 Subject: factor out force; now btDeformableLagrangianceForce can be specified at configuration time and to specific softbody --- src/BulletSoftBody/btDeformableGravityForce.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/BulletSoftBody/btDeformableGravityForce.h') 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& 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; + } }; -- cgit v1.2.1