Fix CREKeyframeEmitter::GetValue

Former-commit-id: 9ad66e9f2d
This commit is contained in:
Phillip Stephens 2022-10-17 22:40:25 -07:00
parent 8af6095198
commit 2b0a843ec8
1 changed files with 7 additions and 11 deletions

View File

@ -223,9 +223,7 @@ CRELifetimeTween::~CRELifetimeTween() {
} }
// fake but using it to test // fake but using it to test
static inline float Lerp(float a, float b, float c) { static inline float Lerp(float a, float b, float c) { return b * c + a * (1.f - c); }
return b * c + a * (1.f - c);
}
bool CRELifetimeTween::GetValue(int frame, float& valOut) const { bool CRELifetimeTween::GetValue(int frame, float& valOut) const {
float ltFac = frame / CParticleGlobals::GetParticleLifetimeReal(); float ltFac = frame / CParticleGlobals::GetParticleLifetimeReal();
@ -264,15 +262,13 @@ bool CREKeyframeEmitter::GetValue(int frame, float& valOut) const {
return false; return false;
} }
int ltPerc = CParticleGlobals::GetParticleLifetimePercentage(); if (CParticleGlobals::GetParticleLifetimePercentage() == 100) {
if (ltPerc == 100) { valOut = x18_keys[CParticleGlobals::GetParticleLifetimePercentage()];
valOut = x18_keys[ltPerc];
} else { } else {
float ltPercRem = CParticleGlobals::GetParticleLifetimePercentageRemainder(); valOut = (1.f - CParticleGlobals::GetParticleLifetimePercentageRemainder()) *
float key1 = x18_keys[ltPerc]; x18_keys[CParticleGlobals::GetParticleLifetimePercentage()] +
float key2 = x18_keys[ltPerc + 1]; CParticleGlobals::GetParticleLifetimePercentageRemainder() *
valOut = (1.f - ltPercRem) * key1 + ltPercRem * key2; x18_keys[CParticleGlobals::GetParticleLifetimePercentage() + 1];
// valOut = Lerp(key1, key2, ltPercRem);
} }
return false; return false;
} }