From df33dd5cab88cf900087f008ae06d7806cec89fb Mon Sep 17 00:00:00 2001 From: Irlan Date: Thu, 18 Apr 2019 11:02:04 -0300 Subject: [PATCH] Setter and getter for spring mode cloth dragging --- examples/testbed/framework/cloth_dragger.cpp | 15 +++++++++++++++ examples/testbed/framework/cloth_dragger.h | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/examples/testbed/framework/cloth_dragger.cpp b/examples/testbed/framework/cloth_dragger.cpp index 47ee7fc..e05d447 100644 --- a/examples/testbed/framework/cloth_dragger.cpp +++ b/examples/testbed/framework/cloth_dragger.cpp @@ -145,6 +145,21 @@ void b3ClothDragger::Drag() } } +void b3ClothDragger::SetSpring(bool bit) +{ + if (bit == m_spring) + { + return; + } + + if (IsDragging()) + { + StopDragging(); + } + + m_spring = bit; +} + void b3ClothDragger::StopDragging() { B3_ASSERT(IsDragging() == true); diff --git a/examples/testbed/framework/cloth_dragger.h b/examples/testbed/framework/cloth_dragger.h index d0e49de..6bbb797 100644 --- a/examples/testbed/framework/cloth_dragger.h +++ b/examples/testbed/framework/cloth_dragger.h @@ -32,6 +32,10 @@ public: b3ClothDragger(b3Ray3* ray, b3Cloth* cloth); ~b3ClothDragger(); + void SetSpring(bool bit); + + bool GetSpring() const; + bool IsDragging() const; bool StartDragging(); @@ -62,6 +66,11 @@ private: b3ParticleType m_t1, m_t2, m_t3; }; +inline bool b3ClothDragger::GetSpring() const +{ + return m_spring; +} + inline bool b3ClothDragger::IsDragging() const { return m_triangle != nullptr;