diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2025-09-04 07:56:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-04 17:56:59 +0300 |
| commit | b45a089e15d79821b07be020db628e01a49b1fd2 (patch) | |
| tree | 948057548cc19b19d644bd4f300ca6434e6bff11 /include/JSystem/JMath | |
| parent | ee8b843996f4d888903f8c125b95ec1af376877e (diff) | |
some J3D/misc cleanup (#2628)
* some j3d cleanup
* begin using uintptr_t
* j3dgraphbase cleanup
* j3dgraphanimator cleanup
Diffstat (limited to 'include/JSystem/JMath')
| -rw-r--r-- | include/JSystem/JMath/JMATrigonometric.h | 21 | ||||
| -rw-r--r-- | include/JSystem/JMath/JMath.h | 5 |
2 files changed, 16 insertions, 10 deletions
diff --git a/include/JSystem/JMath/JMATrigonometric.h b/include/JSystem/JMath/JMATrigonometric.h index 1b88975794..25b79a72dc 100644 --- a/include/JSystem/JMath/JMATrigonometric.h +++ b/include/JSystem/JMath/JMATrigonometric.h @@ -2,8 +2,9 @@ #define JMATRIGONOMETRIC_H #include "dolphin/types.h" -#include "utility.h" +#include <utility.h> +namespace JMath { template<typename T> struct TAngleConstant_; @@ -19,7 +20,6 @@ struct TAngleConstant_<f32> { static f32 RADIAN_TO_DEGREE_FACTOR() { return 180.0f / RADIAN_DEG180(); } }; -namespace JMath { /** * @ingroup jsystem-jmath * @@ -73,30 +73,31 @@ struct TAtanTable { * @ingroup jsystem-jmath * */ +template<int N, typename T> struct TAsinAcosTable { - f32 table[1025]; + T table[1025]; u8 pad[0x1C]; - f32 acos_(f32 x) { + T acos_(T x) const { if (x >= 1.0f) { return 0.0f; } else if (x <= -1.0f) { - return TAngleConstant_<f32>::RADIAN_DEG180(); + return TAngleConstant_<T>::RADIAN_DEG180(); } else if (x < 0.0f) { - return table[(u32)(-x * 1023.5f)] + TAngleConstant_<f32>::RADIAN_DEG090(); + return table[(u32)(-x * 1023.5f)] + TAngleConstant_<T>::RADIAN_DEG090(); } else { - return TAngleConstant_<f32>::RADIAN_DEG090() - table[(u32)(x * 1023.5f)]; + return TAngleConstant_<T>::RADIAN_DEG090() - table[(u32)(x * 1023.5f)]; } } - f32 acosDegree(f32 x) { - return acos_(x) * TAngleConstant_<f32>::RADIAN_TO_DEGREE_FACTOR(); + T acosDegree(T x) const { + return acos_(x) * TAngleConstant_<T>::RADIAN_TO_DEGREE_FACTOR(); } }; extern TSinCosTable<13, f32> sincosTable_; extern TAtanTable atanTable_; -extern TAsinAcosTable asinAcosTable_; +extern TAsinAcosTable<1024, f32> asinAcosTable_; inline f32 acosDegree(f32 x) { return asinAcosTable_.acosDegree(x); diff --git a/include/JSystem/JMath/JMath.h b/include/JSystem/JMath/JMath.h index eb7932e848..4d9dd66608 100644 --- a/include/JSystem/JMath/JMath.h +++ b/include/JSystem/JMath/JMath.h @@ -80,6 +80,11 @@ inline f32 JMAHermiteInterpolation(register f32 p1, register f32 p2, register f3 namespace JMath { +template <typename T> +inline T fastSqrt(T value) { + return JMAFastSqrt(value); +} + inline f32 fastReciprocal(f32 value) { return JMAFastReciprocal(value); } |
