From 36738b7676f40c8734df89137fe1a9039cc55c0f Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sat, 22 Feb 2020 10:40:31 -0800 Subject: [PATCH] release memory of m_deformableBodySolver in ClothFriction demo. --- examples/DeformableDemo/ClothFriction.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/DeformableDemo/ClothFriction.cpp b/examples/DeformableDemo/ClothFriction.cpp index 5ea2d8701..e2aa2c0b3 100644 --- a/examples/DeformableDemo/ClothFriction.cpp +++ b/examples/DeformableDemo/ClothFriction.cpp @@ -29,13 +29,16 @@ class ClothFriction : public CommonRigidBodyBase { btAlignedObjectArray m_forces; + btDeformableBodySolver* m_deformableBodySolver; public: ClothFriction(struct GUIHelperInterface* helper) - : CommonRigidBodyBase(helper) + : CommonRigidBodyBase(helper), + m_deformableBodySolver(0) { } virtual ~ClothFriction() { + } void initPhysics(); @@ -94,14 +97,14 @@ void ClothFriction::initPhysics() m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_broadphase = new btDbvtBroadphase(); - btDeformableBodySolver* deformableBodySolver = new btDeformableBodySolver(); + m_deformableBodySolver = new btDeformableBodySolver(); ///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded) btDeformableMultiBodyConstraintSolver* sol = new btDeformableMultiBodyConstraintSolver(); - sol->setDeformableSolver(deformableBodySolver); + sol->setDeformableSolver(m_deformableBodySolver); m_solver = sol; - m_dynamicsWorld = new btDeformableMultiBodyDynamicsWorld(m_dispatcher, m_broadphase, sol, m_collisionConfiguration, deformableBodySolver); + m_dynamicsWorld = new btDeformableMultiBodyDynamicsWorld(m_dispatcher, m_broadphase, sol, m_collisionConfiguration, m_deformableBodySolver); btVector3 gravity = btVector3(0, -10, 0); m_dynamicsWorld->setGravity(gravity); getDeformableDynamicsWorld()->getWorldInfo().m_gravity = gravity; @@ -240,6 +243,8 @@ void ClothFriction::exitPhysics() delete m_solver; + delete m_deformableBodySolver; + delete m_broadphase; delete m_dispatcher;