diff --git a/src/BulletSoftBody/btSoftBody.cpp b/src/BulletSoftBody/btSoftBody.cpp index 0fec84ab4..152035238 100644 --- a/src/BulletSoftBody/btSoftBody.cpp +++ b/src/BulletSoftBody/btSoftBody.cpp @@ -222,6 +222,9 @@ void btSoftBody::initDefaults() m_useSelfCollision = false; m_usePostCollisionDamping = false; m_collisionFlags = 0; + m_maxSpeedSquared = 0; + m_repulsionStiffness = 0.5; + m_fdbvnt = 0; } // @@ -3423,7 +3426,7 @@ void btSoftBody::setSpringStiffness(btScalar k) { m_links[i].Feature::m_material->m_kLST = k; } - repulsionStiffness = k; + m_repulsionStiffness = k; } void btSoftBody::initializeDmInverse() diff --git a/src/BulletSoftBody/btSoftBody.h b/src/BulletSoftBody/btSoftBody.h index b1d78b7b7..7b7374a73 100644 --- a/src/BulletSoftBody/btSoftBody.h +++ b/src/BulletSoftBody/btSoftBody.h @@ -724,6 +724,15 @@ public: /* SolverState */ struct SolverState { + //if you add new variables, always initialize them! + SolverState() + :sdt(0), + isdt(0), + velmrg(0), + radmrg(0), + updmrg(0) + { + } btScalar sdt; // dt*timescale btScalar isdt; // 1/sdt btScalar velmrg; // velocity margin @@ -810,7 +819,7 @@ public: btScalar m_sleepingThreshold; btScalar m_maxSpeedSquared; btAlignedObjectArray m_quads; // quadrature points for collision detection - btScalar repulsionStiffness; + btScalar m_repulsionStiffness; btAlignedObjectArray m_X; // initial positions btAlignedObjectArray m_renderNodesInterpolationWeights; @@ -1301,7 +1310,7 @@ public: btScalar I = 0; btScalar mass = node->m_im == 0 ? 0 : btScalar(1)/node->m_im; if (applySpringForce) - I = -btMin(repulsionStiffness * timeStep * d, mass * (OVERLAP_REDUCTION_FACTOR * d / timeStep - vn)); + I = -btMin(m_repulsionStiffness * timeStep * d, mass * (OVERLAP_REDUCTION_FACTOR * d / timeStep - vn)); if (vn < 0) I += 0.5 * mass * vn; bool face_constrained = false, node_constrained = node->m_constrained;