Fix errors when building with -ipa program (#3035)

This commit is contained in:
Max Roncace
2026-01-11 22:25:26 -05:00
committed by GitHub
parent e3610729d9
commit 919a7aaa96
17 changed files with 88 additions and 91 deletions
+45
View File
@@ -2,8 +2,18 @@
#define JMATRIGONOMETRIC_H
#include "dolphin/types.h"
#include <math>
#include <utility>
#ifdef __cplusplus
extern "C" {
#endif
extern double asin(double);
extern double atan(double);
#ifdef __cplusplus
}
#endif
namespace JMath {
template<typename T>
struct TAngleConstant_;
@@ -28,6 +38,16 @@ template<int N, typename T>
struct TSinCosTable {
std::pair<T, T> table[1 << N];
TSinCosTable() {
init();
}
void init() {
for (int i = 0; i < 1 << N; i++) {
table[i].first = sin((i * f64(TAngleConstant_<f32>::RADIAN_DEG360())) / (1 << N));
table[i].second = cos((i * f64(TAngleConstant_<f32>::RADIAN_DEG360())) / (1 << N));
}
}
T sinShort(s16 v) const { return table[(u16)v >> (16U - N)].first; }
T cosShort(s16 v) const { return table[(u16)v >> (16U - N)].second; }
@@ -68,6 +88,19 @@ template<int N, typename T>
struct TAtanTable {
T table[N + 1];
u8 pad[0x1C];
TAtanTable() {
init();
}
void init() {
// u32 cast needed for cmplwi instead of cmpwi
for (int i = 0; i < (u32)N; i++) {
table[i] = atan(i / (f64)N);
}
table[0] = 0.0f;
table[N] = TAngleConstant_<T>::RADIAN_DEG180() / 4.0f;
}
};
/**
@@ -79,6 +112,18 @@ struct TAsinAcosTable {
T table[N + 1];
u8 pad[0x1C];
TAsinAcosTable() {
init();
}
void init() {
for (int i = 0; i < 1024; i++) {
table[i] = asin(i / (f64)N);
}
table[0] = 0.0f;
table[N] = TAngleConstant_<T>::RADIAN_DEG180() / 4.0f;
}
T acos_(T x) const {
if (x >= 1.0f) {
return 0.0f;