Closer CVEKeyframeEmitter

This commit is contained in:
2025-11-25 12:30:32 -08:00
parent 845c55c80c
commit caaa30f41a
2 changed files with 16 additions and 16 deletions

View File

@@ -251,7 +251,7 @@ bool CREKeyframeEmitter::GetValue(int frame, float& valOut) const {
if (xc_loop) { if (xc_loop) {
if (emitterTime >= x10_loopEnd) { if (emitterTime >= x10_loopEnd) {
emitterTime -= x14_loopStart; emitterTime -= x14_loopStart;
emitterTime = emitterTime % (x10_loopEnd - x14_loopStart); emitterTime %= x10_loopEnd - x14_loopStart;
emitterTime += x14_loopStart; emitterTime += x14_loopStart;
} }
valOut = x18_keys[emitterTime]; valOut = x18_keys[emitterTime];

View File

@@ -286,27 +286,27 @@ CVEKeyframeEmitter::~CVEKeyframeEmitter() {}
bool CVEKeyframeEmitter::GetValue(int frame, CVector3f& valOut) const { bool CVEKeyframeEmitter::GetValue(int frame, CVector3f& valOut) const {
if (!mPercent) { if (!mPercent) {
int emitterTime = CParticleGlobals::GetEmitterTime(); int emitterTime = CParticleGlobals::GetEmitterTime();
int calcKey = emitterTime;
if (mLoop) { if (mLoop) {
if (emitterTime >= mLoopEnd) { if (emitterTime >= mLoopEnd) {
calcKey = ((emitterTime - mLoopStart) % (mLoopEnd - mLoopStart)) + mLoopStart; emitterTime -= mLoopStart;
emitterTime %= mLoopEnd - mLoopStart;
emitterTime += mLoopStart;
} }
valOut = mKeys[calcKey]; valOut = mKeys[emitterTime];
} else { } else {
if ((mLoopEnd - 1) < emitterTime) { emitterTime = rstl::min_val(emitterTime, mLoopEnd - 1);
calcKey = (mLoopEnd - 1); valOut = mKeys[emitterTime];
} }
valOut = mKeys[calcKey]; return false;
} }
} else {
if (CParticleGlobals::GetParticleLifetimePercentage() == 100) { if (CParticleGlobals::GetParticleLifetimePercentage() == 100) {
valOut = mKeys[100]; valOut = mKeys[CParticleGlobals::GetParticleLifetimePercentage()];
} else { } else {
CVector3f tmp1 = mKeys[CParticleGlobals::GetParticleLifetimePercentage()]; valOut = (1.f - CParticleGlobals::GetParticleLifetimePercentageRemainder()) *
CVector3f tmp2 = mKeys[CParticleGlobals::GetParticleLifetimePercentage() + 1]; mKeys[CParticleGlobals::GetParticleLifetimePercentage()] +
valOut = (1.f - CParticleGlobals::GetParticleLifetimePercentageRemainder()) * tmp1 + CParticleGlobals::GetParticleLifetimePercentageRemainder() *
CParticleGlobals::GetParticleLifetimePercentageRemainder() * tmp2; mKeys[CParticleGlobals::GetParticleLifetimePercentage() + 1];
}
} }
return false; return false;