Delete world body contacts if world gets detached.

This commit is contained in:
Irlan 2019-06-23 15:29:47 -03:00
parent fe6c2a3b0e
commit 1876592d22
2 changed files with 17 additions and 5 deletions

View File

@ -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;

View File

@ -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();