mirror of https://github.com/zeldaret/botw.git
Merge pull request #67 from ThePixelGamer/mafs
Update misc files to match sead math changes
This commit is contained in:
commit
a679afcf3f
2
lib/sead
2
lib/sead
|
@ -1 +1 @@
|
||||||
Subproject commit 9fef13c1348038b38351b7f1c47a7490fd4dc8ab
|
Subproject commit 42aea99fb278f1017e4b07a29fe22e6f31448d15
|
|
@ -533,8 +533,8 @@ bool isAirOctaWoodPlatformDlc(const sead::SafeString& name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void getRevivalGridPosition(const sead::Vector3f& pos, int* col1, int* row1, int* col2, int* row2) {
|
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 col = sead::Mathi::clamp((int(pos.x) + 5000) / 1000, 0, 9);
|
||||||
const int row = sead::clamp((int(pos.z) + 4000) / 1000, 0, 7);
|
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 x = (float(col) + 0.5f) * 1000.0f - 5000.0f;
|
||||||
const auto z = (float(row) + 0.5f) * 1000.0f - 4000.0f;
|
const auto z = (float(row) + 0.5f) * 1000.0f - 4000.0f;
|
||||||
|
|
|
@ -587,7 +587,7 @@ bool InfoData::getYLimitAlgorithm(const char** algorithm, const char* actor) con
|
||||||
f32 InfoData::getAabbNorm(const char* actor, bool x) const {
|
f32 InfoData::getAabbNorm(const char* actor, bool x) const {
|
||||||
sead::Vector3f min, max;
|
sead::Vector3f min, max;
|
||||||
if (getAAbbMinMax(actor, &min, &max, x))
|
if (getAAbbMinMax(actor, &min, &max, x))
|
||||||
return sead::norm2(max - min);
|
return (max - min).length();
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,14 @@ void Ecosystem::calc() {}
|
||||||
// FP instructions rearranged.
|
// FP instructions rearranged.
|
||||||
#ifdef NON_MATCHING
|
#ifdef NON_MATCHING
|
||||||
s32 Ecosystem::getMapArea(const EcoMapInfo& info, f32 posX, f32 posZ) const {
|
s32 Ecosystem::getMapArea(const EcoMapInfo& info, f32 posX, f32 posZ) const {
|
||||||
posX = sead::clamp(posX, -5000.0F, 4999.0F);
|
posX = sead::Mathf::clamp(posX, -5000.0F, 4999.0F);
|
||||||
posZ = sead::clamp(posZ, -4000.0F, 4000.0F);
|
posZ = sead::Mathf::clamp(posZ, -4000.0F, 4000.0F);
|
||||||
f32 epsilon1 = (posX + 5000.0F >= 0.0F) ? 0.5F : -0.5F;
|
f32 epsilon1 = (posX + 5000.0F >= 0.0F) ? 0.5F : -0.5F;
|
||||||
f32 epsilon2 = (posZ + 4000.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 x = posX + 5000.0F + epsilon1;
|
||||||
s32 z = (posZ + 4000.0F + epsilon2) / info.mHeader->divisor;
|
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)
|
if (info.mHeader->divisor == 10)
|
||||||
x = x / 10;
|
x = x / 10;
|
||||||
|
|
|
@ -1822,8 +1822,8 @@ bool TriggerParam::shouldSkipRevivingShopItem(bool* is_shop_item, u32 flag_hash,
|
||||||
if (!act::ActorSystem::instance()->getAutoPlacementActorPos(dealer, &pos))
|
if (!act::ActorSystem::instance()->getAutoPlacementActorPos(dealer, &pos))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
col = sead::clamp((int(pos.x) + 5000) / 1000, 0, 9);
|
col = sead::Mathi::clamp((int(pos.x) + 5000) / 1000, 0, 9);
|
||||||
row = sead::clamp((int(pos.z) + 4000) / 1000, 0, 7);
|
row = sead::Mathi::clamp((int(pos.z) + 4000) / 1000, 0, 7);
|
||||||
} else {
|
} else {
|
||||||
num = areas.getSize();
|
num = areas.getSize();
|
||||||
if (areas.tryGetIterByIndex(&iter, 0)) {
|
if (areas.tryGetIterByIndex(&iter, 0)) {
|
||||||
|
|
|
@ -238,17 +238,17 @@ void SupportBoneResource::BaseBone::postRead_() {
|
||||||
sead::Vector3f up_local = up.ref();
|
sead::Vector3f up_local = up.ref();
|
||||||
aim_local.normalize();
|
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?
|
// XXX: this looks like a hack. Why does this not match without an inline function?
|
||||||
[&] { side.normalize(); }();
|
[&] { side.normalize(); }();
|
||||||
|
|
||||||
up_local = sead::cross(side, aim_local);
|
up_local.setCross(side, aim_local);
|
||||||
up_local.normalize();
|
up_local.normalize();
|
||||||
up = up_local;
|
up = up_local;
|
||||||
aim = aim_local;
|
aim = aim_local;
|
||||||
|
|
||||||
base_rotate->normalize();
|
base_rotate->normalize();
|
||||||
base_rotate->invert(&reverse_rotate);
|
base_rotate->inverse(&reverse_rotate);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ksys::phys
|
} // namespace ksys::phys
|
||||||
|
|
|
@ -45,8 +45,8 @@ u8* OffsetReadFileDevice::doLoad_(sead::FileDevice::LoadArg& arg) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bytesToRead = mOffsetReadOffset + sead::Mathi::roundUpPow2Positive(
|
bytesToRead = mOffsetReadOffset +
|
||||||
fileSize, FileDevice::cBufferMinAlignment);
|
sead::Mathi::roundUpPow2(fileSize, FileDevice::cBufferMinAlignment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ u8* OffsetReadFileDevice::doLoad_(sead::FileDevice::LoadArg& arg) {
|
||||||
|
|
||||||
if (buf == nullptr) {
|
if (buf == nullptr) {
|
||||||
const s32 sign = (arg.alignment < 0) ? -1 : 1;
|
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);
|
alignment = sign * ((alignment < cBufferMinAlignment) ? cBufferMinAlignment : alignment);
|
||||||
|
|
||||||
sead::Heap* heap = arg.heap;
|
sead::Heap* heap = arg.heap;
|
||||||
|
|
|
@ -95,7 +95,7 @@ public:
|
||||||
const auto f = getLerpFactor(t);
|
const auto f = getLerpFactor(t);
|
||||||
const auto max_d = instance()->getDeltaTime() * max_delta;
|
const auto max_d = instance()->getDeltaTime() * max_delta;
|
||||||
const auto diff = b - *value;
|
const auto diff = b - *value;
|
||||||
const auto d = f * sead::absf(diff);
|
const auto d = f * sead::Mathf::abs(diff);
|
||||||
if (d > max_d)
|
if (d > max_d)
|
||||||
*value += diff < 0.0 ? -max_d : max_d;
|
*value += diff < 0.0 ? -max_d : max_d;
|
||||||
else
|
else
|
||||||
|
@ -109,9 +109,9 @@ public:
|
||||||
const auto min_d = instance()->getDeltaTime() * min_delta;
|
const auto min_d = instance()->getDeltaTime() * min_delta;
|
||||||
|
|
||||||
const auto diff = b - *value;
|
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;
|
*value = b;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ void VFRVec3f::lerp(const sead::Vector3f& b, f32 t) {
|
||||||
bool VFRVec3f::chase(const sead::Vector3f& target, f32 t) {
|
bool VFRVec3f::chase(const sead::Vector3f& target, f32 t) {
|
||||||
const auto delta = VFR::instance()->getDeltaTime() * t;
|
const auto delta = VFR::instance()->getDeltaTime() * t;
|
||||||
const auto diff = target - value;
|
const auto diff = target - value;
|
||||||
const auto norm = sead::norm2(diff);
|
const auto norm = diff.length();
|
||||||
|
|
||||||
if (norm <= delta) {
|
if (norm <= delta) {
|
||||||
sead::MemUtil::copy(&value, &target, sizeof(value));
|
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) {
|
void VFRValue::clamp(const f32& min, const f32& max) {
|
||||||
const auto a = min;
|
const auto a = min;
|
||||||
const auto b = max;
|
const auto b = max;
|
||||||
value = sead::clamp(value, a, b);
|
value = sead::Mathf::clamp(value, a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFRVec3f::normalize(f32 new_norm) {
|
void VFRVec3f::normalize(f32 new_norm) {
|
||||||
if (sead::norm2(value) > new_norm) {
|
if (value.length() > new_norm) {
|
||||||
const auto norm = sead::norm2(value);
|
const auto norm = value.length();
|
||||||
if (norm > 0.0)
|
if (norm > 0.0)
|
||||||
value *= new_norm / norm;
|
value *= new_norm / norm;
|
||||||
}
|
}
|
||||||
|
|
|
@ -796,11 +796,11 @@ bool Manager::isGerudoDesertClimate() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Manager::hasCameraOrPlayerMoved(float distance_threshold) const {
|
bool Manager::hasCameraOrPlayerMoved(float distance_threshold) const {
|
||||||
const auto camera_dist = sead::norm2(mCameraPos - mPrevCameraPos);
|
const auto camera_dist = (mCameraPos - mPrevCameraPos).length();
|
||||||
const auto player_dist = sead::norm2(mPlayerPos - mPrevPlayerPos);
|
const auto player_dist = (mPlayerPos - mPrevPlayerPos).length();
|
||||||
const bool moved = player_dist >= distance_threshold || camera_dist >= distance_threshold;
|
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()) {
|
evt::Manager::instance()->hasActiveEvent()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -830,7 +830,7 @@ float Manager::getDungeonLightLongitude() const {
|
||||||
|
|
||||||
void Manager::setCameraDistForRemainsElectric(sead::Vector3f pos) {
|
void Manager::setCameraDistForRemainsElectric(sead::Vector3f pos) {
|
||||||
_7ac = 10;
|
_7ac = 10;
|
||||||
_770 = sead::norm2(mCameraPos - pos);
|
_770 = (mCameraPos - pos).length();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::setFocusDist(float dist) {
|
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};
|
const sead::Vector3f unk_center{-2004, mPlayerPos.y, 1710};
|
||||||
mIgnitedLevel = level;
|
mIgnitedLevel = level;
|
||||||
|
|
||||||
if (sead::norm2(mPlayerPos - unk_center) < 20.0) {
|
if ((mPlayerPos - unk_center).length() < 20.0) {
|
||||||
mIgnitedCenter = unk_center;
|
mIgnitedCenter = unk_center;
|
||||||
mIgnitedRadius = 7.0;
|
mIgnitedRadius = 7.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,6 @@
|
||||||
|
|
||||||
namespace ksys::world {
|
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() {
|
SkyMgr::SkyMgr() {
|
||||||
_20._18 = {0, 0, 0};
|
_20._18 = {0, 0, 0};
|
||||||
_20._24 = {0, 0, 0};
|
_20._24 = {0, 0, 0};
|
||||||
|
@ -321,7 +315,7 @@ SkyMgr::SkyMgr() {
|
||||||
_3f14.x = -0.0;
|
_3f14.x = -0.0;
|
||||||
_3f14.y = -std::sinf(0.82903141);
|
_3f14.y = -std::sinf(0.82903141);
|
||||||
_3f14.z = -std::cosf(0.82903141);
|
_3f14.z = -std::cosf(0.82903141);
|
||||||
normalize(_3f14);
|
_3f14.normalize();
|
||||||
_3f44 = 0.0;
|
_3f44 = 0.0;
|
||||||
_3f48 = 0.0;
|
_3f48 = 0.0;
|
||||||
_3f4c = 0.2;
|
_3f4c = 0.2;
|
||||||
|
|
Loading…
Reference in New Issue