ksys/phys: Add impulse related ContactMgr functions

This commit is contained in:
Léo Lam
2022-03-11 21:59:14 +01:00
parent ad6c11f468
commit e27c55361d
9 changed files with 286 additions and 53 deletions
+13 -1
View File
@@ -1,12 +1,24 @@
#pragma once
#include <math/seadMathCalcCommon.h>
#include <math/seadVector.h>
namespace ksys::util {
/// Remap `value` from a [low, high] range to [new_low, new_high].
inline float remapRange(float value, float low, float high, float new_low, float new_high) {
return new_low + (value - low) * (new_high - new_low) / (high - low);
}
/// Clamp `value` to [low, high] and then remap the value to the range [new_low, new_high].
inline float clampAndRemapRange(float value, float low, float high, float new_low, float new_high) {
value = sead::Mathf::clamp(value, low, high);
return remapRange(value, low, high, new_low, new_high);
}
// too specific for sead
inline float sqXZDistance(const sead::Vector3f& a, const sead::Vector3f& b) {
return sead::Mathf::square(a.x - b.x) + sead::Mathf::square(a.z - b.z);
}
} // namespace ksys::util
} // namespace ksys::util