mirror of
https://github.com/MonsterDruide1/OdysseyDecomp
synced 2026-04-23 09:04:21 +00:00
all: Make use of sead::round (#866)
This commit is contained in:
parent
d53ede9dad
commit
094badb850
|
|
@ -13,18 +13,16 @@ void calcWorldPosFromGridIndex(sead::Vector3f* outPos, const sead::Matrix34f& mt
|
|||
outPos->setMul(mtx, grid);
|
||||
}
|
||||
|
||||
// TODO: might be a sead function?
|
||||
inline s32 round(f32 val) {
|
||||
return val >= 0.0f ? val + 0.5f : val - 0.5f;
|
||||
}
|
||||
|
||||
void calcGridIndexFromWorldPos(sead::Vector3i* outGridIndex, const sead::Matrix34f& mtx,
|
||||
const sead::Vector3f& pos) {
|
||||
sead::Vector3f posOrigin = pos - mtx.getTranslation();
|
||||
|
||||
outGridIndex->x = round(mtx.getBase(0).dot(posOrigin) / mtx.getBase(0).squaredLength());
|
||||
outGridIndex->y = round(mtx.getBase(1).dot(posOrigin) / mtx.getBase(1).squaredLength());
|
||||
outGridIndex->z = round(mtx.getBase(2).dot(posOrigin) / mtx.getBase(2).squaredLength());
|
||||
outGridIndex->x =
|
||||
sead::Mathf::round(mtx.getBase(0).dot(posOrigin) / mtx.getBase(0).squaredLength());
|
||||
outGridIndex->y =
|
||||
sead::Mathf::round(mtx.getBase(1).dot(posOrigin) / mtx.getBase(1).squaredLength());
|
||||
outGridIndex->z =
|
||||
sead::Mathf::round(mtx.getBase(2).dot(posOrigin) / mtx.getBase(2).squaredLength());
|
||||
}
|
||||
|
||||
sead::Vector3i calcGridIndexNext(const sead::Vector3i& gridIndex, s32 dirIndex) {
|
||||
|
|
|
|||
|
|
@ -1029,14 +1029,10 @@ f32 calcFriction(f32 accel, f32 speed) {
|
|||
return (accel + speed) / speed;
|
||||
}
|
||||
|
||||
inline f32 round(f32 v) {
|
||||
return (s32)(v + (v >= 0.0f ? 0.5f : -0.5f));
|
||||
}
|
||||
|
||||
void roundOffVec(sead::Vector3f* outVec, const sead::Vector3f& vec) {
|
||||
outVec->x = round(vec.x);
|
||||
outVec->y = round(vec.y);
|
||||
outVec->z = round(vec.z);
|
||||
outVec->x = sead::Mathf::round(vec.x);
|
||||
outVec->y = sead::Mathf::round(vec.y);
|
||||
outVec->z = sead::Mathf::round(vec.z);
|
||||
}
|
||||
|
||||
void roundOffVec(sead::Vector3f* vec) {
|
||||
|
|
@ -1044,8 +1040,8 @@ void roundOffVec(sead::Vector3f* vec) {
|
|||
}
|
||||
|
||||
void roundOffVec(sead::Vector2f* outVec, const sead::Vector2f& vec) {
|
||||
outVec->x = round(vec.x);
|
||||
outVec->y = round(vec.y);
|
||||
outVec->x = sead::Mathf::round(vec.x);
|
||||
outVec->y = sead::Mathf::round(vec.y);
|
||||
}
|
||||
|
||||
void roundOffVec(sead::Vector2f* vec) {
|
||||
|
|
@ -1053,7 +1049,7 @@ void roundOffVec(sead::Vector2f* vec) {
|
|||
}
|
||||
|
||||
f32 snapToGrid(f32 val, f32 gridSize, f32 offset) {
|
||||
return round((val - offset) / gridSize) * gridSize + offset;
|
||||
return sead::Mathf::round((val - offset) / gridSize) * gridSize + offset;
|
||||
}
|
||||
|
||||
void snapVecToGrid(sead::Vector3f* outVec, const sead::Vector3f& vec, f32 gridSize,
|
||||
|
|
|
|||
|
|
@ -62,16 +62,11 @@ void HackObjMovieCameraTarget::updateHack(bool isInHack) {
|
|||
mNerveKeeper->update();
|
||||
}
|
||||
|
||||
// TODO: might be sead function?
|
||||
s32 roundAwayFromZero(f32 val) {
|
||||
return (s32)(val >= 0 ? val + 0.5f : val - 0.5f);
|
||||
}
|
||||
|
||||
void HackObjMovieCameraTarget::changeTargetToHackObj() {
|
||||
f32 distanceBetweenActors = (al::getTrans(getActor()) - rs::getPlayerPos(getActor())).length();
|
||||
|
||||
f32 timeToTranstion = sead::Mathf::clampMin(distanceBetweenActors - 200.0f, 0.0f) / 30.0f;
|
||||
mTransitionTime = sead::Mathi::clamp(roundAwayFromZero(timeToTranstion) + 15, 15, 30);
|
||||
mTransitionTime = sead::Mathi::clamp(sead::Mathf::round(timeToTranstion) + 15, 15, 30);
|
||||
|
||||
if (al::isNerve(this, &CenterFix))
|
||||
al::setNerve(this, &CenterFixToHackObj);
|
||||
|
|
|
|||
Loading…
Reference in a new issue