1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 22:53:50 +00:00

Ensure non-negative particle life time, add size assertion

This commit is contained in:
scrawl 2014-07-18 15:58:25 +02:00
parent 192d5ca08f
commit 1320ac6983
2 changed files with 6 additions and 2 deletions

View file

@ -762,8 +762,8 @@ class NIFObjectLoader
else else
emitter->setEmissionRate(partctrl->numParticles / (partctrl->lifetime + partctrl->lifetimeRandom/2)); emitter->setEmissionRate(partctrl->numParticles / (partctrl->lifetime + partctrl->lifetimeRandom/2));
emitter->setTimeToLive(partctrl->lifetime, emitter->setTimeToLive(std::max(0.f, partctrl->lifetime),
partctrl->lifetime + partctrl->lifetimeRandom); std::max(0.f, partctrl->lifetime + partctrl->lifetimeRandom));
emitter->setParameter("width", Ogre::StringConverter::toString(partctrl->offsetRandom.x)); emitter->setParameter("width", Ogre::StringConverter::toString(partctrl->offsetRandom.x));
emitter->setParameter("height", Ogre::StringConverter::toString(partctrl->offsetRandom.y)); emitter->setParameter("height", Ogre::StringConverter::toString(partctrl->offsetRandom.y));
emitter->setParameter("depth", Ogre::StringConverter::toString(partctrl->offsetRandom.z)); emitter->setParameter("depth", Ogre::StringConverter::toString(partctrl->offsetRandom.z));

View file

@ -448,12 +448,14 @@ public:
if(life_time-particle_time < mGrowTime) if(life_time-particle_time < mGrowTime)
{ {
Ogre::Real scale = (life_time-particle_time) / mGrowTime; Ogre::Real scale = (life_time-particle_time) / mGrowTime;
assert (scale >= 0);
width *= scale; width *= scale;
height *= scale; height *= scale;
} }
if(particle_time < mFadeTime) if(particle_time < mFadeTime)
{ {
Ogre::Real scale = particle_time / mFadeTime; Ogre::Real scale = particle_time / mFadeTime;
assert (scale >= 0);
width *= scale; width *= scale;
height *= scale; height *= scale;
} }
@ -479,12 +481,14 @@ public:
if(life_time-particle_time < mGrowTime) if(life_time-particle_time < mGrowTime)
{ {
Ogre::Real scale = (life_time-particle_time) / mGrowTime; Ogre::Real scale = (life_time-particle_time) / mGrowTime;
assert (scale >= 0);
width *= scale; width *= scale;
height *= scale; height *= scale;
} }
if(particle_time < mFadeTime) if(particle_time < mFadeTime)
{ {
Ogre::Real scale = particle_time / mFadeTime; Ogre::Real scale = particle_time / mFadeTime;
assert (scale >= 0);
width *= scale; width *= scale;
height *= scale; height *= scale;
} }