diff options
| author | LagoLunatic <LagoLunatic@users.noreply.github.com> | 2023-09-18 15:29:40 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-18 12:29:40 -0700 |
| commit | 01f2fc433f52c78cd09d8398f338c9df296c6ee0 (patch) | |
| tree | ec1370289df22d5abfe4b9229efbe1fac8ff7182 /include/JSystem/JMath | |
| parent | 1040e0498cb0a10bc8ed79a167d690d78f05dbd6 (diff) | |
d_a_nh done (no match) (#55)
* Fix sin and cos
* Fix dCcD_GObjInf JP inlining difference
* Improvements to dDlst_alphaModel_c
* d_a_nh done (no match)
Diffstat (limited to 'include/JSystem/JMath')
| -rw-r--r-- | include/JSystem/JMath/JMATrigonometric.h | 69 |
1 files changed, 5 insertions, 64 deletions
diff --git a/include/JSystem/JMath/JMATrigonometric.h b/include/JSystem/JMath/JMATrigonometric.h index 6fe4c321..d57bd234 100644 --- a/include/JSystem/JMath/JMATrigonometric.h +++ b/include/JSystem/JMath/JMATrigonometric.h @@ -4,74 +4,15 @@ #include "dolphin/types.h" #include "MSL_C/utility.h" -struct TSinCosTable { - std::pair<f32, f32> table[0x2000]; - - f32 sinShort(s16 v) const { return table[static_cast<u16>(v) >> 3].first; } - f32 cosShort(s16 v) const { return table[static_cast<u16>(v) >> 3].second; } - - inline f32 sinLap(f32 v) { - if (v < 0.0f) { - return -table[(u16)(-8192.0f * v) & 0x1fff].first; - } - return table[(u16)(8192.0f * v) & 0x1fff].first; - } - - inline f32 sinDegree(f32 degree) { - if (degree < 0.0f) { - return -table[(u16)(-22.755556106567383f * degree) & 0x1fffU].first; - } - return table[(u16)(22.755556106567383f * degree) & 0x1fffU].first; - } - - inline f32 cosDegree(f32 degree) { - if (degree < 0.0f) { - degree = -degree; - } - return table[(u16)(22.755556106567383f * degree) & 0x1fffU].second; - } -}; - -struct TAtanTable { - f32 table[1025]; - u8 pad[0x1C]; -}; - -struct TAsinAcosTable { - f32 table[1025]; - u8 pad[0x1C]; -}; - -namespace JMath { -extern TSinCosTable sincosTable_; -extern TAtanTable atanTable_; -extern TAsinAcosTable asinAcosTable_; -}; // namespace JMath - -inline f32 JMASCosShort(s16 v) { - return JMath::sincosTable_.cosShort(v); -} -inline f32 JMASinShort(s16 v) { - return JMath::sincosTable_.sinShort(v); -} +extern u32 jmaSinShift; +extern f32 *jmaSinTable; +extern f32 *jmaCosTable; inline f32 JMASCos(s16 v) { - return JMASCosShort(v); + return jmaCosTable[static_cast<u16>(v) >> jmaSinShift]; } inline f32 JMASSin(s16 v) { - return JMASinShort(v); -} - -inline f32 JMASinLap(f32 v) { - return JMath::sincosTable_.sinLap(v); -} - -inline f32 JMASinDegree(f32 degree) { - return JMath::sincosTable_.sinDegree(degree); -} - -inline f32 JMACosDegree(f32 degree) { - return JMath::sincosTable_.cosDegree(degree); + return jmaSinTable[static_cast<u16>(v) >> jmaSinShift]; } #endif /* JMATRIGONOMETRIC_H */ |
