From 1320ac6983912ce0ec7fdaadf2eca5768f684d55 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 18 Jul 2014 15:58:25 +0200 Subject: [PATCH] Ensure non-negative particle life time, add size assertion --- components/nifogre/ogrenifloader.cpp | 4 ++-- components/nifogre/particles.cpp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/nifogre/ogrenifloader.cpp b/components/nifogre/ogrenifloader.cpp index eed320756..81b2e55d2 100644 --- a/components/nifogre/ogrenifloader.cpp +++ b/components/nifogre/ogrenifloader.cpp @@ -762,8 +762,8 @@ class NIFObjectLoader else emitter->setEmissionRate(partctrl->numParticles / (partctrl->lifetime + partctrl->lifetimeRandom/2)); - emitter->setTimeToLive(partctrl->lifetime, - partctrl->lifetime + partctrl->lifetimeRandom); + emitter->setTimeToLive(std::max(0.f, partctrl->lifetime), + std::max(0.f, partctrl->lifetime + partctrl->lifetimeRandom)); emitter->setParameter("width", Ogre::StringConverter::toString(partctrl->offsetRandom.x)); emitter->setParameter("height", Ogre::StringConverter::toString(partctrl->offsetRandom.y)); emitter->setParameter("depth", Ogre::StringConverter::toString(partctrl->offsetRandom.z)); diff --git a/components/nifogre/particles.cpp b/components/nifogre/particles.cpp index a1433a669..47dce774f 100644 --- a/components/nifogre/particles.cpp +++ b/components/nifogre/particles.cpp @@ -448,12 +448,14 @@ public: if(life_time-particle_time < mGrowTime) { Ogre::Real scale = (life_time-particle_time) / mGrowTime; + assert (scale >= 0); width *= scale; height *= scale; } if(particle_time < mFadeTime) { Ogre::Real scale = particle_time / mFadeTime; + assert (scale >= 0); width *= scale; height *= scale; } @@ -479,12 +481,14 @@ public: if(life_time-particle_time < mGrowTime) { Ogre::Real scale = (life_time-particle_time) / mGrowTime; + assert (scale >= 0); width *= scale; height *= scale; } if(particle_time < mFadeTime) { Ogre::Real scale = particle_time / mFadeTime; + assert (scale >= 0); width *= scale; height *= scale; }