diff --git a/lib/sead b/lib/sead index 9fef13c1..42aea99f 160000 --- a/lib/sead +++ b/lib/sead @@ -1 +1 @@ -Subproject commit 9fef13c1348038b38351b7f1c47a7490fd4dc8ab +Subproject commit 42aea99fb278f1017e4b07a29fe22e6f31448d15 diff --git a/src/KingSystem/ActorSystem/actActorUtil.cpp b/src/KingSystem/ActorSystem/actActorUtil.cpp index 443e4046..75de3637 100644 --- a/src/KingSystem/ActorSystem/actActorUtil.cpp +++ b/src/KingSystem/ActorSystem/actActorUtil.cpp @@ -533,8 +533,8 @@ bool isAirOctaWoodPlatformDlc(const sead::SafeString& name) { } void getRevivalGridPosition(const sead::Vector3f& pos, int* col1, int* row1, int* col2, int* row2) { - const int col = sead::clamp((int(pos.x) + 5000) / 1000, 0, 9); - const int row = sead::clamp((int(pos.z) + 4000) / 1000, 0, 7); + const int col = sead::Mathi::clamp((int(pos.x) + 5000) / 1000, 0, 9); + const int row = sead::Mathi::clamp((int(pos.z) + 4000) / 1000, 0, 7); const auto x = (float(col) + 0.5f) * 1000.0f - 5000.0f; const auto z = (float(row) + 0.5f) * 1000.0f - 4000.0f; diff --git a/src/KingSystem/ActorSystem/actInfoData.cpp b/src/KingSystem/ActorSystem/actInfoData.cpp index 94fb092d..6a4b1c21 100644 --- a/src/KingSystem/ActorSystem/actInfoData.cpp +++ b/src/KingSystem/ActorSystem/actInfoData.cpp @@ -587,7 +587,7 @@ bool InfoData::getYLimitAlgorithm(const char** algorithm, const char* actor) con f32 InfoData::getAabbNorm(const char* actor, bool x) const { sead::Vector3f min, max; if (getAAbbMinMax(actor, &min, &max, x)) - return sead::norm2(max - min); + return (max - min).length(); return 0.0; } diff --git a/src/KingSystem/Ecosystem/ecoSystem.cpp b/src/KingSystem/Ecosystem/ecoSystem.cpp index 6f8252bf..83fd3c8c 100644 --- a/src/KingSystem/Ecosystem/ecoSystem.cpp +++ b/src/KingSystem/Ecosystem/ecoSystem.cpp @@ -32,14 +32,14 @@ void Ecosystem::calc() {} // FP instructions rearranged. #ifdef NON_MATCHING s32 Ecosystem::getMapArea(const EcoMapInfo& info, f32 posX, f32 posZ) const { - posX = sead::clamp(posX, -5000.0F, 4999.0F); - posZ = sead::clamp(posZ, -4000.0F, 4000.0F); + posX = sead::Mathf::clamp(posX, -5000.0F, 4999.0F); + posZ = sead::Mathf::clamp(posZ, -4000.0F, 4000.0F); f32 epsilon1 = (posX + 5000.0F >= 0.0F) ? 0.5F : -0.5F; f32 epsilon2 = (posZ + 4000.0F >= 0.0F) ? 0.5F : -0.5F; s32 x = posX + 5000.0F + epsilon1; s32 z = (posZ + 4000.0F + epsilon2) / info.mHeader->divisor; - s32 row = sead::clamp(z, (s32)0, info.mHeader->num_rows - 2); + s32 row = sead::Mathi::clamp(z, 0, info.mHeader->num_rows - 2); if (info.mHeader->divisor == 10) x = x / 10; diff --git a/src/KingSystem/GameData/gdtTriggerParam.cpp b/src/KingSystem/GameData/gdtTriggerParam.cpp index ff8089cc..82ab81dd 100644 --- a/src/KingSystem/GameData/gdtTriggerParam.cpp +++ b/src/KingSystem/GameData/gdtTriggerParam.cpp @@ -1822,8 +1822,8 @@ bool TriggerParam::shouldSkipRevivingShopItem(bool* is_shop_item, u32 flag_hash, if (!act::ActorSystem::instance()->getAutoPlacementActorPos(dealer, &pos)) return false; - col = sead::clamp((int(pos.x) + 5000) / 1000, 0, 9); - row = sead::clamp((int(pos.z) + 4000) / 1000, 0, 7); + col = sead::Mathi::clamp((int(pos.x) + 5000) / 1000, 0, 9); + row = sead::Mathi::clamp((int(pos.z) + 4000) / 1000, 0, 7); } else { num = areas.getSize(); if (areas.tryGetIterByIndex(&iter, 0)) { diff --git a/src/KingSystem/Physics/SupportBone/physSupportBoneResource.cpp b/src/KingSystem/Physics/SupportBone/physSupportBoneResource.cpp index a33031e0..b7b2dbd9 100644 --- a/src/KingSystem/Physics/SupportBone/physSupportBoneResource.cpp +++ b/src/KingSystem/Physics/SupportBone/physSupportBoneResource.cpp @@ -238,17 +238,17 @@ void SupportBoneResource::BaseBone::postRead_() { sead::Vector3f up_local = up.ref(); aim_local.normalize(); - side = sead::cross(aim_local, up_local); + side.setCross(aim_local, up_local); // XXX: this looks like a hack. Why does this not match without an inline function? [&] { side.normalize(); }(); - up_local = sead::cross(side, aim_local); + up_local.setCross(side, aim_local); up_local.normalize(); up = up_local; aim = aim_local; base_rotate->normalize(); - base_rotate->invert(&reverse_rotate); + base_rotate->inverse(&reverse_rotate); } } // namespace ksys::phys diff --git a/src/KingSystem/Resource/resOffsetReadFileDevice.cpp b/src/KingSystem/Resource/resOffsetReadFileDevice.cpp index 5bc3f9ac..ec284908 100644 --- a/src/KingSystem/Resource/resOffsetReadFileDevice.cpp +++ b/src/KingSystem/Resource/resOffsetReadFileDevice.cpp @@ -45,8 +45,8 @@ u8* OffsetReadFileDevice::doLoad_(sead::FileDevice::LoadArg& arg) { return nullptr; } } else { - bytesToRead = mOffsetReadOffset + sead::Mathi::roundUpPow2Positive( - fileSize, FileDevice::cBufferMinAlignment); + bytesToRead = mOffsetReadOffset + + sead::Mathi::roundUpPow2(fileSize, FileDevice::cBufferMinAlignment); } } @@ -55,7 +55,7 @@ u8* OffsetReadFileDevice::doLoad_(sead::FileDevice::LoadArg& arg) { if (buf == nullptr) { const s32 sign = (arg.alignment < 0) ? -1 : 1; - s32 alignment = sead::abs(arg.alignment); + s32 alignment = sead::Mathi::abs(arg.alignment); alignment = sign * ((alignment < cBufferMinAlignment) ? cBufferMinAlignment : alignment); sead::Heap* heap = arg.heap; diff --git a/src/KingSystem/System/VFR.h b/src/KingSystem/System/VFR.h index 10a8bcaa..552d9949 100644 --- a/src/KingSystem/System/VFR.h +++ b/src/KingSystem/System/VFR.h @@ -95,7 +95,7 @@ public: const auto f = getLerpFactor(t); const auto max_d = instance()->getDeltaTime() * max_delta; const auto diff = b - *value; - const auto d = f * sead::absf(diff); + const auto d = f * sead::Mathf::abs(diff); if (d > max_d) *value += diff < 0.0 ? -max_d : max_d; else @@ -109,9 +109,9 @@ public: const auto min_d = instance()->getDeltaTime() * min_delta; const auto diff = b - *value; - const auto d = f * sead::absf(diff); + const auto d = f * sead::Mathf::abs(diff); - if (sead::absf(diff) <= min_d) { + if (sead::Mathf::abs(diff) <= min_d) { *value = b; return true; } diff --git a/src/KingSystem/System/VFRValue.cpp b/src/KingSystem/System/VFRValue.cpp index 68601898..6915fbdd 100644 --- a/src/KingSystem/System/VFRValue.cpp +++ b/src/KingSystem/System/VFRValue.cpp @@ -75,7 +75,7 @@ void VFRVec3f::lerp(const sead::Vector3f& b, f32 t) { bool VFRVec3f::chase(const sead::Vector3f& target, f32 t) { const auto delta = VFR::instance()->getDeltaTime() * t; const auto diff = target - value; - const auto norm = sead::norm2(diff); + const auto norm = diff.length(); if (norm <= delta) { sead::MemUtil::copy(&value, &target, sizeof(value)); @@ -101,12 +101,12 @@ void VFRValue::setToMin(const f32& min) { void VFRValue::clamp(const f32& min, const f32& max) { const auto a = min; const auto b = max; - value = sead::clamp(value, a, b); + value = sead::Mathf::clamp(value, a, b); } void VFRVec3f::normalize(f32 new_norm) { - if (sead::norm2(value) > new_norm) { - const auto norm = sead::norm2(value); + if (value.length() > new_norm) { + const auto norm = value.length(); if (norm > 0.0) value *= new_norm / norm; } diff --git a/src/KingSystem/World/worldManager.cpp b/src/KingSystem/World/worldManager.cpp index 0dc18cef..b95b62e7 100644 --- a/src/KingSystem/World/worldManager.cpp +++ b/src/KingSystem/World/worldManager.cpp @@ -796,11 +796,11 @@ bool Manager::isGerudoDesertClimate() const { } bool Manager::hasCameraOrPlayerMoved(float distance_threshold) const { - const auto camera_dist = sead::norm2(mCameraPos - mPrevCameraPos); - const auto player_dist = sead::norm2(mPlayerPos - mPrevPlayerPos); + const auto camera_dist = (mCameraPos - mPrevCameraPos).length(); + const auto player_dist = (mPlayerPos - mPrevPlayerPos).length(); const bool moved = player_dist >= distance_threshold || camera_dist >= distance_threshold; - if (sead::norm2(mPlayerPos - mPrevPlayerPos) <= 100.0 && + if ((mPlayerPos - mPrevPlayerPos).length() <= 100.0 && evt::Manager::instance()->hasActiveEvent()) { return false; } @@ -830,7 +830,7 @@ float Manager::getDungeonLightLongitude() const { void Manager::setCameraDistForRemainsElectric(sead::Vector3f pos) { _7ac = 10; - _770 = sead::norm2(mCameraPos - pos); + _770 = (mCameraPos - pos).length(); } void Manager::setFocusDist(float dist) { @@ -888,7 +888,7 @@ void Manager::setIgnitedLevel(int level, float radius, sead::Vector3f center) { const sead::Vector3f unk_center{-2004, mPlayerPos.y, 1710}; mIgnitedLevel = level; - if (sead::norm2(mPlayerPos - unk_center) < 20.0) { + if ((mPlayerPos - unk_center).length() < 20.0) { mIgnitedCenter = unk_center; mIgnitedRadius = 7.0; } diff --git a/src/KingSystem/World/worldSkyMgr.cpp b/src/KingSystem/World/worldSkyMgr.cpp index 8a1afbbd..7e6a1d97 100644 --- a/src/KingSystem/World/worldSkyMgr.cpp +++ b/src/KingSystem/World/worldSkyMgr.cpp @@ -5,12 +5,6 @@ namespace ksys::world { -static void normalize(sead::Vector3f& v) { - const auto norm = sead::norm2(v); - if (norm > 0.0) - v *= 1.0f / norm; -} - SkyMgr::SkyMgr() { _20._18 = {0, 0, 0}; _20._24 = {0, 0, 0}; @@ -321,7 +315,7 @@ SkyMgr::SkyMgr() { _3f14.x = -0.0; _3f14.y = -std::sinf(0.82903141); _3f14.z = -std::cosf(0.82903141); - normalize(_3f14); + _3f14.normalize(); _3f44 = 0.0; _3f48 = 0.0; _3f4c = 0.2;