Fixed some particle crashes after 99a831a03b
parent
89b495c667
commit
d80fa387b9
|
@ -641,22 +641,22 @@ void CParticle::GetRankFromChannel(int &channel)
|
|||
int uniqueStamp = (channel>>16)&0xffff;
|
||||
channel &= 0xffff;
|
||||
|
||||
assert(channel >= 0 && channel < MAXPARTICULE*MAXPARTITYPE);
|
||||
|
||||
if (!m_particle[channel].used) assert(!!"Tried to access invalid particle channel (used=false) !\n");
|
||||
if (m_particle[channel].uniqueStamp != uniqueStamp) assert(!!"Tried to access invalid particle channel (uniqueStamp changed) !\n");
|
||||
if (channel < 0 || channel >= MAXPARTICULE*MAXPARTITYPE) throw std::runtime_error("Tried to access invalid particle channel (invalid ID)");
|
||||
if (!m_particle[channel].used) throw std::runtime_error("Tried to access invalid particle channel (used=false)");
|
||||
if (m_particle[channel].uniqueStamp != uniqueStamp) throw std::runtime_error("Tried to access invalid particle channel (uniqueStamp changed)");
|
||||
}
|
||||
|
||||
bool CParticle::ParticleExists(int channel)
|
||||
{
|
||||
int uniqueStamp = (channel>>16)&0xffff;
|
||||
channel &= 0xffff;
|
||||
|
||||
assert(channel >= 0 && channel < MAXPARTICULE*MAXPARTITYPE);
|
||||
|
||||
if (!m_particle[channel].used) return false;
|
||||
if (m_particle[channel].uniqueStamp != uniqueStamp) return false;
|
||||
try
|
||||
{
|
||||
GetRankFromChannel(channel);
|
||||
return true;
|
||||
}
|
||||
catch (const std::runtime_error& e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void CParticle::DeleteRank(int rank)
|
||||
|
|
|
@ -297,7 +297,11 @@ public:
|
|||
protected:
|
||||
//! Removes a particle of given rank
|
||||
void DeleteRank(int rank);
|
||||
//! Adapts the channel so it can be used as an offset in m_particle
|
||||
/**
|
||||
* \brief Adapts the channel so it can be used as an offset in m_particle
|
||||
* \param channel Channel number to process, will be modified to be index of particle in m_particle
|
||||
* \throw std::runtime_error if this particle does not exist any more
|
||||
**/
|
||||
void GetRankFromChannel(int &channel);
|
||||
//! Draws a triangular particle
|
||||
void DrawParticleTriangle(int i);
|
||||
|
|
|
@ -2975,6 +2975,7 @@ void COldObject::UpdateSelectParticle()
|
|||
// Updates lens.
|
||||
for ( i=0 ; i<4 ; i++ )
|
||||
{
|
||||
if (m_partiSel[i] == -1) continue;
|
||||
pos[i] = Math::Transform(m_objectPart[0].matWorld, pos[i]);
|
||||
dim[i].y = dim[i].x;
|
||||
m_particle->SetParam(m_partiSel[i], pos[i], dim[i], zoom[i], angle, 1.0f);
|
||||
|
|
Loading…
Reference in New Issue