diff --git a/include/bounce/cloth/cloth.h b/include/bounce/cloth/cloth.h index 288c724..4e7136c 100644 --- a/include/bounce/cloth/cloth.h +++ b/include/bounce/cloth/cloth.h @@ -204,11 +204,6 @@ inline b3Vec3 b3Cloth::GetGravity() const return m_gravity; } -inline void b3Cloth::SetWorld(b3World* world) -{ - m_world = world; -} - inline const b3World* b3Cloth::GetWorld() const { return m_world; diff --git a/src/bounce/cloth/cloth.cpp b/src/bounce/cloth/cloth.cpp index 0152bac..cdec9be 100644 --- a/src/bounce/cloth/cloth.cpp +++ b/src/bounce/cloth/cloth.cpp @@ -293,6 +293,23 @@ b3Cloth::~b3Cloth() } } +void b3Cloth::SetWorld(b3World* world) +{ + if (!world && m_world) + { + // Destroy body contacts + b3ParticleBodyContact* c = m_contactManager.m_particleBodyContactList.m_head; + while (c) + { + b3ParticleBodyContact* boom = c; + c = c->m_next; + m_contactManager.Destroy(boom); + } + } + + m_world = world; +} + b3Particle* b3Cloth::CreateParticle(const b3ParticleDef& def) { void* mem = m_particleBlocks.Allocate();