Remove particle forces if it gets destroyed
This commit is contained in:
parent
5ee66d645e
commit
07ee080310
@ -46,6 +46,9 @@ public:
|
|||||||
|
|
||||||
//
|
//
|
||||||
b3Force* GetNext();
|
b3Force* GetNext();
|
||||||
|
|
||||||
|
//
|
||||||
|
virtual bool HasParticle(const b3Particle* particle) const = 0;
|
||||||
protected:
|
protected:
|
||||||
friend class b3List2<b3Force>;
|
friend class b3List2<b3Force>;
|
||||||
friend class b3Cloth;
|
friend class b3Cloth;
|
||||||
|
@ -67,6 +67,8 @@ public:
|
|||||||
float32 GetDampingStiffness() const;
|
float32 GetDampingStiffness() const;
|
||||||
|
|
||||||
b3Vec3 GetActionForce() const;
|
b3Vec3 GetActionForce() const;
|
||||||
|
|
||||||
|
bool HasParticle(const b3Particle* particle) const;
|
||||||
private:
|
private:
|
||||||
friend class b3Force;
|
friend class b3Force;
|
||||||
friend class b3Cloth;
|
friend class b3Cloth;
|
||||||
@ -127,4 +129,9 @@ inline b3Vec3 b3SpringForce::GetActionForce() const
|
|||||||
return m_f;
|
return m_f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool b3SpringForce::HasParticle(const b3Particle* particle) const
|
||||||
|
{
|
||||||
|
return m_p1 == particle || m_p2 == particle;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -257,8 +257,7 @@ b3Cloth::~b3Cloth()
|
|||||||
{
|
{
|
||||||
b3Force* f0 = f;
|
b3Force* f0 = f;
|
||||||
f = f->m_next;
|
f = f->m_next;
|
||||||
f0->~b3Force();
|
b3Force::Destroy(f0);
|
||||||
b3Free(f0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,6 +280,19 @@ void b3Cloth::DestroyParticle(b3Particle* particle)
|
|||||||
{
|
{
|
||||||
B3_ASSERT(particle->m_vertex == ~0);
|
B3_ASSERT(particle->m_vertex == ~0);
|
||||||
|
|
||||||
|
b3Force* f = m_forceList.m_head;
|
||||||
|
while (f)
|
||||||
|
{
|
||||||
|
b3Force* f0 = f;
|
||||||
|
f = f->m_next;
|
||||||
|
|
||||||
|
if (f0->HasParticle(particle))
|
||||||
|
{
|
||||||
|
m_forceList.Remove(f0);
|
||||||
|
b3Force::Destroy(f0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_particleTree.RemoveNode(particle->m_treeId);
|
m_particleTree.RemoveNode(particle->m_treeId);
|
||||||
|
|
||||||
m_particleList.Remove(particle);
|
m_particleList.Remove(particle);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user