diff --git a/include/SSystem/SComponent/c_m3d_g_aab.h b/include/SSystem/SComponent/c_m3d_g_aab.h index fc2e27fa7af..559f2937bfb 100644 --- a/include/SSystem/SComponent/c_m3d_g_aab.h +++ b/include/SSystem/SComponent/c_m3d_g_aab.h @@ -2,5 +2,35 @@ #define C_M3D_G_AAB_H #include "dolphin/types.h" +#include "SSystem/SComponent/c_xyz.h" + +// Axis aligned bounding box +class cM3dGAab { +private: +public: + cXyz mMin; + cXyz mMax; + + virtual ~cM3dGAab(); + void Set(const cXyz*, const cXyz*); + bool CrossY(const cXyz*) const; + bool UnderPlaneYUnder(f32) const; + bool TopPlaneYUnder(f32) const; + void ClearForMinMax(void); + void SetMinMax(const cXyz&); + void SetMinMax(const cM3dGAab&); + void SetMin(const cXyz&); + void SetMax(const cXyz&); + void CalcCenter(cXyz*) const; + void PlusR(f32); + const cXyz& getMaxP(void) const { return mMax; } + const cXyz& getMinP(void) const { return mMin; } + const f32 GetMaxX(void) const { return mMax.GetX(); } + const f32 GetMaxY(void) const { return mMax.GetY(); } + const f32 GetMaxZ(void) const { return mMax.GetZ(); } + const f32 GetMinX(void) const { return mMin.GetX(); } + const f32 GetMinY(void) const { return mMin.GetY(); } + const f32 GetMinZ(void) const { return mMin.GetZ(); } +}; #endif /* C_M3D_G_AAB_H */ diff --git a/include/SSystem/SComponent/c_m3d_g_cir.h b/include/SSystem/SComponent/c_m3d_g_cir.h index d8ce850da66..d58bd406a40 100644 --- a/include/SSystem/SComponent/c_m3d_g_cir.h +++ b/include/SSystem/SComponent/c_m3d_g_cir.h @@ -3,4 +3,22 @@ #include "dolphin/types.h" +class cM2dGCir { +public: + f32 mPosX; + f32 mPosY; + f32 mRadius; + cM2dGCir() {} + virtual ~cM2dGCir() {} +}; + +class cM3dGCir : public cM2dGCir { + f32 mPosZ; + +public: + cM3dGCir(void); + virtual ~cM3dGCir(void); + void Set(f32, f32, f32, f32); +}; + #endif /* C_M3D_G_CIR_H */ diff --git a/include/SSystem/SComponent/c_m3d_g_cps.h b/include/SSystem/SComponent/c_m3d_g_cps.h index 9af5ec6e91f..149f194e0ae 100644 --- a/include/SSystem/SComponent/c_m3d_g_cps.h +++ b/include/SSystem/SComponent/c_m3d_g_cps.h @@ -2,5 +2,25 @@ #define C_M3D_G_CPS_H #include "dolphin/types.h" +#include "SSystem/SComponent/c_m3d_g_lin.h" +#include "SSystem/SComponent/c_xyz.h" + +struct cM3dGCpsS { + Vec mStart; + Vec mEnd; + f32 unk_0x1c; +}; + +class cM3dGCps : public cM3dGLin { +private: + f32 unk_0x1c; + +public: + cM3dGCps(void); + virtual ~cM3dGCps(void); + void Set(const cXyz&, const cXyz&, f32); + void Set(const cM3dGCpsS&); + void SetCps(const cM3dGCps&); +}; #endif /* C_M3D_G_CPS_H */ diff --git a/include/SSystem/SComponent/c_m3d_g_lin.h b/include/SSystem/SComponent/c_m3d_g_lin.h index 4a1e9501159..4493ffe4d03 100644 --- a/include/SSystem/SComponent/c_m3d_g_lin.h +++ b/include/SSystem/SComponent/c_m3d_g_lin.h @@ -2,5 +2,28 @@ #define C_M3D_G_LIN_H #include "dolphin/types.h" +#include "SSystem/SComponent/c_xyz.h" +#include "mtx_vec.h" + +// Line +class cM3dGLin { + // private: +public: + cXyz mStart; + cXyz mEnd; + + cM3dGLin() {} + cM3dGLin(const cXyz&, const cXyz&); + virtual ~cM3dGLin() {} + void SetStartEnd(const cXyz&, const cXyz&); + void SetStartEnd(const Vec&, const Vec&); + void CalcPos(Vec*, f32) const; + void CalcVec(Vec* pOut) const { PSVECSubtract(&this->mEnd, &this->mStart, pOut); } + void SetEnd(const cXyz&); + const cXyz& GetStartP(void) const { return mStart; } + cXyz& GetStartP(void) { return mStart; } + const cXyz& GetEndP(void) const { return mEnd; } + cXyz& GetEndP(void) { return mEnd; } +}; #endif /* C_M3D_G_LIN_H */ diff --git a/include/SSystem/SComponent/c_xyz.h b/include/SSystem/SComponent/c_xyz.h index 21460d2bfb9..d75dd51d236 100644 --- a/include/SSystem/SComponent/c_xyz.h +++ b/include/SSystem/SComponent/c_xyz.h @@ -32,6 +32,21 @@ struct cXyz : Vec { /* 80266B84 */ cXyz operator*(f32) const; /* 80266BD0 */ cXyz operator*(Vec const&) const; /* 80266C18 */ cXyz operator/(f32) const; + void operator+=(f32 f) { + x += f; + y += f; + z += f; + } + void operator-=(f32 f) { + x -= f; + y -= f; + z -= f; + } + void operator+=(const Vec& vec) { + x += vec.x; + y += vec.y; + z += vec.z; + } /* 80266C6C */ cXyz getCrossProduct(Vec const&) const; /* 80266CBC */ cXyz outprod(Vec const&) const; /* 80266CE4 */ cXyz norm() const; @@ -45,6 +60,44 @@ struct cXyz : Vec { /* 802670AC */ bool isZero() const; /* 80267128 */ s16 atan2sX_Z() const; /* 80267150 */ s16 atan2sY_XZ() const; + + void setAll(f32 f) { + z = f; + y = f; + x = f; + } + + void set(f32 pX, f32 pY, f32 pZ) { + x = pX; + y = pY; + z = pZ; + } + + void setMin(const cXyz& other) { + if (x > other.x) { + x = other.x; + } + if (y > other.y) { + y = other.y; + } + if (z > other.z) { + z = other.z; + } + } + + void setMax(const cXyz& other) { + if (x < other.x) { + x = other.x; + } + if (y < other.y) { + y = other.y; + } + if (z < other.z) { + z = other.z; + } + } + + float getSquareMag() const { return PSVECSquareMag(this); } }; #endif /* C_XYZ_H */ diff --git a/libs/SSystem/SComponent/c_m3d_g_aab.cpp b/libs/SSystem/SComponent/c_m3d_g_aab.cpp index 74a9752ffb4..40edb3cb996 100644 --- a/libs/SSystem/SComponent/c_m3d_g_aab.cpp +++ b/libs/SSystem/SComponent/c_m3d_g_aab.cpp @@ -6,175 +6,72 @@ #include "SSystem/SComponent/c_m3d_g_aab.h" #include "dol2asm.h" #include "dolphin/types.h" - -// -// Types: -// - -struct cXyz {}; - -struct cM3dGAab { - /* 8026EC54 */ void Set(cXyz const*, cXyz const*); - /* 8026EC88 */ void CrossY(cXyz const*) const; - /* 8026ECD0 */ void UnderPlaneYUnder(f32) const; - /* 8026ECE4 */ void TopPlaneYUnder(f32) const; - /* 8026ECF8 */ void ClearForMinMax(); - /* 8026ED60 */ void SetMinMax(cM3dGAab const&); - /* 8026ED1C */ void SetMinMax(cXyz const&); - /* 8026EDA4 */ void SetMin(cXyz const&); - /* 8026EDE4 */ void SetMax(cXyz const&); - /* 8026EE24 */ void CalcCenter(cXyz*) const; - /* 8026EE68 */ void PlusR(f32); -}; - -// -// Forward References: -// - -extern "C" void Set__8cM3dGAabFPC4cXyzPC4cXyz(); -extern "C" void CrossY__8cM3dGAabCFPC4cXyz(); -extern "C" void UnderPlaneYUnder__8cM3dGAabCFf(); -extern "C" void TopPlaneYUnder__8cM3dGAabCFf(); -extern "C" void ClearForMinMax__8cM3dGAabFv(); -extern "C" void SetMinMax__8cM3dGAabFRC4cXyz(); -extern "C" void SetMinMax__8cM3dGAabFRC8cM3dGAab(); -extern "C" void SetMin__8cM3dGAabFRC4cXyz(); -extern "C" void SetMax__8cM3dGAabFRC4cXyz(); -extern "C" void CalcCenter__8cM3dGAabCFP4cXyz(); -extern "C" void PlusR__8cM3dGAabFf(); - -// -// External References: -// - -extern "C" void PSVECAdd(); -extern "C" void PSVECScale(); +#include "mtx_vec.h" // // Declarations: // /* 8026EC54-8026EC88 0034+00 s=0 e=4 z=0 None .text Set__8cM3dGAabFPC4cXyzPC4cXyz */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGAab::Set(cXyz const* param_0, cXyz const* param_1) { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_aab/Set__8cM3dGAabFPC4cXyzPC4cXyz.s" +void cM3dGAab::Set(const cXyz* pMin, const cXyz* pMax) { + mMin = *pMin; + mMax = *pMax; } -#pragma pop /* 8026EC88-8026ECD0 0048+00 s=0 e=6 z=0 None .text CrossY__8cM3dGAabCFPC4cXyz */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGAab::CrossY(cXyz const* param_0) const { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_aab/CrossY__8cM3dGAabCFPC4cXyz.s" +bool cM3dGAab::CrossY(const cXyz* pOther) const { + if (mMin.x > pOther->x || mMax.x < pOther->x || mMin.z > pOther->z || mMax.z < pOther->z) { + return false; + } else { + return true; + } } -#pragma pop /* 8026ECD0-8026ECE4 0014+00 s=0 e=6 z=0 None .text UnderPlaneYUnder__8cM3dGAabCFf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGAab::UnderPlaneYUnder(f32 param_0) const { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_aab/UnderPlaneYUnder__8cM3dGAabCFf.s" +bool cM3dGAab::UnderPlaneYUnder(f32 pY) const { + return mMin.y < pY; } -#pragma pop /* 8026ECE4-8026ECF8 0014+00 s=0 e=6 z=0 None .text TopPlaneYUnder__8cM3dGAabCFf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGAab::TopPlaneYUnder(f32 param_0) const { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_aab/TopPlaneYUnder__8cM3dGAabCFf.s" +bool cM3dGAab::TopPlaneYUnder(f32 pY) const { + return mMax.y < pY; } -#pragma pop - -/* ############################################################################################## */ -/* 804551D0-804551D4 0004+00 s=1 e=0 z=0 None .sdata2 @416 */ -SECTION_SDATA2 static f32 lit_416 = 1000000000.0f; - -/* 804551D4-804551D8 0004+00 s=1 e=0 z=0 None .sdata2 @417 */ -SECTION_SDATA2 static f32 lit_417 = -1000000000.0f; /* 8026ECF8-8026ED1C 0024+00 s=0 e=6 z=0 None .text ClearForMinMax__8cM3dGAabFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGAab::ClearForMinMax() { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_aab/ClearForMinMax__8cM3dGAabFv.s" +void cM3dGAab::ClearForMinMax(void) { + mMin.setAll(1000000000.0f); + mMax.setAll(-1000000000.0f); } -#pragma pop /* 8026ED1C-8026ED60 0044+00 s=1 e=3 z=0 None .text SetMinMax__8cM3dGAabFRC4cXyz */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGAab::SetMinMax(cXyz const& param_0) { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_aab/SetMinMax__8cM3dGAabFRC4cXyz.s" +void cM3dGAab::SetMinMax(const cXyz& pMinMax) { + this->SetMin(pMinMax); + this->SetMax(pMinMax); } -#pragma pop /* 8026ED60-8026EDA4 0044+00 s=0 e=2 z=0 None .text SetMinMax__8cM3dGAabFRC8cM3dGAab */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGAab::SetMinMax(cM3dGAab const& param_0) { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_aab/SetMinMax__8cM3dGAabFRC8cM3dGAab.s" +void cM3dGAab::SetMinMax(const cM3dGAab& pOther) { + this->SetMinMax(pOther.mMin); + this->SetMinMax(pOther.mMax); } -#pragma pop /* 8026EDA4-8026EDE4 0040+00 s=1 e=1 z=0 None .text SetMin__8cM3dGAabFRC4cXyz */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGAab::SetMin(cXyz const& param_0) { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_aab/SetMin__8cM3dGAabFRC4cXyz.s" +void cM3dGAab::SetMin(const cXyz& pMin) { + mMin.setMin(pMin); } -#pragma pop /* 8026EDE4-8026EE24 0040+00 s=1 e=1 z=0 None .text SetMax__8cM3dGAabFRC4cXyz */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGAab::SetMax(cXyz const& param_0) { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_aab/SetMax__8cM3dGAabFRC4cXyz.s" +void cM3dGAab::SetMax(const cXyz& pMax) { + mMax.setMax(pMax); } -#pragma pop - -/* ############################################################################################## */ -/* 804551D8-804551E0 0004+04 s=1 e=0 z=0 None .sdata2 @493 */ -SECTION_SDATA2 static f32 lit_493[1 + 1 /* padding */] = { - 0.5f, - /* padding */ - 0.0f, -}; - /* 8026EE24-8026EE68 0044+00 s=0 e=1 z=0 None .text CalcCenter__8cM3dGAabCFP4cXyz */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGAab::CalcCenter(cXyz* param_0) const { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_aab/CalcCenter__8cM3dGAabCFP4cXyz.s" +void cM3dGAab::CalcCenter(cXyz* pOut) const { + PSVECAdd(&mMin, &mMax, pOut); + PSVECScale(pOut, pOut, 0.5f); } -#pragma pop /* 8026EE68-8026EEB4 004C+00 s=0 e=1 z=0 None .text PlusR__8cM3dGAabFf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGAab::PlusR(f32 param_0) { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_aab/PlusR__8cM3dGAabFf.s" +void cM3dGAab::PlusR(f32 pR) { + mMin -= pR; + mMax += pR; } -#pragma pop diff --git a/libs/SSystem/SComponent/c_m3d_g_cir.cpp b/libs/SSystem/SComponent/c_m3d_g_cir.cpp index cf98c105d97..7472fca065f 100644 --- a/libs/SSystem/SComponent/c_m3d_g_cir.cpp +++ b/libs/SSystem/SComponent/c_m3d_g_cir.cpp @@ -7,92 +7,29 @@ #include "dol2asm.h" #include "dolphin/types.h" -// -// Types: -// - -struct cM3dGCir { - /* 8026EEB4 */ cM3dGCir(); - /* 8026EF18 */ ~cM3dGCir(); - /* 8026EF74 */ void Set(f32, f32, f32, f32); -}; - -struct cM2dGCir { - /* 8026EED0 */ ~cM2dGCir(); -}; - -// -// Forward References: -// - -extern "C" void __ct__8cM3dGCirFv(); -extern "C" void __dt__8cM2dGCirFv(); -extern "C" void __dt__8cM3dGCirFv(); -extern "C" void Set__8cM3dGCirFffff(); - // // External References: // void operator delete(void*); -extern "C" void __dl__FPv(); - // // Declarations: // -/* ############################################################################################## */ -/* 803C3FE0-803C3FEC 000C+00 s=2 e=0 z=0 None .data __vt__8cM3dGCir */ -SECTION_DATA static void* __vt__8cM3dGCir[3] = { - (void*)NULL, - (void*)NULL, - (void*)__dt__8cM3dGCirFv, -}; - -/* 803C3FEC-803C3FF8 000C+00 s=3 e=0 z=0 None .data __vt__8cM2dGCir */ -SECTION_DATA static void* __vt__8cM2dGCir[3] = { - (void*)NULL, - (void*)NULL, - (void*)__dt__8cM2dGCirFv, -}; - /* 8026EEB4-8026EED0 001C+00 s=0 e=1 z=0 None .text __ct__8cM3dGCirFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm cM3dGCir::cM3dGCir() { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_cir/__ct__8cM3dGCirFv.s" -} -#pragma pop +cM3dGCir::cM3dGCir(void) {} /* 8026EED0-8026EF18 0048+00 s=1 e=0 z=0 None .text __dt__8cM2dGCirFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm cM2dGCir::~cM2dGCir() { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_cir/__dt__8cM2dGCirFv.s" -} -#pragma pop +// cM2dGCir::~cM2dGCir() autogenerated here /* 8026EF18-8026EF74 005C+00 s=1 e=4 z=386 None .text __dt__8cM3dGCirFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm cM3dGCir::~cM3dGCir() { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_cir/__dt__8cM3dGCirFv.s" -} -#pragma pop +cM3dGCir::~cM3dGCir(void) {} /* 8026EF74-8026EF88 0014+00 s=0 e=1 z=0 None .text Set__8cM3dGCirFffff */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGCir::Set(f32 param_0, f32 param_1, f32 param_2, f32 param_3) { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_cir/Set__8cM3dGCirFffff.s" +void cM3dGCir::Set(f32 pPosX, f32 pPosY, f32 pPosZ, f32 pRadius) { + mPosX = pPosX; + mPosY = pPosY; + mRadius = pRadius; + mPosZ = pPosZ; } -#pragma pop diff --git a/libs/SSystem/SComponent/c_m3d_g_cps.cpp b/libs/SSystem/SComponent/c_m3d_g_cps.cpp index 51858ec6426..d531e5236ba 100644 --- a/libs/SSystem/SComponent/c_m3d_g_cps.cpp +++ b/libs/SSystem/SComponent/c_m3d_g_cps.cpp @@ -3,7 +3,7 @@ // Translation Unit: c_m3d_g_cps // -#include "SSystem/SComponent/c_m3d_g_cps.h" +// #include "SSystem/SComponent/c_m3d_g_cps.h" #include "dol2asm.h" #include "dolphin/types.h" diff --git a/libs/SSystem/SComponent/c_m3d_g_lin.cpp b/libs/SSystem/SComponent/c_m3d_g_lin.cpp index 3597b6f96cb..65f3a0b5499 100644 --- a/libs/SSystem/SComponent/c_m3d_g_lin.cpp +++ b/libs/SSystem/SComponent/c_m3d_g_lin.cpp @@ -7,22 +7,6 @@ #include "dol2asm.h" #include "dolphin/types.h" -// -// Types: -// - -struct cXyz {}; - -struct Vec {}; - -struct cM3dGLin { - /* 8026F2A8 */ cM3dGLin(cXyz const&, cXyz const&); - /* 8026F2E8 */ void SetStartEnd(cXyz const&, cXyz const&); - /* 8026F31C */ void SetStartEnd(Vec const&, Vec const&); - /* 8026F350 */ void CalcPos(Vec*, f32) const; - /* 8026F3C0 */ void SetEnd(cXyz const&); -}; - // // Forward References: // @@ -37,9 +21,6 @@ extern "C" void SetEnd__8cM3dGLinFRC4cXyz(); // External References: // -extern "C" void PSVECAdd(); -extern "C" void PSVECSubtract(); -extern "C" void PSVECScale(); extern "C" extern void* __vt__8cM3dGLin[3]; // @@ -57,41 +38,26 @@ asm cM3dGLin::cM3dGLin(cXyz const& param_0, cXyz const& param_1) { #pragma pop /* 8026F2E8-8026F31C 0034+00 s=0 e=8 z=10 None .text SetStartEnd__8cM3dGLinFRC4cXyzRC4cXyz */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGLin::SetStartEnd(cXyz const& param_0, cXyz const& param_1) { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_lin/SetStartEnd__8cM3dGLinFRC4cXyzRC4cXyz.s" +void cM3dGLin::SetStartEnd(const cXyz& pStart, const cXyz& pEnd) { + mStart = pStart; + mEnd = pEnd; } -#pragma pop /* 8026F31C-8026F350 0034+00 s=0 e=7 z=4 None .text SetStartEnd__8cM3dGLinFRC3VecRC3Vec */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGLin::SetStartEnd(Vec const& param_0, Vec const& param_1) { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_lin/SetStartEnd__8cM3dGLinFRC3VecRC3Vec.s" +void cM3dGLin::SetStartEnd(const Vec& pStart, const Vec& pEnd) { + mStart = pStart; + mEnd = pEnd; } -#pragma pop /* 8026F350-8026F3C0 0070+00 s=0 e=3 z=0 None .text CalcPos__8cM3dGLinCFP3Vecf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGLin::CalcPos(Vec* param_0, f32 param_1) const { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_lin/CalcPos__8cM3dGLinCFP3Vecf.s" +void cM3dGLin::CalcPos(Vec* pOut, f32 pScale) const { + Vec tmp; + PSVECSubtract(&mEnd, &mStart, &tmp); + PSVECScale(&tmp, &tmp, pScale); + PSVECAdd(&tmp, &mStart, pOut); } -#pragma pop /* 8026F3C0-8026F3DC 001C+00 s=0 e=1 z=0 None .text SetEnd__8cM3dGLinFRC4cXyz */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cM3dGLin::SetEnd(cXyz const& param_0) { - nofralloc -#include "asm/SSystem/SComponent/c_m3d_g_lin/SetEnd__8cM3dGLinFRC4cXyz.s" +void cM3dGLin::SetEnd(const cXyz& pEnd) { + mEnd = pEnd; } -#pragma pop