diff --git a/src/Kyoto/Particles/CRealElement.cpp b/src/Kyoto/Particles/CRealElement.cpp index 757627cb..3f78a755 100644 --- a/src/Kyoto/Particles/CRealElement.cpp +++ b/src/Kyoto/Particles/CRealElement.cpp @@ -251,7 +251,7 @@ bool CREKeyframeEmitter::GetValue(int frame, float& valOut) const { if (xc_loop) { if (emitterTime >= x10_loopEnd) { emitterTime -= x14_loopStart; - emitterTime = emitterTime % (x10_loopEnd - x14_loopStart); + emitterTime %= x10_loopEnd - x14_loopStart; emitterTime += x14_loopStart; } valOut = x18_keys[emitterTime]; diff --git a/src/Kyoto/Particles/CVectorElement.cpp b/src/Kyoto/Particles/CVectorElement.cpp index 742c44fc..1ae49e0c 100644 --- a/src/Kyoto/Particles/CVectorElement.cpp +++ b/src/Kyoto/Particles/CVectorElement.cpp @@ -286,27 +286,27 @@ CVEKeyframeEmitter::~CVEKeyframeEmitter() {} bool CVEKeyframeEmitter::GetValue(int frame, CVector3f& valOut) const { if (!mPercent) { int emitterTime = CParticleGlobals::GetEmitterTime(); - int calcKey = emitterTime; if (mLoop) { if (emitterTime >= mLoopEnd) { - calcKey = ((emitterTime - mLoopStart) % (mLoopEnd - mLoopStart)) + mLoopStart; + emitterTime -= mLoopStart; + emitterTime %= mLoopEnd - mLoopStart; + emitterTime += mLoopStart; } - valOut = mKeys[calcKey]; + valOut = mKeys[emitterTime]; } else { - if ((mLoopEnd - 1) < emitterTime) { - calcKey = (mLoopEnd - 1); - } - valOut = mKeys[calcKey]; + emitterTime = rstl::min_val(emitterTime, mLoopEnd - 1); + valOut = mKeys[emitterTime]; } + return false; + } + + if (CParticleGlobals::GetParticleLifetimePercentage() == 100) { + valOut = mKeys[CParticleGlobals::GetParticleLifetimePercentage()]; } else { - if (CParticleGlobals::GetParticleLifetimePercentage() == 100) { - valOut = mKeys[100]; - } else { - CVector3f tmp1 = mKeys[CParticleGlobals::GetParticleLifetimePercentage()]; - CVector3f tmp2 = mKeys[CParticleGlobals::GetParticleLifetimePercentage() + 1]; - valOut = (1.f - CParticleGlobals::GetParticleLifetimePercentageRemainder()) * tmp1 + - CParticleGlobals::GetParticleLifetimePercentageRemainder() * tmp2; - } + valOut = (1.f - CParticleGlobals::GetParticleLifetimePercentageRemainder()) * + mKeys[CParticleGlobals::GetParticleLifetimePercentage()] + + CParticleGlobals::GetParticleLifetimePercentageRemainder() * + mKeys[CParticleGlobals::GetParticleLifetimePercentage() + 1]; } return false;