diff --git a/examples/testbed/tests/cloth_test.h b/examples/testbed/tests/cloth_test.h index 885ed47..d514418 100644 --- a/examples/testbed/tests/cloth_test.h +++ b/examples/testbed/tests/cloth_test.h @@ -168,7 +168,7 @@ public: if (m_spring) { - m_particle->ApplyTranslation(dx); + m_particle->SetPosition(B); } else { diff --git a/include/bounce/dynamics/cloth/particle.h b/include/bounce/dynamics/cloth/particle.h index fce588e..f8a3f40 100644 --- a/include/bounce/dynamics/cloth/particle.h +++ b/include/bounce/dynamics/cloth/particle.h @@ -81,6 +81,11 @@ public: // Get the vertex index. u32 GetVertex() const; + // Set the particle position. + // If the particle is dynamic changing the position directly might lead + // to physically incorrect simulation behaviour. + void SetPosition(const b3Vec3& position); + // Get the particle position. const b3Vec3& GetPosition() const; @@ -175,6 +180,12 @@ inline u32 b3Particle::GetVertex() const return m_vertex; } +inline void b3Particle::SetPosition(const b3Vec3& position) +{ + m_position = position; + m_translation.SetZero(); +} + inline const b3Vec3& b3Particle::GetPosition() const { return m_position;