Skip to content

Commit

Permalink
just regswap on adjustSpeed
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah-thomas774 committed Nov 6, 2024
1 parent b97f0a5 commit b905dc5
Show file tree
Hide file tree
Showing 15 changed files with 193 additions and 159 deletions.
2 changes: 1 addition & 1 deletion config/SOUE01/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45930,7 +45930,7 @@ lbl_8057CD8C = .sdata2:0x8057CD8C; // type:object size:0x4 data:float
sHalfCircleDeg__4mAng = .sdata2:0x8057CD90; // type:object size:0x4 data:float
sAngToDeg__4mAng = .sdata2:0x8057CD94; // type:object size:0x4 data:float
sAngToRad__4mAng = .sdata2:0x8057CD98; // type:object size:0x4 data:float
NotSure__4mAng = .sdata2:0x8057CD9C; // type:object size:0x4 data:float
sAngToNorm__4mAng = .sdata2:0x8057CD9C; // type:object size:0x4 data:float
sDegToRad__4mAng = .sdata2:0x8057CDA0; // type:object size:0x4 data:float
sDegToAng__4mAng = .sdata2:0x8057CDA4; // type:object size:0x4 data:float
sRadToAng__4mAng = .sdata2:0x8057CDA8; // type:object size:0x4 data:float
Expand Down
5 changes: 5 additions & 0 deletions include/c/c_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ int rndInt(int max);
f32 rndF(f32 max);
f32 rndFX(f32 amp);

template <typename T>
inline T minMaxLimit(T val, T min, T max) {
return (T)((T)val < (T)min ? (T)min : ((T)val > (T)max ? (T)max : (T)val));
}

} // namespace cM

#endif
4 changes: 4 additions & 0 deletions include/d/col/bg/d_bg_s_acch.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ class dBgS_Acch : public cBgS_Chk, public dBgS_Chk {
return mFlags & GROUND_HIT;
}

dBgS_GndChk &GetGnd() {
return mGnd;
}

public:
/* 0x040 */ u32 mFlags;
/* 0x044 */ mVec3_c *mpPos;
Expand Down
4 changes: 0 additions & 4 deletions include/egg/math/eggMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ class Math {
return (T)0;
}

static T clamp(T x, T low, T high) {
return (x < low ? low : (x > high ? high : x));
}

static T sqrt(T);
static T sin(T);
static T cos(T);
Expand Down
51 changes: 21 additions & 30 deletions include/egg/math/eggQuat.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,32 @@
#include "common.h"
#include "egg/math/eggVector.h"


namespace EGG {

struct Quatf : public Vector3f {
struct Quatf {
Quatf() {}
Quatf(f32 f, Vector3f v) : w(f), Vector3f(v) {}
Quatf(f32 f, f32 x, f32 y, f32 z) : w(f), Vector3f(Vector3f(x, y, z)) {}
Quatf(f32 f, const Vector3f &v) : w(f), v(v) {}
Quatf(f32 f, f32 x, f32 y, f32 z) : w(f), v(Vector3f(x, y, z)) {}
~Quatf() {}

friend Quatf operator*(const Quatf &q, const Vector3f &vec) {
Vector3f crossed = q.cross(vec);
Vector3f crossed = q.v.cross(vec);
Vector3f scaled = vec * q.w;
Quatf ret = Quatf(-q.Vector3f::dot(vec), crossed + scaled);
Quatf ret = Quatf(-q.v.dot(vec), crossed + scaled);
return ret;
}

// TODO: Implement
friend Quatf operator*(const Quatf &u, const Quatf &v) {
Vector3f cross = u.cross(v);
Vector3f v_mul_w = u.w * v;
Vector3f u_mul_w = v.w * v;
Vector3f added_2 = u_mul_w + (cross + v_mul_w);
Quatf out = Quatf(u.w * v.w - u.Vector3f::dot(v), added_2);
return out;
};
friend Quatf operator*(const Quatf &lhs, const Quatf &rhs) {
Vector3f cross = lhs.v.cross(rhs.v);

Vector3f scaledRhs = lhs.w * rhs.v;
Vector3f tmp0 = cross + scaledRhs;

Vector3f scaledLhs = rhs.w * lhs.v;
Vector3f tmp1 = tmp0 + scaledLhs;

return Quatf(lhs.w * rhs.w - lhs.v.dot(rhs.v), tmp1);
}

/* 8049b390 */ void set(f32 fw, f32 fx, f32 fy, f32 fz);
/* */ void set(f32 f, const Vector3f &vec);
Expand All @@ -47,27 +48,17 @@ struct Quatf : public Vector3f {
/* */ void makeVectorRotationLimit(Vector3f &, Vector3f &, f32);
/* 8049bbb0 */ void makeVectorRotation(Vector3f &, Vector3f &);

f32 dot(const Quatf &q) const {
return w * w + q.x * q.x + q.y * q.y + q.z * q.z;
}
f32 length() const {
return Math<f32>::sqrt(dot(*this));
}
void multScalar(f32 s) {
w *= s;
x *= s;
y *= s;
z *= s;
v.x *= s;
v.y *= s;
v.z *= s;
}
void setUnit() {
set(1.0f, 0.0f, 0.0f, 0.0f);
}
// union {
// Vector3f v;
// struct {
// f32 x, y, z;
// };
// };

Vector3f v;
f32 w;
};

Expand Down
5 changes: 2 additions & 3 deletions include/egg/math/eggVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "egg/math/eggMath.h"
#include "nw4r/math.h"


namespace EGG {

struct Vector3f : public nw4r::math::VEC3 {
Expand All @@ -28,11 +27,11 @@ struct Vector3f : public nw4r::math::VEC3 {
}

friend Vector3f operator*(f32 f, const Vector3f &v) {
return v.operator*(f);
return Vector3f(v.x * f, v.y * f, v.z * f);
}

// __pl__Q23EGG8Vector3fCFRCQ23EGG8Vector3f
Vector3f operator+(const Vector3f &v) {
Vector3f operator+(const Vector3f &v) const {
return Vector3f(x + v.x, y + v.y, z + v.z);
}

Expand Down
36 changes: 22 additions & 14 deletions include/m/m_angle.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "c/c_math.h"
#include "common.h"
#include "m/m_vec.h"
#include "math.h"
#include "nw4r/math/math_triangular.h"

struct mAng {
Expand Down Expand Up @@ -51,41 +52,48 @@ struct mAng {

s16 mVal;

f32 degree() const {
return (360.0f / 65536.0f) * mVal;
}

static mAng fromDeg(f32 deg) {
return deg * sDegToAng;
}

static mAng fromRad(f32 rad) {
f32 radian() const {
return ((2.f * M_PI) / 65536.0f) * mVal;
}
static s16 fromRad(f32 rad) {
return rad * sRadToAng;
}

static f32 Radian_to_Degree(f32 rad) {
return rad * 57.2957763671875f;
static f32 rad2deg(f32 rad) {
return rad * (360.f / (2.f * M_PI));
}
static f32 Degree_to_Radian(f32 deg) {
return deg * 0.017453292f;
static f32 deg2rad(f32 deg) {
return deg * ((2.f * M_PI) / 360.f);
}
static s16 Degree_to_SAngle(f32 deg) {
return deg * 182.04444885253906f;
static s16 deg2short(f32 deg) {
return deg * (65536.0f / 360.0f);
}
static f32 SAngle_to_Degree(s16 angle) {
static f32 short2deg(s16 angle) {
return (360.0f / 65536.0f) * angle;
}
static f32 SAngle_to_Radian(s16 angle) {
return 9.58738E-5f * angle;
static f32 short2rad(s16 angle) {
return ((2.f * M_PI) / 65536.0f) * angle;
}
static f32 SAngle_to_Normal(s16 angle) {
static f32 short2norm(s16 angle) {
return 3.0517578E-5f * angle;
}
static s16 Radian_to_SAngle(f32 rad) {
return rad * 10430.378f;
static s16 rad2short(f32 rad) {
return rad * (65536.0f / (2.f * M_PI));
}

private:
static const f32 sHalfCircleDeg;
static const f32 sAngToDeg;
static const f32 sAngToRad;
static const f32 NotSure;
static const f32 sAngToNorm;
static const f32 sDegToRad;
static const f32 sDegToAng;
static const f32 sRadToAng;
Expand Down
13 changes: 13 additions & 0 deletions include/m/m_mtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "m/m_angle.h"
#include "m/m_vec.h"
#include "nw4r/types_nw4r.h"
#include "rvl/MTX/mtx.h"

class mMtx_c : public EGG::Matrix34f {
typedef f32 (*MtxRef)[4];
Expand Down Expand Up @@ -63,6 +64,18 @@ class mMtx_c : public EGG::Matrix34f {
void rot(int, int); // does some werrd operation to rotate the matrix
bool quatRelated();

void trans(const mVec3_c &v) {
PSMTXTrans(*this, v.x, v.y, v.z);
}
void trans(f32 x, f32 y, f32 z) {
PSMTXTrans(*this, x, y, z);
}

mMtx_c &operator+=(const mMtx_c &rhs) {
PSMTXConcat(*this, rhs, *this);
return *this;
}

public:
static mMtx_c Identity;
};
Expand Down
5 changes: 3 additions & 2 deletions include/m/m_quat.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ class mQuat_c : public EGG::Quatf {
public:
mQuat_c() {}
mQuat_c(f32 x, f32 y, f32 z, f32 w) : EGG::Quatf(w, x, y, z) {}

mQuat_c &operator=(const EGG::Quatf &rhs) {
*(EGG::Quatf *)this = rhs;
v = rhs.v;
w = rhs.w;
return *this;
}

void fn_802F2780(const mQuat_c &other);
};

Expand Down
5 changes: 4 additions & 1 deletion include/m/m_vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "nw4r/types_nw4r.h"
#include "rvl/MTX/vec.h"


class mAng;

class mVec3_c : public EGG::Vector3f {
Expand Down Expand Up @@ -226,6 +225,10 @@ class mVec3_c : public EGG::Vector3f {
p->z = z;
}

s16 ang() const {
return cM::atan2s(x * x, z * z);
}

static mVec3_c Zero;
static mVec3_c Ex;
static mVec3_c Ey;
Expand Down
Loading

0 comments on commit b905dc5

Please sign in to comment.