summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTakaRikka <38417346+TakaRikka@users.noreply.github.com>2021-12-02 06:38:58 -0800
committerGitHub <noreply@github.com>2021-12-02 06:38:58 -0800
commit5f187a0776487afa64cb0993b1e96bb5ee115efd (patch)
tree22191c5d493194c14bd11766a6cd5b376211b423 /include
parentc4ef30bc95d3e69eb84cb5efa76598bb6e900662 (diff)
parentbac74bd010b3026e64ec5c30340ad96736c924b2 (diff)
Merge pull request #161 from lepelog/c-lib
c_lib OK
Diffstat (limited to 'include')
-rw-r--r--include/SSystem/SComponent/c_lib.h5
-rw-r--r--include/SSystem/SComponent/c_xyz.h7
-rw-r--r--include/msl_c/math.h3
3 files changed, 14 insertions, 1 deletions
diff --git a/include/SSystem/SComponent/c_lib.h b/include/SSystem/SComponent/c_lib.h
index 8ff0092bc1..12d01b9f7c 100644
--- a/include/SSystem/SComponent/c_lib.h
+++ b/include/SSystem/SComponent/c_lib.h
@@ -4,6 +4,11 @@
#include "SSystem/SComponent/c_xyz.h"
#include "dolphin/mtx/mtx.h"
#include "dolphin/types.h"
+#include "msl_c/math.h"
+
+inline bool cLib_IsZero(f32 f) {
+ return fabsf(f) < 8e-11f;
+}
void cLib_memCpy(void* dst, const void* src, unsigned long size);
void cLib_memSet(void* ptr, int value, unsigned long size);
diff --git a/include/SSystem/SComponent/c_xyz.h b/include/SSystem/SComponent/c_xyz.h
index 0f28e22048..bf9c092b8a 100644
--- a/include/SSystem/SComponent/c_xyz.h
+++ b/include/SSystem/SComponent/c_xyz.h
@@ -3,6 +3,7 @@
#include "dolphin/mtx/vec.h"
#include "global.h"
+#include "msl_c/math.h"
struct cXyz : Vec {
static const cXyz Zero;
@@ -50,11 +51,13 @@ struct cXyz : Vec {
y -= f;
z -= f;
}
+ void operator-=(const Vec& other) { PSVECSubtract(this, &other, this); }
void operator+=(const Vec& vec) {
x += vec.x;
y += vec.y;
z += vec.z;
}
+ void operator*=(f32 scale) { PSVECScale(this, this, scale); }
/* 80266C6C */ cXyz getCrossProduct(Vec const&) const;
/* 80266CBC */ cXyz outprod(Vec const&) const;
/* 80266CE4 */ cXyz norm() const;
@@ -116,6 +119,10 @@ struct cXyz : Vec {
cXyz tmp2(other.x, 0, other.z);
return tmp.abs2(tmp2);
}
+ f32 abs() const { return sqrtf(this->abs2()); }
+ f32 abs(const Vec& other) const { return sqrtf(this->abs2(other)); }
+ f32 absXZ() const { return sqrtf(this->abs2XZ()); }
+ f32 absXZ(const Vec& other) const { return sqrtf(this->abs2XZ(other)); }
f32 getMagXZ() const { return cXyz(this->x, 0, this->z).getSquareMag(); }
};
diff --git a/include/msl_c/math.h b/include/msl_c/math.h
index a966a8cce0..844a514251 100644
--- a/include/msl_c/math.h
+++ b/include/msl_c/math.h
@@ -46,6 +46,7 @@ f32 tanf(f32);
extern f32 __float_nan[4];
extern f32 __float_epsilon[4];
+extern f32 __float_max[4];
inline f64 sqrt_step(f64 tmpd, f32 mag) {
return tmpd * 0.5 * (3.0 - mag * (tmpd * tmpd));
@@ -68,4 +69,4 @@ inline f32 sqrtf(f32 mag) {
}
}
-#endif \ No newline at end of file
+#endif