summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------lib/NintendoSDK0
m---------lib/sead0
-rw-r--r--src/Game/DLC/aocHardModeManager.cpp6
-rw-r--r--src/KingSystem/Physics/RigidBody/Shape/Box/physBoxShape.cpp13
-rw-r--r--src/KingSystem/Physics/RigidBody/physRigidBody.cpp14
-rw-r--r--src/KingSystem/Physics/RigidBody/physRigidBodyMotionEntity.cpp12
-rw-r--r--src/KingSystem/Physics/System/physContactMgr.cpp17
-rw-r--r--src/KingSystem/System/VFR.cpp4
-rw-r--r--src/KingSystem/World/worldManager.cpp4
-rw-r--r--src/KingSystem/World/worldTimeMgr.cpp2
10 files changed, 33 insertions, 39 deletions
diff --git a/lib/NintendoSDK b/lib/NintendoSDK
-Subproject 362e47b48c27ab51d6e34de11185a0d89bd32a3
+Subproject 8dce6534c41bf304ee9fc44fc99d3023c6fd12b
diff --git a/lib/sead b/lib/sead
-Subproject cc672852c6218bf081325cb955dd3d87723d16c
+Subproject 1decfbfc7f23f11233db326d3796ba96c813fcf
diff --git a/src/Game/DLC/aocHardModeManager.cpp b/src/Game/DLC/aocHardModeManager.cpp
index f149265d..9d8faef9 100644
--- a/src/Game/DLC/aocHardModeManager.cpp
+++ b/src/Game/DLC/aocHardModeManager.cpp
@@ -66,15 +66,15 @@ void HardModeManager::init_() {
}
void HardModeManager::nerfHpRestore(f32* hp) const {
- *hp = sead::Mathf::max(*hp * getMultiplier(MultiplierType::HpRestore), 1.0f);
+ *hp = sead::Mathf::clampMin(*hp * getMultiplier(MultiplierType::HpRestore), 1.0f);
}
void HardModeManager::nerfHpRestore(s32* hp) const {
- *hp = sead::Mathi::max(*hp * getMultiplier(MultiplierType::HpRestore), 1);
+ *hp = sead::Mathi::clampMin(*hp * getMultiplier(MultiplierType::HpRestore), 1);
}
void HardModeManager::modifyEnemyNoticeDuration(f32* value) const {
- *value = sead::Mathf::max(*value * getMultiplier(MultiplierType::EnemyNoticeDuration), 0);
+ *value = sead::Mathf::clampMin(*value * getMultiplier(MultiplierType::EnemyNoticeDuration), 0);
}
bool HardModeManager::shouldCreateLifeRecoverInfo(ksys::act::Actor* actor) {
diff --git a/src/KingSystem/Physics/RigidBody/Shape/Box/physBoxShape.cpp b/src/KingSystem/Physics/RigidBody/Shape/Box/physBoxShape.cpp
index 1226372b..1ded03e0 100644
--- a/src/KingSystem/Physics/RigidBody/Shape/Box/physBoxShape.cpp
+++ b/src/KingSystem/Physics/RigidBody/Shape/Box/physBoxShape.cpp
@@ -11,9 +11,9 @@ BoxShape* BoxShape::make(const BoxShapeParam& param, sead::Heap* heap) {
hkpBoxShape* box = nullptr;
if (auto* storage = util::allocStorage<hkpBoxShape>(heap)) {
const auto radius = param.convex_radius;
- const hkVector4f half_extents{sead::Mathf::max(param.extents.x / 2 - radius, 0.001),
- sead::Mathf::max(param.extents.y / 2 - radius, 0.001),
- sead::Mathf::max(param.extents.z / 2 - radius, 0.001)};
+ const hkVector4f half_extents{sead::Mathf::clampMin(param.extents.x / 2 - radius, 0.001),
+ sead::Mathf::clampMin(param.extents.y / 2 - radius, 0.001),
+ sead::Mathf::clampMin(param.extents.z / 2 - radius, 0.001)};
box = new (storage) hkpBoxShape(half_extents, radius);
}
@@ -122,9 +122,10 @@ const hkpShape* BoxShape::updateHavokShape() {
if (mFlags.isOn(Flag::Dirty)) {
{
const auto radius = mHavokShape->getRadius();
- const sead::Vector3f half_extents{sead::Mathf::max(mExtents.x / 2 - radius, 0.001),
- sead::Mathf::max(mExtents.y / 2 - radius, 0.001),
- sead::Mathf::max(mExtents.z / 2 - radius, 0.001)};
+ const sead::Vector3f half_extents{
+ sead::Mathf::clampMin(mExtents.x / 2 - radius, 0.001),
+ sead::Mathf::clampMin(mExtents.y / 2 - radius, 0.001),
+ sead::Mathf::clampMin(mExtents.z / 2 - radius, 0.001)};
const auto ref_count = mHavokShape->getReferenceCount();
mHavokShape = new (mHavokShape) hkpBoxShape(toHkVec4(half_extents), radius);
mHavokShape->setReferenceCount(ref_count);
diff --git a/src/KingSystem/Physics/RigidBody/physRigidBody.cpp b/src/KingSystem/Physics/RigidBody/physRigidBody.cpp
index 5a67d445..175dac29 100644
--- a/src/KingSystem/Physics/RigidBody/physRigidBody.cpp
+++ b/src/KingSystem/Physics/RigidBody/physRigidBody.cpp
@@ -84,9 +84,9 @@ bool RigidBody::initMotionAccessorForDynamicMotion(sead::Heap* heap) {
hkMatrix3 inertia;
body->getInertiaLocal(inertia);
- param.inertia = {sead::Mathf::max(inertia(0, 0), MinInertia),
- sead::Mathf::max(inertia(1, 1), MinInertia),
- sead::Mathf::max(inertia(2, 2), MinInertia)};
+ param.inertia = {sead::Mathf::clampMin(inertia(0, 0), MinInertia),
+ sead::Mathf::clampMin(inertia(1, 1), MinInertia),
+ sead::Mathf::clampMin(inertia(2, 2), MinInertia)};
param.center_of_mass = toVec3(body->getCenterOfMassLocal());
param.linear_damping = body->getLinearDamping();
param.angular_damping = body->getAngularDamping();
@@ -126,9 +126,9 @@ bool RigidBody::createMotion(hkpMaxSizeMotion* motion, MotionType motion_type,
case MotionType::Dynamic: {
hkMatrix3f inertia_local;
- inertia_local.m_col0.set(sead::Mathf::max(param.inertia.x, MinInertia), 0, 0);
- inertia_local.m_col1.set(0, sead::Mathf::max(param.inertia.y, MinInertia), 0);
- inertia_local.m_col2.set(0, 0, sead::Mathf::max(param.inertia.z, MinInertia));
+ inertia_local.m_col0.set(sead::Mathf::clampMin(param.inertia.x, MinInertia), 0, 0);
+ inertia_local.m_col1.set(0, sead::Mathf::clampMin(param.inertia.y, MinInertia), 0);
+ inertia_local.m_col2.set(0, 0, sead::Mathf::clampMin(param.inertia.z, MinInertia));
hkpRigidBody::createDynamicRigidMotion(
hkpMotion::MOTION_DYNAMIC, position, rotation, param.mass, inertia_local,
@@ -1630,7 +1630,7 @@ bool RigidBody::isEntityMotionFlag80On() const {
void RigidBody::setColImpulseScale(float scale) {
if (!isEntity())
return;
- scale = sead::Mathf::max(scale, 0.0);
+ scale = sead::Mathf::clampMin(scale, 0.0);
getEntityMotionAccessor()->setColImpulseScale(scale);
}
diff --git a/src/KingSystem/Physics/RigidBody/physRigidBodyMotionEntity.cpp b/src/KingSystem/Physics/RigidBody/physRigidBodyMotionEntity.cpp
index 3be3e533..9820d86b 100644
--- a/src/KingSystem/Physics/RigidBody/physRigidBodyMotionEntity.cpp
+++ b/src/KingSystem/Physics/RigidBody/physRigidBodyMotionEntity.cpp
@@ -300,14 +300,6 @@ float RigidBodyMotionEntity::getMassInv() const {
return mMotion->getMassInv();
}
-static inline float max3(float a, float b, float c) {
- return sead::Mathf::max(c, a > b ? a : b);
-}
-
-static inline float min3(float a, float b, float c) {
- return sead::Mathf::min(a < b ? a : b, c);
-}
-
void RigidBodyMotionEntity::setInertiaLocal(const sead::Vector3f& inertia) {
if (mBody->isCharacterControllerType())
return;
@@ -317,8 +309,8 @@ void RigidBodyMotionEntity::setInertiaLocal(const sead::Vector3f& inertia) {
return;
}
- const float max = max3(inertia.x, inertia.y, inertia.z);
- const float min = min3(inertia.x, inertia.y, inertia.z);
+ const float max = sead::Mathf::max3(inertia.x, inertia.y, inertia.z);
+ const float min = sead::Mathf::min3(inertia.x, inertia.y, inertia.z);
const float threshold = max * 0.8f;
bool need_to_recreate_motion = false;
diff --git a/src/KingSystem/Physics/System/physContactMgr.cpp b/src/KingSystem/Physics/System/physContactMgr.cpp
index ccc25385..7872f3ef 100644
--- a/src/KingSystem/Physics/System/physContactMgr.cpp
+++ b/src/KingSystem/Physics/System/physContactMgr.cpp
@@ -551,19 +551,20 @@ void ContactMgr::setImpulseEntryContactInfo(RigidBody* body_a, RigidBody* body_b
const auto relative_vel = linvel_a - linvel_b;
const auto dot_neg = [&](const auto& vec) { return vec.dot(-contact_point_normal); };
- float magnitude = is_flag_off ? sead::Mathf::max(0.0, relative_vel.dot(-contact_point_normal)) :
- sead::Mathf::max(0.0, relative_vel.length());
+ float magnitude = is_flag_off ?
+ sead::Mathf::clampMin(0.0, relative_vel.dot(-contact_point_normal)) :
+ sead::Mathf::clampMin(0.0, relative_vel.length());
if (magnitude >= entry->magnitude) {
float i1, i2;
if (is_flag_off) {
- i1 = sead::Mathf::min(sead::Mathf::max(0.0, dot_neg(linvel_a)), magnitude);
- i2 = sead::Mathf::min(sead::Mathf::max(0.0, linvel_b.dot(contact_point_normal)),
- sead::Mathf::max(0.0, dot_neg(relative_vel)));
+ i1 = sead::Mathf::min(sead::Mathf::clampMin(0.0, dot_neg(linvel_a)), magnitude);
+ i2 = sead::Mathf::min(sead::Mathf::clampMin(0.0, linvel_b.dot(contact_point_normal)),
+ sead::Mathf::clampMin(0.0, dot_neg(relative_vel)));
} else {
- i1 = sead::Mathf::min(sead::Mathf::max(0.0, linvel_a.length()), magnitude);
- i2 = sead::Mathf::min(sead::Mathf::max(0.0, linvel_b.length()),
- sead::Mathf::max(0.0, relative_vel.length()));
+ i1 = sead::Mathf::min(sead::Mathf::clampMin(0.0, linvel_a.length()), magnitude);
+ i2 = sead::Mathf::min(sead::Mathf::clampMin(0.0, linvel_b.length()),
+ sead::Mathf::clampMin(0.0, relative_vel.length()));
}
entry->magnitude = magnitude;
diff --git a/src/KingSystem/System/VFR.cpp b/src/KingSystem/System/VFR.cpp
index f2ae8d1f..0c53d41d 100644
--- a/src/KingSystem/System/VFR.cpp
+++ b/src/KingSystem/System/VFR.cpp
@@ -21,7 +21,7 @@ VFR::~VFR() {
}
void VFR::setDelta(u32 core, f32 delta) {
- delta = sead::Mathf::max(delta, 0.01f);
+ delta = sead::Mathf::clampMin(delta, 0.01f);
*mRawDeltaFrames[core] = delta;
*mDeltaFrames[core] = delta * *mIntervalRatios[core];
*mRawDeltaTimes[core] = delta * mFrameTime;
@@ -111,7 +111,7 @@ void VFR::TimeSpeedMultiplier::update(f32 multiplier) {
if (target_value < value) {
value = target_value;
} else {
- sead::Mathf::chase(&value, target_value, sead::Mathf::max(value * multiplier, 0.01));
+ sead::Mathf::chase(&value, target_value, sead::Mathf::clampMin(value * multiplier, 0.01));
}
}
diff --git a/src/KingSystem/World/worldManager.cpp b/src/KingSystem/World/worldManager.cpp
index cd2d9853..d92fa470 100644
--- a/src/KingSystem/World/worldManager.cpp
+++ b/src/KingSystem/World/worldManager.cpp
@@ -140,7 +140,7 @@ float Manager::calcTempDay(float height) const {
float normal_temp = 23.0f;
if (isMainField() && worldInfoLoaded()) {
- height = sead::Mathf::max(height, 0.0f);
+ height = sead::Mathf::clampMin(height, 0.0f);
int a = -1;
float h{};
@@ -182,7 +182,7 @@ float Manager::calcTempNight(float height) const {
float normal_temp = 23.0f;
if (isMainField() && worldInfoLoaded()) {
- height = sead::Mathf::max(height, 0.0f);
+ height = sead::Mathf::clampMin(height, 0.0f);
int a = -1;
float h{};
diff --git a/src/KingSystem/World/worldTimeMgr.cpp b/src/KingSystem/World/worldTimeMgr.cpp
index 39e213bc..2cb5d091 100644
--- a/src/KingSystem/World/worldTimeMgr.cpp
+++ b/src/KingSystem/World/worldTimeMgr.cpp
@@ -327,7 +327,7 @@ void TimeMgr::calc_() {
if (!mFindDungeonActivated && mTime >= 11_h)
mTime = 11_h;
- _d0 = sead::Mathf::max(mTimeStep / DefaultTimeStep, 1.0);
+ _d0 = sead::Mathf::clampMin(mTimeStep / DefaultTimeStep, 1.0);
mBloodMoonTimer += delta;
break;
}