diff options
| author | Aetias <aetias@outlook.com> | 2024-10-21 20:36:15 +0200 |
|---|---|---|
| committer | Aetias <aetias@outlook.com> | 2024-10-21 20:36:15 +0200 |
| commit | a62cc074e93cdd77605bddcd145a96d3cfa7618d (patch) | |
| tree | 31f0d5bf0872b316643d543957ea2a6d22e632e2 /include/lib/math.h | |
| parent | 5c3e3aee99af35884462f518a9bc1fbf65ae92d4 (diff) | |
| parent | f4c5e4862419a14487575bf477118458c0e4a289 (diff) | |
Merge branch 'main' into actor-manager
Diffstat (limited to 'include/lib/math.h')
| -rw-r--r-- | include/lib/math.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/include/lib/math.h b/include/lib/math.h index 8242284e..f7204acc 100644 --- a/include/lib/math.h +++ b/include/lib/math.h @@ -8,10 +8,12 @@ typedef s32 q20; // Q4.12 fixed point number typedef s16 q4; -#define INT_TO_Q20(n) ((s32)((n) << 12)) -#define FLOAT_TO_Q20(n) ((s32)(((n) * 8192 + 1) / 2)) -#define ROUND_Q20(n) (((s32)(n) + 0x800) >> 12) -#define MUL_Q20(a,b) (q20)((((s64)(a)) * ((s64)(b)) + 0x800) >> 12) +#define INT_TO_Q20(n) ((s32) ((n) << 12)) +#define FLOAT_TO_Q21(n) ((s32) (((n) * 8192 + 1) / 4)) +#define FLOAT_TO_Q20(n) ((s32) (((n) * 8192 + 1) / 2)) +#define FLOAT_TO_Q19(n) ((s32) (((n) * 8192 + 1))) +#define ROUND_Q20(n) (((s32) (n) + 0x800) >> 12) +#define MUL_Q20(a, b) (q20)((((s64) (a)) * ((s64) (b)) + 0x800) >> 12) #define DEG_TO_ANG(n) ((n) * 0x10000 / 360) #define SIN(n) (gSinCosTable[2 * ((n) >> 4)]) @@ -60,6 +62,7 @@ inline void Vec3p_Rotate(Vec3p *vec, q20 sin, q20 cos, Vec3p *out) { inline void Vec3p_CopyXZ(Vec3p *vec, Vec3p *out) { q20 z = vec->z; q20 x = vec->x; + out->x = x; out->y = 0; out->z = z; |
