Fix handling of particle 'father' objects when they are destroyed
parent
904b7e580b
commit
648dfd75c4
|
@ -3740,4 +3740,24 @@ Color CParticle::GetFogColor(Math::Vector pos)
|
|||
return result;
|
||||
}
|
||||
|
||||
void CParticle::CutObjectLink(CObject* obj)
|
||||
{
|
||||
for (int i = 0; i < MAXPARTICULE*MAXPARTITYPE; i++)
|
||||
{
|
||||
if (!m_particle[i].used) continue;
|
||||
|
||||
if (m_particle[i].objLink == obj)
|
||||
{
|
||||
// If the object this particle's coordinates are linked to doesn't exist anymore, remove the particle
|
||||
DeleteRank(i);
|
||||
}
|
||||
|
||||
if (m_particle[i].objFather == obj)
|
||||
{
|
||||
// If the object that spawned this partcle doesn't exist anymore, remove the link
|
||||
m_particle[i].objFather = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Gfx
|
||||
|
|
|
@ -291,6 +291,9 @@ public:
|
|||
//! Draws all the particles
|
||||
void DrawParticle(int sheet);
|
||||
|
||||
//! Indicates that the object binds to the particle no longer exists, without deleting it
|
||||
void CutObjectLink(CObject* obj);
|
||||
|
||||
protected:
|
||||
//! Removes a particle of given rank
|
||||
void DeleteRank(int rank);
|
||||
|
|
|
@ -203,6 +203,7 @@ void COldObject::DeleteObject(bool bAll)
|
|||
if ( !bAll )
|
||||
{
|
||||
m_engine->GetPyroManager()->CutObjectLink(this);
|
||||
m_particle->CutObjectLink(this);
|
||||
|
||||
if ( m_bSelect )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue