all: Replace custom impl with sead::Mathf::floor (#776)

This commit is contained in:
Narr the Reg 2025-10-28 04:56:06 -06:00 committed by GitHub
parent 79ab80f6bb
commit 000c3aadd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 10 deletions

View file

@ -503,9 +503,8 @@ f32 calcFourthOrderRate(f32 t, f32 scale) {
f32 calcTriangleWave01(f32 t, f32 period) {
f32 val = t / (2 * period);
s32 rounded = (s32)val + (((s32)val == val) ? 0 : -!(val >= 0.0f));
val = sead::Mathf::abs(val - rounded - 0.5f);
val = sead::Mathf::abs(val - sead::Mathf::floor(val) - 0.5f);
return 1.0f - (2 * val);
}

View file

@ -45,15 +45,10 @@ void BigBirdStateWait::appear() {
al::setNerve(this, getWaitInitNerve());
}
// TODO: might be a `sead` function?
static s32 floorToInt(f32 x) {
s32 r = static_cast<s32>(x);
return r == x ? r : r + (x >= 0 ? 0 : -1);
}
static void setRandomFrame(al::LiveActor* actor) {
al::setActionFrame(actor, floorToInt(al::getActionFrameMax(actor, al::getActionName(actor)) *
al::getRandom(0.25f, 0.75f)));
al::setActionFrame(actor,
sead::Mathf::floor(al::getActionFrameMax(actor, al::getActionName(actor)) *
al::getRandom(0.25f, 0.75f)));
}
static f32 getTurnFrameRate(f32 angle) {