CRealElement: Fixes from decomp

This commit is contained in:
Luke Street 2022-10-29 11:04:53 -04:00
parent c36f478a21
commit 67369f075c
2 changed files with 16 additions and 14 deletions

View File

@ -71,10 +71,11 @@ bool CREConstant::GetValue([[maybe_unused]] int frame, float& valOut) const {
bool CRETimeChain::GetValue(int frame, float& valOut) const {
int v;
xc_swFrame->GetValue(frame, v);
if (frame >= v)
return x8_b->GetValue(frame, valOut);
else
if (frame < v) {
return x4_a->GetValue(frame, valOut);
} else {
return x8_b->GetValue(frame - v, valOut);
}
}
bool CREAdd::GetValue(int frame, float& valOut) const {
@ -109,11 +110,11 @@ bool CREInitialRandom::GetValue(int frame, float& valOut) const {
}
bool CRERandom::GetValue(int frame, float& valOut) const {
float a, b;
x4_min->GetValue(frame, a);
x8_max->GetValue(frame, b);
float rand = CRandom16::GetRandomNumber()->Float();
valOut = b * rand + a * (1.0f - rand);
float min;
float max;
x4_min->GetValue(frame, min);
x8_max->GetValue(frame, max);
valOut = (max - min) * CRandom16::GetRandomNumber()->Float() + min;
return false;
}
@ -177,10 +178,11 @@ bool CRESineWave::GetValue(int frame, float& valOut) const {
}
bool CREInitialSwitch::GetValue(int frame, float& valOut) const {
if (frame == 0)
x4_a->GetValue(frame, valOut);
else
x8_b->GetValue(frame, valOut);
if (frame == 0) {
x4_a->GetValue(0, valOut);
} else {
x8_b->GetValue(frame - 1, valOut);
}
return false;
}
@ -199,7 +201,7 @@ bool CRECompareEquals::GetValue(int frame, float& valOut) const {
float a, b;
x4_a->GetValue(frame, a);
x8_b->GetValue(frame, b);
if (std::fabs(a - b) < 0.00001f)
if (zeus::close_enough(a, b))
xc_c->GetValue(frame, valOut);
else
x10_d->GetValue(frame, valOut);

View File

@ -152,7 +152,7 @@ class CRESineWave : public CRealElement {
public:
CRESineWave(std::unique_ptr<CRealElement>&& a, std::unique_ptr<CRealElement>&& b, std::unique_ptr<CRealElement>&& c)
: x4_frequency(std::move(a)), x8_amplitude(std::move(b)), xc_phase(std::move(c)) {}
: x4_frequency(std::move(b)), x8_amplitude(std::move(c)), xc_phase(std::move(a)) {}
bool GetValue(int frame, float& valOut) const override;
};