summaryrefslogtreecommitdiff
path: root/libs/SSystem
diff options
context:
space:
mode:
authorlepelog <lepelog@users.noreply.github.com>2021-01-26 23:48:47 +0100
committerGitHub <noreply@github.com>2021-01-26 17:48:47 -0500
commit1e105b87f104badeadcb1d2b0ddbdff1310eb5be (patch)
tree7e923852259e9eaccf0a4835ad0adb8240d251af /libs/SSystem
parentb8d0da505dcad87937ef261961f5b454c7f4fbee (diff)
some c_m3d (#97)
* decompiled some bgs_chk funcs * c_m3d_g * c_math progress * remove duplicate SComponent headers * move some variables and decompile a function * some inlined from debug * cM3d_2PlaneLinePosNearPos * fix fabsf and decompile cM3d_CrawVec * format * cleanup * more cleanup Co-authored-by: Pheenoh <pheenoh@gmail.com>
Diffstat (limited to 'libs/SSystem')
-rw-r--r--libs/SSystem/SComponent/c_bg_s_chk.cpp30
-rw-r--r--libs/SSystem/SComponent/c_bg_s_gnd_chk.cpp4
-rw-r--r--libs/SSystem/SComponent/c_bg_s_lin_chk.cpp4
-rw-r--r--libs/SSystem/SComponent/c_bg_s_poly_info.cpp70
-rw-r--r--libs/SSystem/SComponent/c_bg_s_shdw_draw.cpp4
-rw-r--r--libs/SSystem/SComponent/c_m2d.cpp10
-rw-r--r--libs/SSystem/SComponent/c_m3d.cpp654
-rw-r--r--libs/SSystem/SComponent/c_m3d_g_aab.cpp82
-rw-r--r--libs/SSystem/SComponent/c_m3d_g_cir.cpp30
-rw-r--r--libs/SSystem/SComponent/c_m3d_g_cps.cpp32
-rw-r--r--libs/SSystem/SComponent/c_m3d_g_cyl.cpp67
-rw-r--r--libs/SSystem/SComponent/c_m3d_g_lin.cpp37
-rw-r--r--libs/SSystem/SComponent/c_m3d_g_pla.cpp64
-rw-r--r--libs/SSystem/SComponent/c_m3d_g_sph.cpp51
-rw-r--r--libs/SSystem/SComponent/c_m3d_g_tri.cpp34
-rw-r--r--libs/SSystem/SComponent/c_sxyz.cpp7
-rw-r--r--libs/SSystem/SComponent/c_xyz.cpp22
17 files changed, 790 insertions, 412 deletions
diff --git a/libs/SSystem/SComponent/c_bg_s_chk.cpp b/libs/SSystem/SComponent/c_bg_s_chk.cpp
index 7fbec11fc9..5ff94b7a8b 100644
--- a/libs/SSystem/SComponent/c_bg_s_chk.cpp
+++ b/libs/SSystem/SComponent/c_bg_s_chk.cpp
@@ -3,26 +3,28 @@
#include "SComponent/c_bg_s_chk.h"
// __ct__8cBgS_ChkFv
-asm cBgS_Chk::cBgS_Chk(void) {
- nofralloc
-#include "SComponent/c_bg_s_chk/asm/func_80267B4C.s"
+cBgS_Chk::cBgS_Chk(void) {
+ unk_0x00 = 0;
+ unk_0x04 = 0;
+ unk_0x0C = 1;
}
// __dt__8cBgS_ChkFv
-asm cBgS_Chk::~cBgS_Chk(void) {
- nofralloc
-#include "SComponent/c_bg_s_chk/asm/func_80267B70.s"
-}
+cBgS_Chk::~cBgS_Chk(void) {}
// SetExtChk__8cBgS_ChkFR8cBgS_Chk
-asm void cBgS_Chk::SetExtChk(cBgS_Chk&) {
- nofralloc
-#include "SComponent/c_bg_s_chk/asm/func_80267BB8.s"
+void cBgS_Chk::SetExtChk(cBgS_Chk& pOther) {
+ unk_0x00 = pOther.unk_0x00;
+ unk_0x04 = pOther.unk_0x04;
+ unk_0x08 = pOther.unk_0x08;
+ unk_0x0C = pOther.unk_0x0C;
}
// ChkSameActorPid__8cBgS_ChkCFUi
-// cBgS_Chk::ChkSameActorPid(unsigned int) const
-asm bool cBgS_Chk::ChkSameActorPid(unsigned int) const {
- nofralloc
-#include "SComponent/c_bg_s_chk/asm/func_80267BDC.s"
+bool cBgS_Chk::ChkSameActorPid(unsigned int pUint) const {
+ if (unk_0x08 == -1 || pUint == UINT32_MAX || unk_0x0C == 0) {
+ return 0;
+ } else {
+ return (unk_0x08 == pUint) ? 1 : 0;
+ }
}
diff --git a/libs/SSystem/SComponent/c_bg_s_gnd_chk.cpp b/libs/SSystem/SComponent/c_bg_s_gnd_chk.cpp
index 7b584c5ea1..b2c637c7fd 100644
--- a/libs/SSystem/SComponent/c_bg_s_gnd_chk.cpp
+++ b/libs/SSystem/SComponent/c_bg_s_gnd_chk.cpp
@@ -2,6 +2,10 @@
#include "SComponent/c_bg_s_gnd_chk.h"
+// additional symbols needed for c_bg_s_gnd_chk.cpp
+// autogenerated by split.py v0.3 at 2020-12-31 14:10:48.795807
+extern u8 lbl_803C3F90;
+
// __ct__11cBgS_GndChkFv
asm cBgS_GndChk::cBgS_GndChk(void) {
nofralloc
diff --git a/libs/SSystem/SComponent/c_bg_s_lin_chk.cpp b/libs/SSystem/SComponent/c_bg_s_lin_chk.cpp
index a4e4efd0fa..b09963b075 100644
--- a/libs/SSystem/SComponent/c_bg_s_lin_chk.cpp
+++ b/libs/SSystem/SComponent/c_bg_s_lin_chk.cpp
@@ -2,6 +2,10 @@
#include "SComponent/c_bg_s_lin_chk.h"
+// additional symbols needed for c_bg_s_lin_chk.cpp
+// autogenerated by split.py v0.3 at 2021-01-01 12:56:44.686018
+extern u8 lbl_803C3FA8;
+
// __ct__11cBgS_LinChkFv
// cBgS_LinChk::cBgS_LinChk(void)
asm cBgS_LinChk::cBgS_LinChk(void) {
diff --git a/libs/SSystem/SComponent/c_bg_s_poly_info.cpp b/libs/SSystem/SComponent/c_bg_s_poly_info.cpp
index 859cd3d2d0..b5ef983681 100644
--- a/libs/SSystem/SComponent/c_bg_s_poly_info.cpp
+++ b/libs/SSystem/SComponent/c_bg_s_poly_info.cpp
@@ -3,64 +3,60 @@
#include "SComponent/c_bg_s_poly_info.h"
// __ct__13cBgS_PolyInfoFv
-// cBgS_PolyInfo::cBgS_PolyInfo(void)
-asm cBgS_PolyInfo::cBgS_PolyInfo(void) {
- nofralloc
-#include "SComponent/c_bg_s_poly_info/asm/func_80268074.s"
+cBgS_PolyInfo::cBgS_PolyInfo(void) {
+ this->ClearPi();
}
// __dt__13cBgS_PolyInfoFv
-// cBgS_PolyInfo::~cBgS_PolyInfo(void)
-asm cBgS_PolyInfo::~cBgS_PolyInfo(void) {
- nofralloc
-#include "SComponent/c_bg_s_poly_info/asm/func_802680B0.s"
-}
+cBgS_PolyInfo::~cBgS_PolyInfo(void) {}
// ChkSetInfo__13cBgS_PolyInfoCFv
-// cBgS_PolyInfo::ChkSetInfo(void) const
-asm bool cBgS_PolyInfo::ChkSetInfo(void) const {
- nofralloc
-#include "SComponent/c_bg_s_poly_info/asm/func_802680F8.s"
+bool cBgS_PolyInfo::ChkSetInfo(void) const {
+ if (mPolyIndex == 0xFFFF || unk_0x02 == 0x100) {
+ return false;
+ } else {
+ return true;
+ }
}
// ClearPi__13cBgS_PolyInfoFv
-// cBgS_PolyInfo::ClearPi(void)
-asm void cBgS_PolyInfo::ClearPi(void) {
- nofralloc
-#include "SComponent/c_bg_s_poly_info/asm/func_80268120.s"
+void cBgS_PolyInfo::ClearPi(void) {
+ mPolyIndex = 0xFFFF;
+ unk_0x02 = 0x100;
+ unk_0x04 = 0;
+ unk_0x08 = -1;
}
// SetPolyInfo__13cBgS_PolyInfoFRC13cBgS_PolyInfo
-// cBgS_PolyInfo::SetPolyInfo(const cBgS_PolyInfo&)
-asm void cBgS_PolyInfo::SetPolyInfo(const cBgS_PolyInfo&) {
- nofralloc
-#include "SComponent/c_bg_s_poly_info/asm/func_80268148.s"
+void cBgS_PolyInfo::SetPolyInfo(const cBgS_PolyInfo& pOther) {
+ mPolyIndex = pOther.mPolyIndex;
+ unk_0x02 = pOther.unk_0x02;
+ unk_0x04 = pOther.unk_0x04;
+ unk_0x08 = pOther.unk_0x08;
}
// SetActorInfo__13cBgS_PolyInfoFiPvUi
-// cBgS_PolyInfo::SetActorInfo(int, void*, unsigned int)
-asm void cBgS_PolyInfo::SetActorInfo(int, void*, unsigned int) {
- nofralloc
-#include "SComponent/c_bg_s_poly_info/asm/func_8026816C.s"
+void cBgS_PolyInfo::SetActorInfo(int param_1, void* param_2, unsigned int param_3) {
+ unk_0x02 = param_1;
+ unk_0x04 = param_2;
+ unk_0x08 = param_3;
}
// ChkSafe__13cBgS_PolyInfoCFPCvUi
-// cBgS_PolyInfo::ChkSafe(const void*, unsigned int) const
-asm bool cBgS_PolyInfo::ChkSafe(const void*, unsigned int) const {
- nofralloc
-#include "SComponent/c_bg_s_poly_info/asm/func_8026817C.s"
+bool cBgS_PolyInfo::ChkSafe(const void* param_1, unsigned int param_2) const {
+ if (unk_0x04 == param_1 && unk_0x08 == param_2) {
+ return true;
+ } else {
+ return false;
+ }
}
// SetPolyIndex__13cBgS_PolyInfoFi
-// cBgS_PolyInfo::SetPolyIndex(int)
-asm void cBgS_PolyInfo::SetPolyIndex(int) {
- nofralloc
-#include "SComponent/c_bg_s_poly_info/asm/func_802681A4.s"
+void cBgS_PolyInfo::SetPolyIndex(int pPolyIndex) {
+ mPolyIndex = pPolyIndex;
}
// ChkBgIndex__13cBgS_PolyInfoCFv
-// cBgS_PolyInfo::ChkBgIndex(void) const
-asm bool cBgS_PolyInfo::ChkBgIndex(void) const {
- nofralloc
-#include "SComponent/c_bg_s_poly_info/asm/func_802681AC.s"
+bool cBgS_PolyInfo::ChkBgIndex(void) const {
+ return unk_0x02 != 0x100;
}
diff --git a/libs/SSystem/SComponent/c_bg_s_shdw_draw.cpp b/libs/SSystem/SComponent/c_bg_s_shdw_draw.cpp
index df247b35b7..f4e4e0bb67 100644
--- a/libs/SSystem/SComponent/c_bg_s_shdw_draw.cpp
+++ b/libs/SSystem/SComponent/c_bg_s_shdw_draw.cpp
@@ -2,6 +2,10 @@
#include "SComponent/c_bg_s_shdw_draw.h"
+// additional symbols needed for c_bg_s_shdw_draw.cpp
+// autogenerated by split.py v0.3 at 2021-01-01 13:07:28.433195
+extern u8 lbl_803C3FC0;
+
// __ct__13cBgS_ShdwDrawFv
// cBgS_ShdwDraw::cBgS_ShdwDraw(void)
asm cBgS_ShdwDraw::cBgS_ShdwDraw(void) {
diff --git a/libs/SSystem/SComponent/c_m2d.cpp b/libs/SSystem/SComponent/c_m2d.cpp
index 25b8536564..66c1b14602 100644
--- a/libs/SSystem/SComponent/c_m2d.cpp
+++ b/libs/SSystem/SComponent/c_m2d.cpp
@@ -2,6 +2,16 @@
#include "SComponent/c_m2d.h"
+// additional symbols needed for c_m2d.cpp
+// autogenerated by split.py v0.3 at 2021-01-01 14:23:08.023070
+extern u8 lbl_80455110;
+extern u8 lbl_80455100;
+extern u8 lbl_80455108;
+extern u8 lbl_804550FC;
+extern u8 lbl_804550F8;
+extern u8 lbl_804550F4;
+extern u8 lbl_804550F0;
+
// cM2d_CrossCirLin__FR8cM2dGCirffffPfPf
asm void cM2d_CrossCirLin(cM2dGCir&, float, float, float, float, float*, float*) {
nofralloc
diff --git a/libs/SSystem/SComponent/c_m3d.cpp b/libs/SSystem/SComponent/c_m3d.cpp
index 738037d38b..71323eb868 100644
--- a/libs/SSystem/SComponent/c_m3d.cpp
+++ b/libs/SSystem/SComponent/c_m3d.cpp
@@ -2,111 +2,351 @@
#include "SComponent/c_m3d.h"
+extern f32 lbl_80455118; // SComponent::@2256, 0.0
+extern f32 lbl_80455138; // SComponent::@2273, 1.0
+extern f32 lbl_8045513C; // SComponent::@2346, 0.02
+extern f32 lbl_804551C4; // SComponent::@3892, 0.5
+
+// additional symbols needed for c_m3d.cpp
+// autogenerated by split.py v0.3 at 2021-01-01 14:58:45.990799
+extern u8 lbl_80455158;
+extern u8 lbl_80455180;
+extern u8 lbl_80455128;
+extern u8 lbl_80455190;
+extern u8 lbl_804551BC;
+extern u8 lbl_80455168;
+extern u8 lbl_804551C8;
+extern u8 lbl_804551B8;
+extern u8 lbl_80455148;
+extern u8 lbl_80455170;
+extern u8 lbl_80455150;
+extern u8 lbl_80455198;
+extern u8 lbl_8045519C;
+extern u8 lbl_8045515C;
+extern u8 lbl_804551A0;
+extern u8 lbl_80455174;
+extern u8 lbl_80455178;
+extern u8 lbl_804551CC;
+extern u8 lbl_80450AEC;
+extern u8 lbl_8045516C;
+extern u8 lbl_80455194;
+extern u8 lbl_804551C0;
+extern u8 lbl_80455188;
+extern u8 lbl_80455164;
+extern u8 lbl_804551AC;
+extern u8 lbl_8045517C;
+extern u8 lbl_80455130;
+extern u8 lbl_804551A4;
+extern u8 lbl_8045514C;
+extern u8 lbl_80455120;
+extern u8 lbl_804551B4;
+extern u8 lbl_804551A8;
+extern u8 lbl_80455184;
+extern u8 lbl_80455144;
+extern u8 lbl_80455140;
+extern u8 lbl_8045518C;
+extern u8 lbl_80455154;
+extern u8 lbl_804551B0;
+extern u8 lbl_80455160;
+
// cM3d_InDivPos1__FPC3VecPC3VecfP3Vec
-// cM3d_InDivPos1(const Vec*, const Vec*, float, Vec*)
-asm void cM3d_InDivPos1(const Vec*, const Vec*, float, Vec*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_80268560.s"
+void cM3d_InDivPos1(const Vec* pVecA, const Vec* pVecB, f32 pF, Vec* pOut) {
+ Vec tmp;
+ PSVECScale(pVecB, &tmp, pF);
+ PSVECAdd(&tmp, pVecA, pOut);
}
// cM3d_InDivPos2__FPC3VecPC3VecfP3Vec
-// cM3d_InDivPos2(const Vec*, const Vec*, float, Vec*)
-asm void cM3d_InDivPos2(const Vec*, const Vec*, float, Vec*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_802685B0.s"
+void cM3d_InDivPos2(const Vec* pVecA, const Vec* pVecB, f32 pF, Vec* pOut) {
+ Vec tmp;
+ PSVECSubtract(pVecB, pVecA, &tmp);
+ cM3d_InDivPos1(pVecA, &tmp, pF, pOut);
}
// cM3d_Len2dSq__Fffff
-// cM3d_Len2dSq(float, float, float, float)
-asm float cM3d_Len2dSq(float, float, float, float) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_80268614.s"
+f32 cM3d_Len2dSq(f32 pX1, f32 pY1, f32 pX2, f32 pY2) {
+ f32 xDiff = pX1 - pX2;
+ f32 yDiff = pY1 - pY2;
+ return xDiff * xDiff + yDiff * yDiff;
+}
+
+inline bool cM3d_IsZero(f32 pF) {
+ return fabsf(pF) < lbl_80451180;
}
// cM3d_Len2dSqPntAndSegLine__FffffffPfPfPf
-// cM3d_Len2dSqPntAndSegLine(float, float, float, float, float, float, float*, float*, float*)
-asm bool cM3d_Len2dSqPntAndSegLine(float, float, float, float, float, float, float*, float*,
- float*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026862C.s"
+bool cM3d_Len2dSqPntAndSegLine(f32 param_1, f32 param_2, f32 param_3, f32 param_4, f32 p5, f32 p6,
+ f32* param_7, f32* param_8, f32* param_9) {
+ bool retVal = false;
+ f32 param_5 = p5 - param_3;
+ f32 param_6 = p6 - param_4;
+ f32 len = param_5 * param_5 + param_6 * param_6;
+ if (cM3d_IsZero(len)) {
+ *param_9 = /* 0.0 */ lbl_80455118;
+ return retVal;
+ } else {
+ len = (param_5 * (param_1 - param_3) + param_6 * (param_2 - param_4)) / len;
+ if (len >= /* 0.0 */ lbl_80455118 && len <= /* 1.0 */ lbl_80455138) {
+ retVal = true;
+ }
+ *param_7 = param_3 + param_5 * len;
+ *param_8 = param_4 + param_6 * len;
+ *param_9 = cM3d_Len2dSq(*param_7, *param_8, param_1, param_2);
+ return retVal;
+ }
}
// cM3d_Len3dSqPntAndSegLine__FPC8cM3dGLinPC3VecP3VecPf
-// cM3d_Len3dSqPntAndSegLine(const cM3dGLin*, const Vec*, Vec*, float*)
-asm bool cM3d_Len3dSqPntAndSegLine(const cM3dGLin*, const Vec*, Vec*, float*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_80268710.s"
+bool cM3d_Len3dSqPntAndSegLine(const cM3dGLin* pLine, const Vec* pVec, Vec* pOutVec, f32* pOutF) {
+ bool retVal = 0;
+ Vec tmp;
+ PSVECSubtract(&pLine->GetEndP(), &pLine->GetStartP(), &tmp);
+ f32 seqLen = PSVECDotProduct(&tmp, &tmp);
+ if (cM3d_IsZero(seqLen)) {
+ *pOutF = /* 0.0 */ lbl_80455118;
+ return retVal;
+ } else {
+ Vec tmp2;
+ PSVECSubtract(pVec, &pLine->GetStartP(), &tmp2);
+ f32 tmpF = PSVECDotProduct(&tmp2, &tmp);
+ tmpF /= seqLen;
+ if (tmpF < /* 0.0 */ lbl_80455118 || tmpF > /* 1.0 */ lbl_80455138) {
+ retVal = false;
+ } else {
+ retVal = true;
+ }
+ PSVECScale(&tmp, &tmp, tmpF);
+ PSVECAdd(&tmp, &pLine->GetStartP(), pOutVec);
+ *pOutF = PSVECSquareDistance(pOutVec, pVec);
+ return retVal;
+ }
}
// cM3d_SignedLenPlaAndPos__FPC8cM3dGPlaPC3Vec
-// cM3d_SignedLenPlaAndPos(const cM3dGPla*, const Vec*)
-asm float cM3d_SignedLenPlaAndPos(const cM3dGPla*, const Vec*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_80268814.s"
+f32 cM3d_SignedLenPlaAndPos(const cM3dGPla* pPlane, const Vec* pPosition) {
+ f32 mag = PSVECMag(&pPlane->GetNP());
+ if (cM3d_IsZero(mag)) {
+ return /* 0.0 */ lbl_80455118;
+ } else {
+ return (pPlane->mD + PSVECDotProduct(&pPlane->GetNP(), pPosition)) / mag;
+ }
}
// cM3d_VectorProduct2d__Fffffff
-// cM3d_VectorProduct2d(float, float, float, float, float, float)
-asm float cM3d_VectorProduct2d(float, float, float, float, float, float) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_80268894.s"
+f32 cM3d_VectorProduct2d(f32 pX1, f32 pY1, f32 pX2, f32 pY2, f32 pX3, f32 pY3) {
+ return (pX2 - pX1) * (pY3 - pY1) - (pY2 - pY1) * (pX3 - pX1);
}
// cM3d_VectorProduct__FPC4cXyzPC4cXyzPC4cXyzP4cXyz
-// cM3d_VectorProduct(const cXyz*, const cXyz*, const cXyz*, cXyz*)
-asm void cM3d_VectorProduct(const cXyz*, const cXyz*, const cXyz*, cXyz*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_802688B4.s"
+void cM3d_VectorProduct(const cXyz* pVecA, const cXyz* pVecB, const cXyz* pVecC, cXyz* pVecOut) {
+ Vec tmp1;
+ Vec tmp2;
+ PSVECSubtract(pVecB, pVecA, &tmp1);
+ PSVECSubtract(pVecC, pVecA, &tmp2);
+ PSVECCrossProduct(&tmp1, &tmp2, pVecOut);
}
// cM3d_CalcPla__FPC3VecPC3VecPC3VecP3VecPf
-// cM3d_CalcPla(const Vec*, const Vec*, const Vec*, Vec*, float*)
-asm void cM3d_CalcPla(const Vec*, const Vec*, const Vec*, Vec*, float*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026891C.s"
+void cM3d_CalcPla(const Vec* pVecA, const Vec* pVecB, const Vec* pVecC, Vec* pVecOut, f32* pD) {
+ Vec tmp2;
+ Vec tmp1;
+ PSVECSubtract(pVecB, pVecA, &tmp1);
+ PSVECSubtract(pVecC, pVecA, &tmp2);
+ PSVECCrossProduct(&tmp1, &tmp2, pVecOut);
+ f32 mag = PSVECMag(pVecOut);
+ if (fabsf(mag) >= /* 0.02 */ lbl_8045513C) {
+ PSVECScale(pVecOut, pVecOut, /* 1.0 */ lbl_80455138 / mag);
+ *pD = -PSVECDotProduct(pVecOut, pVecA);
+ } else {
+ f32 zero = /* 0.0 */ lbl_80455118;
+ pVecOut->y = zero;
+ *pD = zero;
+ pVecOut->z = zero;
+ pVecOut->x = zero;
+ }
+}
+
+inline bool cM3d_CrossNumSection(f32 lMinX, f32 lMaxX, f32 rMinX, f32 rMaxX) {
+ if (lMinX > rMaxX) {
+ return false;
+ } else if (lMaxX < rMinX) {
+ return false;
+ } else if (rMinX > lMaxX) {
+ return false;
+ } else if (rMaxX < lMinX) {
+ return false;
+ } else {
+ return true;
+ }
}
// cM3d_Cross_AabAab__FPC8cM3dGAabPC8cM3dGAab
-// cM3d_Cross_AabAab(const cM3dGAab*, const cM3dGAab*)
-asm bool cM3d_Cross_AabAab(const cM3dGAab*, const cM3dGAab*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_802689E8.s"
+bool cM3d_Cross_AabAab(const cM3dGAab* pAabA, const cM3dGAab* pAabB) {
+ if (cM3d_CrossNumSection(pAabA->getMinP().x, pAabA->getMaxP().x, pAabB->getMinP().x,
+ pAabB->getMaxP().x) &&
+ cM3d_CrossNumSection(pAabA->getMinP().y, pAabA->getMaxP().y, pAabB->getMinP().y,
+ pAabB->getMaxP().y) &&
+ cM3d_CrossNumSection(pAabA->getMinP().z, pAabA->getMaxP().z, pAabB->getMinP().z,
+ pAabB->getMaxP().z)) {
+ return true;
+ } else {
+ return false;
+ }
}
// cM3d_Cross_AabCyl__FPC8cM3dGAabPC8cM3dGCyl
-// cM3d_Cross_AabCyl(const cM3dGAab*, const cM3dGCyl*)
-asm bool cM3d_Cross_AabCyl(const cM3dGAab*, const cM3dGCyl*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_80268B0C.s"
+bool cM3d_Cross_AabCyl(const cM3dGAab* pAab, const cM3dGCyl* pCyl) {
+ if (pAab->getMinP().x > pCyl->GetCP().x + pCyl->GetR()) {
+ return false;
+ } else if (pAab->getMaxP().x < pCyl->GetCP().x - pCyl->GetR()) {
+ return false;
+ } else if (pAab->getMinP().z > pCyl->GetCP().z + pCyl->GetR()) {
+ return false;
+ } else if (pAab->getMaxP().z < pCyl->GetCP().z - pCyl->GetR()) {
+ return false;
+ } else if (pAab->getMinP().y > pCyl->GetCP().y + pCyl->GetH()) {
+ return false;
+ } else if (pAab->getMaxP().y < pCyl->GetCP().y) {
+ return false;
+ } else {
+ return true;
+ }
}
// cM3d_Cross_AabSph__FPC8cM3dGAabPC8cM3dGSph
-// cM3d_Cross_AabSph(const cM3dGAab*, const cM3dGSph*)
+#ifdef NON_MATCHING
+bool cM3d_Cross_AabSph(const cM3dGAab* pAab, const cM3dGSph* pSph) {
+ f32 radius = pSph->GetR();
+ if (pAab->GetMinX() > pSph->GetC().GetX() + radius) { // addition registers are flipped
+ return false;
+ } else if (pAab->GetMaxX() < pSph->GetC().GetX() - radius) {
+ return false;
+ } else if (pAab->GetMinZ() > pSph->GetC().GetZ() + radius) {
+ return false;
+ } else if (pAab->GetMaxZ() < pSph->GetC().GetZ() - radius) {
+ return false;
+ } else if (pAab->GetMinY() > pSph->GetC().GetY() + radius) {
+ return false;
+ } else if (pAab->GetMaxY() < pSph->GetC().GetY() - radius) {
+ return false;
+ } else {
+ return true;
+ }
+}
+#else
asm bool cM3d_Cross_AabSph(const cM3dGAab*, const cM3dGSph*) {
nofralloc
#include "SComponent/c_m3d/asm/func_80268BB4.s"
}
+#endif
+#ifdef NON_MATCHING
// cM3d_Check_LinLin__FPC8cM3dGLinPC8cM3dGLinPfPf
-// cM3d_Check_LinLin(const cM3dGLin*, const cM3dGLin*, float*, float*)
-asm int cM3d_Check_LinLin(const cM3dGLin*, const cM3dGLin*, float*, float*) {
+int cM3d_Check_LinLin(const cM3dGLin* pLinA, const cM3dGLin* pLinB, f32* pFloatA, f32* pFloatB) {
+ Vec linAVec;
+ Vec linBVec;
+ pLinA->CalcVec(&linAVec);
+ pLinB->CalcVec(&linBVec);
+ f32 linALen = PSVECMag(&linAVec);
+ f32 linBLen = PSVECMag(&linBVec);
+ if (cM3d_IsZero(linALen) || cM3d_IsZero(linBLen)) {
+ return 1;
+ } else {
+ f32 invLinALen = /* 1.0 */ lbl_80455138 / linALen;
+ f32 invLinBLen = /* 1.0 */ lbl_80455138 / linBLen;
+ PSVECScale(&linAVec, &linAVec, invLinALen);
+ PSVECScale(&linBVec, &linBVec, invLinBLen);
+ Vec tmp;
+ PSVECSubtract(&pLinA->GetStartP(), &pLinB->GetStartP(), &tmp);
+ f32 tmpF = -PSVECDotProduct(&linAVec, &linBVec);
+ f32 tmpF2 = PSVECDotProduct(&tmp, &linAVec);
+ PSVECSquareMag(&tmp); // result not used
+ f32 tmpF3 = fabsf(/* 1.0 */ lbl_80455138 - (tmpF * tmpF));
+ if (!cM3d_IsZero(tmpF3)) {
+ f32 tmpF4 = -PSVECDotProduct(&tmp, &linBVec);
+ f32 tmpF7 = /* 1.0 */ lbl_80455138 / tmpF3;
+ f32 outFloatAtmp = ((tmpF * tmpF4) - tmpF2) * tmpF7;
+ *pFloatA = outFloatAtmp * invLinALen;
+ f32 outFloatBtmp = ((tmpF * tmpF2) - tmpF4) * tmpF7;
+ *pFloatB = outFloatBtmp * invLinBLen;
+ return 3;
+ } else {
+ f32 tmpF5 = -tmpF2;
+ f32 tmpF6 =
+ /* 0.0 */ lbl_80455118; // would match with literals instead of labels
+ if (tmpF5 < /* 0.0 */ lbl_80455118 || (tmpF5 > linALen)) {
+ tmpF6 = linBLen;
+ tmpF5 = (tmpF6 * tmpF) - tmpF2;
+ }
+ f32 tmpF7 = PSVECDotProduct(&tmp, &linBVec);
+ if (tmpF5 < /* 0.0 */ lbl_80455118 || tmpF5 > linALen) {
+ tmpF5 = /* 0.0 */ lbl_80455118;
+ tmpF6 = tmpF7;
+ }
+ if (tmpF6 < /* 0.0 */ lbl_80455118 || tmpF6 > linBLen) {
+ tmpF5 = linALen;
+ tmpF6 = tmpF7 + (-linALen * tmpF);
+ }
+ *pFloatA = tmpF5 * invLinALen;
+ *pFloatB = tmpF6 * invLinBLen;
+ return 2;
+ }
+ }
+}
+#else
+// cM3d_Check_LinLin(const cM3dGLin*, const cM3dGLin*, f32*, f32*)
+asm int cM3d_Check_LinLin(const cM3dGLin*, const cM3dGLin*, f32*, f32*) {
nofralloc
#include "SComponent/c_m3d/asm/func_80268C5C.s"
}
+#endif
// cM3d_CrossInfLineVsInfPlane_proc__FffPC3VecPC3VecP3Vec
-// cM3d_CrossInfLineVsInfPlane_proc(float, float, const Vec*, const Vec*, Vec*)
-asm bool cM3d_CrossInfLineVsInfPlane_proc(float, float, const Vec*, const Vec*, Vec*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_80268ED4.s"
+bool cM3d_CrossInfLineVsInfPlane_proc(f32 pFloatA, f32 pFloatB, const Vec* pVecA, const Vec* pVecB,
+ Vec* pVecOut) {
+ if (cM3d_IsZero(pFloatA - pFloatB)) {
+ *pVecOut = *pVecB;
+ return false;
+ } else {
+ cM3d_InDivPos2(pVecA, pVecB, pFloatA / (pFloatA - pFloatB), pVecOut);
+ return true;
+ }
}
// cM3d_Cross_LinPla__FPC8cM3dGLinPC8cM3dGPlaP3Vecbb
-// cM3d_Cross_LinPla(const cM3dGLin*, const cM3dGPla*, Vec*, bool, bool)
+#ifdef NON_MATCHING
+bool cM3d_Cross_LinPla(const cM3dGLin* pLine, const cM3dGPla* pPlane, Vec* pVecOut, bool pBoolA,
+ bool pBoolB) {
+ f32 startVal = pPlane->getPlaneFunc(&pLine->GetStartP());
+ f32 endVal = pPlane->getPlaneFunc(&pLine->GetEndP());
+ if (startVal * endVal > /* 0.0 */ lbl_80455118) {
+ // matches with the literal, but that screws up data
+ // if (startVal * endVal > 0) {
+ *pVecOut = pLine->GetEndP();
+ return false;
+ } else {
+ if (startVal >= /* 0.0 */ lbl_80455118 && endVal <= /* 0.0 */ lbl_80455118) {
+ // if (startVal >= 0 && endVal <= 0) {
+ if (pBoolA) {
+ return cM3d_CrossInfLineVsInfPlane_proc(startVal, endVal, &pLine->GetStartP(),
+ &pLine->GetEndP(), pVecOut);
+ }
+ } else {
+ if (pBoolB) {
+ return cM3d_CrossInfLineVsInfPlane_proc(startVal, endVal, &pLine->GetStartP(),
+ &pLine->GetEndP(), pVecOut);
+ }
+ }
+ *pVecOut = pLine->GetEndP();
+ return true;
+ }
+}
+#else
asm bool cM3d_Cross_LinPla(const cM3dGLin*, const cM3dGPla*, Vec*, bool, bool) {
nofralloc
#include "SComponent/c_m3d/asm/func_80268F34.s"
}
+#endif
// cM3d_Cross_MinMaxBoxLine__FPC3VecPC3VecPC3VecPC3Vec
// cM3d_Cross_MinMaxBoxLine(const Vec*, const Vec*, const Vec*, const Vec*)
@@ -116,23 +356,69 @@ asm bool cM3d_Cross_MinMaxBoxLine(const Vec*, const Vec*, const Vec*, const Vec*
}
// cM3d_InclusionCheckPosIn3PosBox3d__FPC3VecPC3VecPC3VecPC3Vecf
-// cM3d_InclusionCheckPosIn3PosBox3d(const Vec*, const Vec*, const Vec*, const Vec*, float)
-asm bool cM3d_InclusionCheckPosIn3PosBox3d(const Vec*, const Vec*, const Vec*, const Vec*, float) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_80269C2C.s"
+bool cM3d_InclusionCheckPosIn3PosBox3d(const Vec* pVecA, const Vec* pVecB, const Vec* pVecC,
+ const Vec* pVecD, f32 pF) {
+ f32 min, max;
+ if (pVecA->GetX() < pVecB->GetX()) {
+ min = pVecA->GetX();
+ max = pVecB->GetX();
+ } else {
+ min = pVecB->GetX();
+ max = pVecA->GetX();
+ }
+ if (min > pVecC->GetX()) {
+ min = pVecC->GetX();
+ } else if (max < pVecC->GetX()) {
+ max = pVecC->GetX();
+ }
+ if (min - pF > pVecD->GetX() || max + pF < pVecD->GetX()) {
+ return false;
+ }
+
+ if (pVecA->GetZ() < pVecB->GetZ()) {
+ min = pVecA->GetZ();
+ max = pVecB->GetZ();
+ } else {
+ min = pVecB->GetZ();
+ max = pVecA->GetZ();
+ }
+ if (min > pVecC->GetZ()) {
+ min = pVecC->GetZ();
+ } else if (max < pVecC->GetZ()) {
+ max = pVecC->GetZ();
+ }
+ if (min - pF > pVecD->GetZ() || max + pF < pVecD->GetZ()) {
+ return false;
+ }
+
+ if (pVecA->GetY() < pVecB->GetY()) {
+ min = pVecA->GetY();
+ max = pVecB->GetY();
+ } else {
+ min = pVecB->GetY();
+ max = pVecA->GetY();
+ }
+ if (min > pVecC->GetY()) {
+ min = pVecC->GetY();
+ } else if (max < pVecC->GetY()) {
+ max = pVecC->GetY();
+ }
+ if (min - pF > pVecD->GetY() || max + pF < pVecD->GetY()) {
+ return false;
+ }
+ return true;
}
// cM3d_InclusionCheckPosIn3PosBox2d__Ffffffffff
-// cM3d_InclusionCheckPosIn3PosBox2d(float, float, float, float, float, float, float, float, float)
-asm bool cM3d_InclusionCheckPosIn3PosBox2d(float, float, float, float, float, float, float, float,
- float) {
+// cM3d_InclusionCheckPosIn3PosBox2d(f32, f32, f32, f32, f32, f32, f32, f32, f32)
+asm bool cM3d_InclusionCheckPosIn3PosBox2d(f32, f32, f32, f32, f32, f32, f32, f32, f32) {
nofralloc
#include "SComponent/c_m3d/asm/func_80269D64.s"
}
// cM3d_CrossX_Tri__FPC8cM3dGTriPC3Vecf
-// cM3d_CrossX_Tri(const cM3dGTri*, const Vec*, float)
-asm bool cM3d_CrossX_Tri(const cM3dGTri*, const Vec*, float) {
+// cM3d_CrossX_Tri(const cM3dGTri*, const Vec*, f32)
+asm bool cM3d_CrossX_Tri(const cM3dGTri*, const Vec*, f32) {
nofralloc
#include "SComponent/c_m3d/asm/func_80269E18.s"
}
@@ -180,29 +466,29 @@ asm bool cM3d_CrossY_Tri_Front(const Vec&, const Vec&, const Vec&, const Vec*) {
}
// cM3d_CrossY_Tri__FPC8cM3dGTriPC3VecPf
-// cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, float*)
-asm bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, float*) {
+// cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, f32*)
+asm bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, f32*) {
nofralloc
#include "SComponent/c_m3d/asm/func_8026A8C0.s"
}
// cM3d_CrossY_Tri__FPC8cM3dGTriPC3Vecf
-// cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, float)
-asm bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, float) {
+// cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, f32)
+asm bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, f32) {
nofralloc
#include "SComponent/c_m3d/asm/func_8026A944.s"
}
// cM3d_CrossY_Tri__FPC8cM3dGTriPC3VecPC10cM3d_RangePf
-// cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, const cM3d_Range*, float*)
-asm bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, const cM3d_Range*, float*) {
+// cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, const cM3d_Range*, f32*)
+asm bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, const cM3d_Range*, f32*) {
nofralloc
#include "SComponent/c_m3d/asm/func_8026AAE8.s"
}
// cM3d_CrossZ_Tri__FPC8cM3dGTriPC3Vecf
-// cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*, float)
-asm bool cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*, float) {
+// cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*, f32)
+asm bool cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*, f32) {
nofralloc
#include "SComponent/c_m3d/asm/func_8026ABD8.s"
}
@@ -257,45 +543,66 @@ asm int cM3d_Cross_LinSph_CrossPos(const cM3dGSph&, const cM3dGLin&, Vec*, Vec*)
}
// cM3d_Cross_CylSph__FPC8cM3dGCylPC8cM3dGSphPf
-// cM3d_Cross_CylSph(const cM3dGCyl*, const cM3dGSph*, float*)
-asm bool cM3d_Cross_CylSph(const cM3dGCyl*, const cM3dGSph*, float*) {
+// cM3d_Cross_CylSph(const cM3dGCyl*, const cM3dGSph*, f32*)
+asm bool cM3d_Cross_CylSph(const cM3dGCyl*, const cM3dGSph*, f32*) {
nofralloc
#include "SComponent/c_m3d/asm/func_8026B8A4.s"
}
// cM3d_Cross_CylSph__FPC8cM3dGCylPC8cM3dGSphP3VecPf
-// cM3d_Cross_CylSph(const cM3dGCyl*, const cM3dGSph*, Vec*, float*)
-asm bool cM3d_Cross_CylSph(const cM3dGCyl*, const cM3dGSph*, Vec*, float*) {
+// cM3d_Cross_CylSph(const cM3dGCyl*, const cM3dGSph*, Vec*, f32*)
+asm bool cM3d_Cross_CylSph(const cM3dGCyl*, const cM3dGSph*, Vec*, f32*) {
nofralloc
#include "SComponent/c_m3d/asm/func_8026BA48.s"
}
// cM3d_Cross_SphSph__FPC8cM3dGSphPC8cM3dGSphPf
-// cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, float*)
-asm bool cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, float*) {
+// cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, f32*)
+asm bool cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, f32*) {
nofralloc
#include "SComponent/c_m3d/asm/func_8026BC7C.s"
}
// cM3d_Cross_SphSph__FPC8cM3dGSphPC8cM3dGSphPfPf
-// cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, float*, float*)
-asm bool cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, float*, float*) {
+// cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, f32*, f32*)
+asm bool cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, f32*, f32*) {
nofralloc
#include "SComponent/c_m3d/asm/func_8026BCFC.s"
}
// cM3d_Cross_SphSph__FPC8cM3dGSphPC8cM3dGSphP3Vec
-// cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, Vec*)
-asm void cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, Vec*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026BD88.s"
+bool cM3d_Cross_SphSph(const cM3dGSph* pSphereA, const cM3dGSph* pSphereB, Vec* pVecOut) {
+ f32 centerDist;
+ f32 overlapLen;
+ if (cM3d_Cross_SphSph(pSphereA, pSphereB, &centerDist, &overlapLen)) {
+ if (!cM3d_IsZero(centerDist)) {
+ // could be an inlined function
+ f32 tmpF = pSphereB->GetR() / centerDist;
+ Vec tmp;
+ PSVECSubtract(&pSphereA->GetC(), &pSphereB->GetC(), &tmp);
+ PSVECScale(&tmp, &tmp, tmpF);
+ PSVECAdd(&tmp, &pSphereB->GetC(), pVecOut);
+ } else {
+ *pVecOut = pSphereA->GetC();
+ }
+ return true;
+ } else {
+ return false;
+ }
}
// cM3d_CalcSphVsTriCrossPoint__FPC8cM3dGSphPC8cM3dGTriP3Vec
-// cM3d_CalcSphVsTriCrossPoint(const cM3dGSph*, const cM3dGTri*, Vec*)
-asm void cM3d_CalcSphVsTriCrossPoint(const cM3dGSph*, const cM3dGTri*, Vec*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026BE5C.s"
+void cM3d_CalcSphVsTriCrossPoint(const cM3dGSph* pSphere, const cM3dGTri* pTriangle, Vec* pVecOut) {
+ Vec tmp2;
+ Vec tmp;
+ PSVECAdd(&pTriangle->mA, &pTriangle->mB, &tmp);
+ PSVECScale(&tmp, &tmp2, /* 0.5 */ lbl_804551C4);
+ f32 sqDist = PSVECSquareDistance(&tmp2, &pSphere->GetC());
+ if (cM3d_IsZero(sqDist)) {
+ *pVecOut = pSphere->GetC();
+ } else {
+ cM3d_InDivPos2(&pSphere->GetC(), &tmp2, pSphere->GetR() / sqDist, pVecOut);
+ }
}
// cM3d_Cross_SphTri__FPC8cM3dGSphPC8cM3dGTriP3Vec
@@ -306,8 +613,8 @@ asm bool cM3d_Cross_SphTri(const cM3dGSph*, const cM3dGTri*, Vec*) {
}
// cM3d_Cross_CylCyl__FPC8cM3dGCylPC8cM3dGCylPf
-// cM3d_Cross_CylCyl(const cM3dGCyl*, const cM3dGCyl*, float*)
-asm bool cM3d_Cross_CylCyl(const cM3dGCyl*, const cM3dGCyl*, float*) {
+// cM3d_Cross_CylCyl(const cM3dGCyl*, const cM3dGCyl*, f32*)
+asm bool cM3d_Cross_CylCyl(const cM3dGCyl*, const cM3dGCyl*, f32*) {
nofralloc
#include "SComponent/c_m3d/asm/func_8026C22C.s"
}
@@ -334,17 +641,24 @@ asm int cM3d_Cross_CylLin(const cM3dGCyl*, const cM3dGLin*, Vec*, Vec*) {
}
// cM3d_Cross_CylPntPnt__FPC8cM3dGCylPC3VecPC3VecP3VecP3Vec
-// cM3d_Cross_CylPntPnt(const cM3dGCyl*, const Vec*, const Vec*, Vec*, Vec*)
-asm int cM3d_Cross_CylPntPnt(const cM3dGCyl*, const Vec*, const Vec*, Vec*, Vec*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026D044.s"
+int cM3d_Cross_CylPntPnt(const cM3dGCyl* pCylinder, const Vec* pVecStart, const Vec* pVecEnd,
+ Vec* pVecOutA, Vec* pVecOutB) {
+ cM3dGLin lin;
+ lin.SetStartEnd(*pVecStart, *pVecEnd);
+ return cM3d_Cross_CylLin(pCylinder, &lin, pVecOutA, pVecOutB);
}
// cM3d_Cross_CylPnt__FPC8cM3dGCylPC3Vec
-// cM3d_Cross_CylPnt(const cM3dGCyl*, const Vec*)
-asm bool cM3d_Cross_CylPnt(const cM3dGCyl*, const Vec*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026D0B0.s"
+bool cM3d_Cross_CylPnt(const cM3dGCyl* pCylinder, const Vec* pPoint) {
+ f32 dX = pCylinder->GetCP().getXDiff(pPoint);
+ f32 dZ = pCylinder->GetCP().getZDiff(pPoint);
+ f32 maxY = pCylinder->GetCP().y + pCylinder->GetH();
+ if (dX * dX + dZ * dZ < pCylinder->GetR() * pCylinder->GetR() &&
+ pCylinder->GetCP().y < pPoint->y && maxY > pPoint->y) {
+ return true;
+ } else {
+ return false;
+ }
}
// cM3d_Cross_CpsCps__FRC8cM3dGCpsRC8cM3dGCpsP3Vec
@@ -382,6 +696,16 @@ asm bool cM3d_Cross_TriTri(const cM3dGTri&, const cM3dGTri&, Vec*) {
#include "SComponent/c_m3d/asm/func_8026DE2C.s"
}
+inline f32 cM3d_2LinCenter(cM3dGLin const pLinA, f32 pLinAF, cM3dGLin const& pLinB, f32 pLinBF,
+ Vec* pVecOut) {
+ Vec tmp, tmp2;
+ pLinA.CalcPos(&tmp, pLinAF);
+ pLinB.CalcPos(&tmp2, pLinBF);
+ PSVECAdd(&tmp, &tmp2, pVecOut);
+ PSVECScale(pVecOut, pVecOut, /* 0.5 */ lbl_804551C4);
+ return PSVECDistance(&tmp, &tmp2);
+}
+
// cM3d_Cross_CpsTri__FRC8cM3dGCps8cM3dGTriP3Vec
// cM3d_Cross_CpsTri(const cM3dGCps&, cM3dGTri, Vec*)
asm bool cM3d_Cross_CpsTri(const cM3dGCps&, cM3dGTri, Vec*) {
@@ -390,10 +714,9 @@ asm bool cM3d_Cross_CpsTri(const cM3dGCps&, cM3dGTri, Vec*) {
}
// cM3d_CalcVecAngle__FRC3VecPsPs
-// cM3d_CalcVecAngle(const Vec&, short*, short*)
-asm void cM3d_CalcVecAngle(const Vec&, short*, short*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026E4FC.s"
+void cM3d_CalcVecAngle(const Vec& pVec, s16* pOutA, s16* pOutB) {
+ *pOutA = -cM_atan2s(-pVec.z * pVec.y, /* 1.0 */ lbl_80455138);
+ *pOutB = cM_atan2s(-pVec.x * pVec.y, /* 1.0 */ lbl_80455138);
}
// cM3d_CalcVecZAngle__FRC3VecP5csXyz
@@ -404,53 +727,126 @@ asm void cM3d_CalcVecZAngle(const Vec&, csXyz*) {
}
// cM3d_PlaneCrossLineProcWork__FfffffffPfPf
-// cM3d_PlaneCrossLineProcWork(float, float, float, float, float, float, float, float*, float*)
-asm void cM3d_PlaneCrossLineProcWork(float, float, float, float, float, float, float, float*,
- float*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026E6C4.s"
+void cM3d_PlaneCrossLineProcWork(f32 f1, f32 f2, f32 f3, f32 f4, f32 f5, f32 f6, f32 f7, f32* pF1,
+ f32* pF2) {
+ *pF1 = ((f2 * f7) - (f4 * f6)) / f5;
+ *pF2 = ((f3 * f6) - (f1 * f7)) / f5;
}
// cM3d_2PlaneCrossLine__FRC8cM3dGPlaRC8cM3dGPlaP8cM3dGLin
-// cM3d_2PlaneCrossLine(const cM3dGPla&, const cM3dGPla&, cM3dGLin*)
-asm int cM3d_2PlaneCrossLine(const cM3dGPla&, const cM3dGPla&, cM3dGLin*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026E6F0.s"
+int cM3d_2PlaneCrossLine(const cM3dGPla& pPlaneA, const cM3dGPla& pPlaneB, cM3dGLin* pLinOut) {
+ Vec tmp;
+ PSVECCrossProduct(&pPlaneA.GetNP(), &pPlaneB.GetNP(), &tmp);
+ if (cM3d_IsZero(tmp.x) && cM3d_IsZero(tmp.y) && cM3d_IsZero(tmp.z)) {
+ return 0;
+ } else {
+ f32 absTX = fabsf(tmp.x);
+ f32 absTY = fabsf(tmp.y);
+ f32 absTZ = fabsf(tmp.z);
+ if (absTX >= absTY && absTX >= absTZ) {
+ cM3d_PlaneCrossLineProcWork(pPlaneA.GetNP().y, pPlaneA.GetNP().z, pPlaneB.GetNP().y,
+ pPlaneB.GetNP().z, tmp.x, pPlaneA.GetD(), pPlaneB.GetD(),
+ &pLinOut->GetStartP().y, &pLinOut->GetStartP().z);
+ pLinOut->GetStartP().x = /* 0.0 */ lbl_80455118;
+ } else if (absTY >= absTX && absTY >= absTZ) {
+ cM3d_PlaneCrossLineProcWork(pPlaneA.GetNP().z, pPlaneA.GetNP().x, pPlaneB.GetNP().z,
+ pPlaneB.GetNP().x, tmp.y, pPlaneA.GetD(), pPlaneB.GetD(),
+ &pLinOut->GetStartP().z, &pLinOut->GetStartP().x);
+ pLinOut->GetStartP().y = /* 0.0 */ lbl_80455118;
+ } else {
+ cM3d_PlaneCrossLineProcWork(pPlaneA.GetNP().x, pPlaneA.GetNP().y, pPlaneB.GetNP().x,
+ pPlaneB.GetNP().y, tmp.z, pPlaneA.GetD(), pPlaneB.GetD(),
+ &pLinOut->GetStartP().x, &pLinOut->GetStartP().y);
+ pLinOut->GetStartP().z = /* 0.0 */ lbl_80455118;
+ }
+ f32 scale = PSVECMag(&pLinOut->GetStartP());
+ if (cM3d_IsZero(scale)) {
+ scale = /* 1.0 */ lbl_80455138;
+ }
+ PSVECScale(&tmp, &tmp, scale);
+ PSVECAdd(&pLinOut->GetStartP(), &tmp, &pLinOut->GetEndP());
+ return 1;
+ }
}
// cM3d_3PlaneCrossPos__FRC8cM3dGPlaRC8cM3dGPlaRC8cM3dGPlaP3Vec
-// cM3d_3PlaneCrossPos(const cM3dGPla&, const cM3dGPla&, const cM3dGPla&, Vec*)
-asm bool cM3d_3PlaneCrossPos(const cM3dGPla&, const cM3dGPla&, const cM3dGPla&, Vec*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026E8A0.s"
+bool cM3d_3PlaneCrossPos(const cM3dGPla& pPlaneA, const cM3dGPla& pPlaneB, const cM3dGPla& pPlaneC,
+ Vec* pVecOut) {
+ cM3dGLin lin;
+ if (!cM3d_2PlaneCrossLine(pPlaneA, pPlaneB, &lin)) {
+ return false;
+ } else {
+ const Vec* end = &lin.GetEndP();
+ f32 tmpf1 = pPlaneC.getPlaneFunc(&lin.GetStartP());
+ f32 tmpf2 = pPlaneC.getPlaneFunc(end);
+ if (!cM3d_CrossInfLineVsInfPlane_proc(tmpf1, tmpf2, &lin.GetStartP(), end, pVecOut)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
}
// cM3d_lineVsPosSuisenCross__FPC8cM3dGLinPC3VecP3Vec
-// cM3d_lineVsPosSuisenCross(const cM3dGLin*, const Vec*, Vec*)
-asm float cM3d_lineVsPosSuisenCross(const cM3dGLin*, const Vec*, Vec*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026E980.s"
+f32 cM3d_lineVsPosSuisenCross(const cM3dGLin* pLine, const Vec* pPoint, Vec* pVecOut) {
+ Vec tmp1;
+ Vec tmp2;
+ Vec tmp3;
+ // PSVECSubtract(&pLine->GetEndP(), &pLine->GetStartP(), &tmp1);
+ pLine->CalcVec(&tmp1);
+ f32 diffLen = PSVECSquareMag(&tmp1);
+ if (cM3d_IsZero(diffLen)) {
+ *pVecOut = *pPoint;
+ return /* 0.0 */ lbl_80455118;
+ } else {
+ PSVECSubtract(pPoint, &pLine->GetStartP(), &tmp2);
+ // f32 dotProd = PSVECDotProduct(&tmp2, &tmp1);
+ // f32 retVal = dotProd / diffLen;
+ f32 retVal = PSVECDotProduct(&tmp2, &tmp1) / diffLen;
+ PSVECScale(&tmp1, &tmp3, retVal);
+ PSVECAdd(&tmp3, &pLine->GetStartP(), pVecOut);
+ return retVal;
+ }
}
// cM3d_lineVsPosSuisenCross__FRC3VecRC3VecRC3VecP3Vec
-// cM3d_lineVsPosSuisenCross(const Vec&, const Vec&, const Vec&, Vec*)
-asm float cM3d_lineVsPosSuisenCross(const Vec&, const Vec&, const Vec&, Vec*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026EA5C.s"
+f32 cM3d_lineVsPosSuisenCross(const Vec& pLinePointA, const Vec& pLinePointB, const Vec& pPoint,
+ Vec* pVecOut) {
+ Vec tmp1;
+ Vec tmp2;
+ Vec tmp3;
+ PSVECSubtract(&pLinePointB, &pLinePointA, &tmp1);
+ f32 diffLen = PSVECSquareMag(&tmp1);
+ if (cM3d_IsZero(diffLen)) {
+ *pVecOut = pPoint;
+ return /* 0.0 */ lbl_80455118;
+ } else {
+ PSVECSubtract(&pPoint, &pLinePointA, &tmp2);
+ f32 dotProd = PSVECDotProduct(&tmp2, &tmp1);
+ f32 retVal = dotProd / diffLen;
+ PSVECScale(&tmp1, &tmp3, retVal);
+ PSVECAdd(&tmp3, &pLinePointA, pVecOut);
+ return retVal;
+ }
}
// cM3d_2PlaneLinePosNearPos__FRC8cM3dGPlaRC8cM3dGPlaPC3VecP3Vec
-// cM3d_2PlaneLinePosNearPos(const cM3dGPla&, const cM3dGPla&, const Vec*, Vec*)
-asm int cM3d_2PlaneLinePosNearPos(const cM3dGPla&, const cM3dGPla&, const Vec*, Vec*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026EB38.s"
+int cM3d_2PlaneLinePosNearPos(const cM3dGPla& pPlaneA, const cM3dGPla& pPlaneB, const Vec* pVec,
+ Vec* pVecOut) {
+ cM3dGLin lin;
+ if (!cM3d_2PlaneCrossLine(pPlaneA, pPlaneB, &lin)) {
+ return FALSE;
+ } else {
+ cM3d_lineVsPosSuisenCross(&lin, pVec, pVecOut);
+ return TRUE;
+ }
}
// cM3d_CrawVec__FRC3VecRC3VecP3Vec
-// cM3d_CrawVec(const Vec&, const Vec&, Vec*)
-asm void cM3d_CrawVec(const Vec&, const Vec&, Vec*) {
- nofralloc
-#include "SComponent/c_m3d/asm/func_8026EBBC.s"
+void cM3d_CrawVec(const Vec& pVecA, const Vec& pVecB, Vec* pVecOut) {
+ Vec tmp;
+ PSVECScale(&pVecA, &tmp, fabsf(pVecB.x * pVecA.x + pVecB.y * pVecA.y + pVecB.z * pVecA.z));
+ PSVECAdd(&tmp, &pVecB, pVecOut);
}
extern "C" {
diff --git a/libs/SSystem/SComponent/c_m3d_g_aab.cpp b/libs/SSystem/SComponent/c_m3d_g_aab.cpp
index edc0bd661d..c01a35fbfc 100644
--- a/libs/SSystem/SComponent/c_m3d_g_aab.cpp
+++ b/libs/SSystem/SComponent/c_m3d_g_aab.cpp
@@ -2,79 +2,73 @@
#include "SComponent/c_m3d_g_aab.h"
+// additional symbols needed for c_m3d_g_aab.cpp
+// autogenerated by split.py v0.3 at 2021-01-01 14:25:53.390342
+extern f32 lbl_804551D4;
+extern f32 lbl_804551D0;
+extern f32 lbl_804551D8;
+
// Set__8cM3dGAabFPC4cXyzPC4cXyz
-// cM3dGAab::Set(const cXyz*, const cXyz*)
-asm void cM3dGAab::Set(const cXyz*, const cXyz*) {
- nofralloc
-#include "SComponent/c_m3d_g_aab/asm/func_8026EC54.s"
+void cM3dGAab::Set(const cXyz* pMin, const cXyz* pMax) {
+ mMin = *pMin;
+ mMax = *pMax;
}
// CrossY__8cM3dGAabCFPC4cXyz
-// cM3dGAab::CrossY(const cXyz*) const
-asm bool cM3dGAab::CrossY(const cXyz*) const {
- nofralloc
-#include "SComponent/c_m3d_g_aab/asm/func_8026EC88.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;
+ }
}
// UnderPlaneYUnder__8cM3dGAabCFf
-// cM3dGAab::UnderPlaneYUnder(float) const
-asm bool cM3dGAab::UnderPlaneYUnder(float) const {
- nofralloc
-#include "SComponent/c_m3d_g_aab/asm/func_8026ECD0.s"
+bool cM3dGAab::UnderPlaneYUnder(f32 pY) const {
+ return mMin.y < pY;
}
// TopPlaneYUnder__8cM3dGAabCFf
-// cM3dGAab::TopPlaneYUnder(float) const
-asm bool cM3dGAab::TopPlaneYUnder(float) const {
- nofralloc
-#include "SComponent/c_m3d_g_aab/asm/func_8026ECE4.s"
+bool cM3dGAab::TopPlaneYUnder(f32 pY) const {
+ return mMax.y < pY;
}
// ClearForMinMax__8cM3dGAabFv
-// cM3dGAab::ClearForMinMax(void)
-asm void cM3dGAab::ClearForMinMax(void) {
- nofralloc
-#include "SComponent/c_m3d_g_aab/asm/func_8026ECF8.s"
+void cM3dGAab::ClearForMinMax(void) {
+ mMin.setAll(lbl_804551D0);
+ mMax.setAll(lbl_804551D4);
}
// SetMinMax__8cM3dGAabFRC4cXyz
-// cM3dGAab::SetMinMax(const cXyz&)
-asm void cM3dGAab::SetMinMax(const cXyz&) {
- nofralloc
-#include "SComponent/c_m3d_g_aab/asm/func_8026ED1C.s"
+void cM3dGAab::SetMinMax(const cXyz& pMinMax) {
+ this->SetMin(pMinMax);
+ this->SetMax(pMinMax);
}
// SetMinMax__8cM3dGAabFRC8cM3dGAab
-// cM3dGAab::SetMinMax(const cM3dGAab&)
-asm void cM3dGAab::SetMinMax(const cM3dGAab&) {
- nofralloc
-#include "SComponent/c_m3d_g_aab/asm/func_8026ED60.s"
+void cM3dGAab::SetMinMax(const cM3dGAab& pOther) {
+ this->SetMinMax(pOther.mMin);
+ this->SetMinMax(pOther.mMax);
}
// SetMin__8cM3dGAabFRC4cXyz
-// cM3dGAab::SetMin(const cXyz&)
-asm void cM3dGAab::SetMin(const cXyz&) {
- nofralloc
-#include "SComponent/c_m3d_g_aab/asm/func_8026EDA4.s"
+void cM3dGAab::SetMin(const cXyz& pMin) {
+ mMin.setMin(pMin);
}
// SetMax__8cM3dGAabFRC4cXyz
-// cM3dGAab::SetMax(const cXyz&)
-asm void cM3dGAab::SetMax(const cXyz&) {
- nofralloc
-#include "SComponent/c_m3d_g_aab/asm/func_8026EDE4.s"
+void cM3dGAab::SetMax(const cXyz& pMax) {
+ mMax.setMax(pMax);
}
// CalcCenter__8cM3dGAabCFP4cXyz
-// cM3dGAab::CalcCenter(cXyz*) const
-asm void cM3dGAab::CalcCenter(cXyz*) const {
- nofralloc
-#include "SComponent/c_m3d_g_aab/asm/func_8026EE24.s"
+void cM3dGAab::CalcCenter(cXyz* pOut) const {
+ PSVECAdd(&mMin, &mMax, pOut);
+ PSVECScale(pOut, pOut, lbl_804551D8);
}
// PlusR__8cM3dGAabFf
-// cM3dGAab::PlusR(float)
-asm void cM3dGAab::PlusR(float) {
- nofralloc
-#include "SComponent/c_m3d_g_aab/asm/func_8026EE68.s"
+void cM3dGAab::PlusR(f32 pR) {
+ mMin -= pR;
+ mMax += pR;
}
diff --git a/libs/SSystem/SComponent/c_m3d_g_cir.cpp b/libs/SSystem/SComponent/c_m3d_g_cir.cpp
index 83e3f7f2ca..c6461fc4d1 100644
--- a/libs/SSystem/SComponent/c_m3d_g_cir.cpp
+++ b/libs/SSystem/SComponent/c_m3d_g_cir.cpp
@@ -3,32 +3,18 @@
#include "SComponent/c_m3d_g_cir.h"
// __ct__8cM3dGCirFv
-// cM3dGCir::cM3dGCir(void)
-asm cM3dGCir::cM3dGCir(void) {
- nofralloc
-#include "SComponent/c_m3d_g_cir/asm/func_8026EEB4.s"
-}
-
-extern "C" {
+cM3dGCir::cM3dGCir(void) {}
+// inlined here
// __dt__8cM2dGCirFv
-// cM2dGCir::~cM2dGCir(void)
-asm void __dt__8cM2dGCirFv(void) {
- nofralloc
-#include "SComponent/c_m3d_g_cir/asm/func_8026EED0.s"
-}
-}
// __dt__8cM3dGCirFv
-// cM3dGCir::~cM3dGCir(void)
-asm cM3dGCir::~cM3dGCir(void) {
- nofralloc
-#include "SComponent/c_m3d_g_cir/asm/func_8026EF18.s"
-}
+cM3dGCir::~cM3dGCir(void) {}
// Set__8cM3dGCirFffff
-// cM3dGCir::Set(float, float, float, float)
-asm void cM3dGCir::Set(float, float, float, float) {
- nofralloc
-#include "SComponent/c_m3d_g_cir/asm/func_8026EF74.s"
+void cM3dGCir::Set(f32 pPosX, f32 pPosY, f32 pPosZ, f32 pRadius) {
+ mPosX = pPosX;
+ mPosY = pPosY;
+ mRadius = pRadius;
+ mPosZ = pPosZ;
}
diff --git a/libs/SSystem/SComponent/c_m3d_g_cps.cpp b/libs/SSystem/SComponent/c_m3d_g_cps.cpp
index b65d244e3b..28010f892f 100644
--- a/libs/SSystem/SComponent/c_m3d_g_cps.cpp
+++ b/libs/SSystem/SComponent/c_m3d_g_cps.cpp
@@ -3,36 +3,24 @@
#include "SComponent/c_m3d_g_cps.h"
// __ct__8cM3dGCpsFv
-// cM3dGCps::cM3dGCps(void)
-asm cM3dGCps::cM3dGCps(void) {
- nofralloc
-#include "SComponent/c_m3d_g_cps/asm/func_8026EF88.s"
-}
+cM3dGCps::cM3dGCps(void) {}
// __dt__8cM3dGCpsFv
-// cM3dGCps::~cM3dGCps(void)
-asm cM3dGCps::~cM3dGCps(void) {
- nofralloc
-#include "SComponent/c_m3d_g_cps/asm/func_8026EFA4.s"
-}
+cM3dGCps::~cM3dGCps(void) {}
// Set__8cM3dGCpsFRC4cXyzRC4cXyzf
-// cM3dGCps::Set(const cXyz&, const cXyz&, float)
-asm void cM3dGCps::Set(const cXyz&, const cXyz&, float) {
- nofralloc
-#include "SComponent/c_m3d_g_cps/asm/func_8026F000.s"
+void cM3dGCps::Set(const cXyz& pStart, const cXyz& pEnd, f32 pUnkF) {
+ this->SetStartEnd(pStart, pEnd);
+ unk_0x1c = pUnkF;
}
// Set__8cM3dGCpsFRC9cM3dGCpsS
-// cM3dGCps::Set(const cM3dGCpsS&)
-asm void cM3dGCps::Set(const cM3dGCpsS&) {
- nofralloc
-#include "SComponent/c_m3d_g_cps/asm/func_8026F03C.s"
+void cM3dGCps::Set(const cM3dGCpsS& other) {
+ this->SetStartEnd(other.mStart, other.mEnd);
+ unk_0x1c = other.unk_0x1c;
}
// SetCps__8cM3dGCpsFRC8cM3dGCps
-// cM3dGCps::SetCps(const cM3dGCps&)
-asm void cM3dGCps::SetCps(const cM3dGCps&) {
- nofralloc
-#include "SComponent/c_m3d_g_cps/asm/func_8026F080.s"
+void cM3dGCps::SetCps(const cM3dGCps& other) {
+ this->Set(other.GetStartP(), other.GetEndP(), other.unk_0x1c);
}
diff --git a/libs/SSystem/SComponent/c_m3d_g_cyl.cpp b/libs/SSystem/SComponent/c_m3d_g_cyl.cpp
index fefedadc96..14b7bc17e5 100644
--- a/libs/SSystem/SComponent/c_m3d_g_cyl.cpp
+++ b/libs/SSystem/SComponent/c_m3d_g_cyl.cpp
@@ -1,66 +1,61 @@
/* c_m3d_g_cyl.cpp autogenerated by split.py v0.3 at 2021-01-01 14:45:46.600671 */
#include "SComponent/c_m3d_g_cyl.h"
+#include "SComponent/c_m3d.h"
// __ct__8cM3dGCylFPC4cXyzff
-// cM3dGCyl::cM3dGCyl(const cXyz*, float, float)
-asm cM3dGCyl::cM3dGCyl(const cXyz*, float, float) {
- nofralloc
-#include "SComponent/c_m3d_g_cyl/asm/func_8026F0A8.s"
+cM3dGCyl::cM3dGCyl(const cXyz* pCenter, f32 pRadius, f32 pHeight) {
+ this->SetC(*pCenter);
+ this->SetR(pRadius);
+ this->SetH(pHeight);
}
// Set__8cM3dGCylFRC9cM3dGCylS
-// cM3dGCyl::Set(const cM3dGCylS&)
-asm void cM3dGCyl::Set(const cM3dGCylS&) {
- nofralloc
-#include "SComponent/c_m3d_g_cyl/asm/func_8026F114.s"
+void cM3dGCyl::Set(const cM3dGCylS& other) {
+ this->SetC(cXyz(other.mCenter));
+ this->SetR(other.mRadius);
+ this->SetH(other.mHeight);
}
// Set__8cM3dGCylFRC4cXyzff
-// cM3dGCyl::Set(const cXyz&, float, float)
-asm void cM3dGCyl::Set(const cXyz&, float, float) {
- nofralloc
-#include "SComponent/c_m3d_g_cyl/asm/func_8026F180.s"
+void cM3dGCyl::Set(const cXyz& pCenter, f32 pRadius, f32 pHeight) {
+ this->SetC(pCenter);
+ this->SetR(pRadius);
+ this->SetH(pHeight);
}
// SetC__8cM3dGCylFRC4cXyz
-// cM3dGCyl::SetC(const cXyz&)
-asm void cM3dGCyl::SetC(const cXyz&) {
- nofralloc
-#include "SComponent/c_m3d_g_cyl/asm/func_8026F1DC.s"
+void cM3dGCyl::SetC(const cXyz& pCenter) {
+ mCenter = pCenter;
}
// SetH__8cM3dGCylFf
-// cM3dGCyl::SetH(float)
-asm void cM3dGCyl::SetH(float) {
- nofralloc
-#include "SComponent/c_m3d_g_cyl/asm/func_8026F1F8.s"
+void cM3dGCyl::SetH(f32 pHeight) {
+ mHeight = pHeight;
}
// SetR__8cM3dGCylFf
-// cM3dGCyl::SetR(float)
-asm void cM3dGCyl::SetR(float) {
- nofralloc
-#include "SComponent/c_m3d_g_cyl/asm/func_8026F200.s"
+void cM3dGCyl::SetR(f32 pRadius) {
+ mRadius = pRadius;
}
// cross__8cM3dGCylCFPC8cM3dGSphP4cXyz
-// cM3dGCyl::cross(const cM3dGSph*, cXyz*) const
-asm bool cM3dGCyl::cross(const cM3dGSph*, cXyz*) const {
- nofralloc
-#include "SComponent/c_m3d_g_cyl/asm/func_8026F208.s"
+bool cM3dGCyl::cross(const cM3dGSph* pOther, cXyz* pOut) const {
+ f32 f;
+ return cM3d_Cross_CylSph(this, pOther, pOut, &f);
}
// cross__8cM3dGCylCFPC8cM3dGCylP4cXyz
-// cM3dGCyl::cross(const cM3dGCyl*, cXyz*) const
-asm bool cM3dGCyl::cross(const cM3dGCyl*, cXyz*) const {
- nofralloc
-#include "SComponent/c_m3d_g_cyl/asm/func_8026F22C.s"
+bool cM3dGCyl::cross(const cM3dGCyl* pOther, cXyz* pOut) const {
+ return cM3d_Cross_CylCyl(this, pOther, pOut);
}
// calcMinMax__8cM3dGCylFP4cXyzP4cXyz
-// cM3dGCyl::calcMinMax(cXyz*, cXyz*)
-asm void cM3dGCyl::calcMinMax(cXyz*, cXyz*) {
- nofralloc
-#include "SComponent/c_m3d_g_cyl/asm/func_8026F24C.s"
+void cM3dGCyl::calcMinMax(cXyz* pMin, cXyz* pMax) {
+ pMin->x = mCenter.x - mRadius;
+ pMin->y = mCenter.y;
+ pMin->z = mCenter.z - mRadius;
+ pMax->x = mCenter.x + mRadius;
+ pMax->y = mCenter.y + mHeight;
+ pMax->z = mCenter.z + mRadius;
}
diff --git a/libs/SSystem/SComponent/c_m3d_g_lin.cpp b/libs/SSystem/SComponent/c_m3d_g_lin.cpp
index 8a4b67721f..04a52f45c3 100644
--- a/libs/SSystem/SComponent/c_m3d_g_lin.cpp
+++ b/libs/SSystem/SComponent/c_m3d_g_lin.cpp
@@ -1,38 +1,31 @@
/* c_m3d_g_lin.cpp autogenerated by split.py v0.3 at 2021-01-01 14:48:45.519641 */
-#include "SComponent/c_m3d_g_lin.h"
+#include "SComponent/c_m3d.h"
// __ct__8cM3dGLinFRC4cXyzRC4cXyz
-// cM3dGLin::cM3dGLin(const cXyz&, const cXyz&)
-asm cM3dGLin::cM3dGLin(const cXyz&, const cXyz&) {
- nofralloc
-#include "SComponent/c_m3d_g_lin/asm/func_8026F2A8.s"
-}
+cM3dGLin::cM3dGLin(const cXyz& pStart, const cXyz& pEnd) : mStart(pStart), mEnd(pEnd) {}
// SetStartEnd__8cM3dGLinFRC4cXyzRC4cXyz
-// cM3dGLin::SetStartEnd(const cXyz&, const cXyz&)
-asm void cM3dGLin::SetStartEnd(const cXyz&, const cXyz&) {
- nofralloc
-#include "SComponent/c_m3d_g_lin/asm/func_8026F2E8.s"
+void cM3dGLin::SetStartEnd(const cXyz& pStart, const cXyz& pEnd) {
+ mStart = pStart;
+ mEnd = pEnd;
}
// SetStartEnd__8cM3dGLinFRC3VecRC3Vec
-// cM3dGLin::SetStartEnd(const Vec&, const Vec&)
-asm void cM3dGLin::SetStartEnd(const Vec&, const Vec&) {
- nofralloc
-#include "SComponent/c_m3d_g_lin/asm/func_8026F31C.s"
+void cM3dGLin::SetStartEnd(const Vec& pStart, const Vec& pEnd) {
+ mStart = pStart;
+ mEnd = pEnd;
}
// CalcPos__8cM3dGLinCFP3Vecf
-// cM3dGLin::CalcPos(Vec*, float) const
-asm void cM3dGLin::CalcPos(Vec*, float) const {
- nofralloc
-#include "SComponent/c_m3d_g_lin/asm/func_8026F350.s"
+void cM3dGLin::CalcPos(Vec* pOut, f32 pScale) const {
+ Vec tmp;
+ PSVECSubtract(&mEnd, &mStart, &tmp);
+ PSVECScale(&tmp, &tmp, pScale);
+ PSVECAdd(&tmp, &mStart, pOut);
}
// SetEnd__8cM3dGLinFRC4cXyz
-// cM3dGLin::SetEnd(const cXyz&)
-asm void cM3dGLin::SetEnd(const cXyz&) {
- nofralloc
-#include "SComponent/c_m3d_g_lin/asm/func_8026F3C0.s"
+void cM3dGLin::SetEnd(const cXyz& pEnd) {
+ mEnd = pEnd;
} \ No newline at end of file
diff --git a/libs/SSystem/SComponent/c_m3d_g_pla.cpp b/libs/SSystem/SComponent/c_m3d_g_pla.cpp
index 55f2bc5bba..0a3c28b917 100644
--- a/libs/SSystem/SComponent/c_m3d_g_pla.cpp
+++ b/libs/SSystem/SComponent/c_m3d_g_pla.cpp
@@ -1,52 +1,58 @@
/* c_m3d_g_pla.cpp autogenerated by split.py v0.3 at 2021-01-01 14:50:54.810233 */
#include "SComponent/c_m3d_g_pla.h"
+#include "SComponent/c_m3d.h"
// __ct__8cM3dGPlaFPC4cXyzf
-// cM3dGPla::cM3dGPla(const cXyz*, float)
-asm cM3dGPla::cM3dGPla(const cXyz*, float) {
- nofralloc
-#include "SComponent/c_m3d_g_pla/asm/func_8026F3DC.s"
-}
+cM3dGPla::cM3dGPla(const cXyz* pNormal, f32 pD) : mNormal(*pNormal), mD(pD) {}
// crossInfLin__8cM3dGPlaCFRC4cXyzRC4cXyzR4cXyz
-// cM3dGPla::crossInfLin(const cXyz&, const cXyz&, cXyz&) const
-asm void cM3dGPla::crossInfLin(const cXyz&, const cXyz&, cXyz&) const {
- nofralloc
-#include "SComponent/c_m3d_g_pla/asm/func_8026F408.s"
+bool cM3dGPla::crossInfLin(const cXyz& pStart, const cXyz& pEnd, cXyz& out) const {
+ f32 tmp1 = (mD + PSVECDotProduct(&mNormal, &pStart));
+ f32 tmp2 = tmp1 - (mD + PSVECDotProduct(&mNormal, &pEnd));
+ if (fabsf(tmp2) < lbl_80451180) {
+ out = pEnd;
+ return false;
+ } else {
+ cM3d_InDivPos2(&pStart, &pEnd, (tmp1 / tmp2), &out);
+ return true;
+ }
}
// SetupNP0__8cM3dGPlaFRC3VecRC3Vec
-// cM3dGPla::SetupNP0(const Vec&, const Vec&)
-asm void cM3dGPla::SetupNP0(const Vec&, const Vec&) {
- nofralloc
-#include "SComponent/c_m3d_g_pla/asm/func_8026F4C4.s"
+void cM3dGPla::SetupNP0(const Vec& pNormal, const Vec& pPoint) {
+ mNormal = pNormal;
+ PSVECNormalize(&mNormal, &mNormal);
+ mD = -PSVECDotProduct(&mNormal, &pPoint);
}
// SetupNP__8cM3dGPlaFRC3VecRC3Vec
-// cM3dGPla::SetupNP(const Vec&, const Vec&)
-asm void cM3dGPla::SetupNP(const Vec&, const Vec&) {
- nofralloc
-#include "SComponent/c_m3d_g_pla/asm/func_8026F52C.s"
+void cM3dGPla::SetupNP(const Vec& pNormal, const Vec& pPoint) {
+ mNormal = pNormal;
+ mD = -PSVECDotProduct(&mNormal, &pPoint);
}
// getCrossY__8cM3dGPlaCFRC4cXyzPf
-// cM3dGPla::getCrossY(const cXyz&, float*) const
-asm bool cM3dGPla::getCrossY(const cXyz&, float*) const {
- nofralloc
-#include "SComponent/c_m3d_g_pla/asm/func_8026F57C.s"
+bool cM3dGPla::getCrossY(const cXyz& pPoint, f32* pOut) const {
+ if (fabsf(mNormal.y) < lbl_80451180) {
+ return false;
+ } else {
+ *pOut = (-mNormal.x * pPoint.x - mNormal.z * pPoint.z - mD) / mNormal.y;
+ return true;
+ }
}
// getCrossYLessD__8cM3dGPlaCFRC3VecPf
-// cM3dGPla::getCrossYLessD(const Vec&, float*) const
-asm bool cM3dGPla::getCrossYLessD(const Vec&, float*) const {
- nofralloc
-#include "SComponent/c_m3d_g_pla/asm/func_8026F5D4.s"
+bool cM3dGPla::getCrossYLessD(const Vec& pPoint, f32* pOut) const {
+ if (fabsf(mNormal.y) < lbl_80451180) {
+ return false;
+ } else {
+ *pOut = (-mNormal.x * pPoint.x - mNormal.z * pPoint.z) / mNormal.y;
+ return true;
+ }
}
// Set__8cM3dGPlaFPC8cM3dGPla
-// cM3dGPla::Set(const cM3dGPla*)
-asm void cM3dGPla::Set(const cM3dGPla*) {
- nofralloc
-#include "SComponent/c_m3d_g_pla/asm/func_8026F624.s"
+void cM3dGPla::Set(const cM3dGPla* pOther) {
+ *this = *pOther;
}
diff --git a/libs/SSystem/SComponent/c_m3d_g_sph.cpp b/libs/SSystem/SComponent/c_m3d_g_sph.cpp
index 4098bcefc1..7f0883a636 100644
--- a/libs/SSystem/SComponent/c_m3d_g_sph.cpp
+++ b/libs/SSystem/SComponent/c_m3d_g_sph.cpp
@@ -1,52 +1,47 @@
/* c_m3d_g_sph.cpp autogenerated by split.py v0.3 at 2021-01-01 14:53:31.074880 */
#include "SComponent/c_m3d_g_sph.h"
+#include "SComponent/c_m3d.h"
// SetC__8cM3dGSphFRC4cXyz
-// cM3dGSph::SetC(const cXyz&)
-asm void cM3dGSph::SetC(const cXyz&) {
- nofralloc
-#include "SComponent/c_m3d_g_sph/asm/func_8026F648.s"
+void cM3dGSph::SetC(const cXyz& pCenter) {
+ mCenter = pCenter;
}
// Set__8cM3dGSphFRC4cXyzf
-// cM3dGSph::Set(const cXyz&, float)
-asm void cM3dGSph::Set(const cXyz&, float) {
- nofralloc
-#include "SComponent/c_m3d_g_sph/asm/func_8026F664.s"
+void cM3dGSph::Set(const cXyz& pCenter, f32 pRadius) {
+ this->SetC(pCenter);
+ this->SetR(pRadius);
}
// Set__8cM3dGSphFRC9cM3dGSphS
-// cM3dGSph::Set(const cM3dGSphS&)
-asm void cM3dGSph::Set(const cM3dGSphS&) {
- nofralloc
-#include "SComponent/c_m3d_g_sph/asm/func_8026F6A8.s"
+void cM3dGSph::Set(const cM3dGSphS& pOther) {
+ this->SetC(cXyz(pOther.mCenter));
+ this->SetR(pOther.mRadius);
}
// SetR__8cM3dGSphFf
-// cM3dGSph::SetR(float)
-asm void cM3dGSph::SetR(float) {
- nofralloc
-#include "SComponent/c_m3d_g_sph/asm/func_8026F708.s"
+void cM3dGSph::SetR(f32 pRadius) {
+ mRadius = pRadius;
}
// cross__8cM3dGSphCFPC8cM3dGSphP4cXyz
-// cM3dGSph::cross(const cM3dGSph*, cXyz*) const
-asm bool cM3dGSph::cross(const cM3dGSph*, cXyz*) const {
- nofralloc
-#include "SComponent/c_m3d_g_sph/asm/func_8026F710.s"
+bool cM3dGSph::cross(const cM3dGSph* pOther, cXyz* pOut) const {
+ return cM3d_Cross_SphSph(pOther, this, pOut);
}
// cross__8cM3dGSphCFPC8cM3dGCylP4cXyz
-// cM3dGSph::cross(const cM3dGCyl*, cXyz*) const
-asm bool cM3dGSph::cross(const cM3dGCyl*, cXyz*) const {
- nofralloc
-#include "SComponent/c_m3d_g_sph/asm/func_8026F73C.s"
+bool cM3dGSph::cross(const cM3dGCyl* pCylinder, cXyz* pOut) const {
+ f32 f;
+ return cM3d_Cross_CylSph(pCylinder, this, pOut, &f);
}
// GetMinMaxCube__8cM3dGSphCFR4cXyzR4cXyz
-// cM3dGSph::GetMinMaxCube(cXyz&, cXyz&) const
-asm void cM3dGSph::GetMinMaxCube(cXyz&, cXyz&) const {
- nofralloc
-#include "SComponent/c_m3d_g_sph/asm/func_8026F76C.s"
+void cM3dGSph::GetMinMaxCube(cXyz& pMin, cXyz& pMax) const {
+ pMin.x = mCenter.x - mRadius;
+ pMin.y = mCenter.y - mRadius;
+ pMin.z = mCenter.z - mRadius;
+ pMax.x = mCenter.x + mRadius;
+ pMax.y = mCenter.y + mRadius;
+ pMax.z = mCenter.z + mRadius;
}
diff --git a/libs/SSystem/SComponent/c_m3d_g_tri.cpp b/libs/SSystem/SComponent/c_m3d_g_tri.cpp
index 3b51b1eddc..dc7162a756 100644
--- a/libs/SSystem/SComponent/c_m3d_g_tri.cpp
+++ b/libs/SSystem/SComponent/c_m3d_g_tri.cpp
@@ -1,31 +1,33 @@
/* c_m3d_g_tri.cpp autogenerated by split.py v0.3 at 2021-01-01 14:55:53.593962 */
#include "SComponent/c_m3d_g_tri.h"
+#include "SComponent/c_m3d.h"
// cross__8cM3dGTriCFPC8cM3dGCylP3Vec
-// cM3dGTri::cross(const cM3dGCyl*, Vec*) const
-asm bool cM3dGTri::cross(const cM3dGCyl*, Vec*) const {
- nofralloc
-#include "SComponent/c_m3d_g_tri/asm/func_8026F7B0.s"
+bool cM3dGTri::cross(const cM3dGCyl* pCylinder, Vec* out) const {
+ return cM3d_Cross_CylTri(pCylinder, this, out);
}
// setPos__8cM3dGTriFPC3VecPC3VecPC3Vec
-// cM3dGTri::setPos(const Vec*, const Vec*, const Vec*)
-asm void cM3dGTri::setPos(const Vec*, const Vec*, const Vec*) {
- nofralloc
-#include "SComponent/c_m3d_g_tri/asm/func_8026F7DC.s"
+void cM3dGTri::setPos(const Vec* pA, const Vec* pB, const Vec* pC) {
+ mA = *pA;
+ mB = *pB;
+ mC = *pC;
+ cM3d_CalcPla(&mA, &mB, &mC, &mPlane.mNormal, &mPlane.mD);
}
// setBg__8cM3dGTriFPC3VecPC3VecPC3VecPC8cM3dGPla
-// cM3dGTri::setBg(const Vec*, const Vec*, const Vec*, const cM3dGPla*)
-asm void cM3dGTri::setBg(const Vec*, const Vec*, const Vec*, const cM3dGPla*) {
- nofralloc
-#include "SComponent/c_m3d_g_tri/asm/func_8026F85C.s"
+void cM3dGTri::setBg(const Vec* pA, const Vec* pB, const Vec* pC, const cM3dGPla* pPlane) {
+ mA = *pA;
+ mB = *pB;
+ mC = *pC;
+ mPlane.Set(pPlane);
}
// set__8cM3dGTriFPC3VecPC3VecPC3VecPC3Vec
-// cM3dGTri::set(const Vec*, const Vec*, const Vec*, const Vec*)
-asm void cM3dGTri::set(const Vec*, const Vec*, const Vec*, const Vec*) {
- nofralloc
-#include "SComponent/c_m3d_g_tri/asm/func_8026F8C8.s"
+void cM3dGTri::set(const Vec* pA, const Vec* pB, const Vec* pC, const Vec* pNormal) {
+ mA = *pA;
+ mB = *pB;
+ mC = *pC;
+ mPlane.SetupNP(*pNormal, *pA);
}
diff --git a/libs/SSystem/SComponent/c_sxyz.cpp b/libs/SSystem/SComponent/c_sxyz.cpp
index a1b6ac82c8..8ec5ea17ca 100644
--- a/libs/SSystem/SComponent/c_sxyz.cpp
+++ b/libs/SSystem/SComponent/c_sxyz.cpp
@@ -2,6 +2,9 @@
#include "SComponent/c_sxyz.h"
+extern u8 lbl_804550A0;
+extern u8 lbl_80430DA8;
+
// __ct__5csXyzFsss
csXyz::csXyz(s16 pX, s16 pY, s16 pZ) {
mX = pX;
@@ -28,11 +31,11 @@ csXyz csXyz::operator-(csXyz& other) {
// __ml__5csXyzFf
#ifdef NON_MATCHING
-csXyz csXyz::operator*(float pFactor) {
+csXyz csXyz::operator*(f32 pFactor) {
return csXyz(mX * pFactor, mY * pFactor, mZ * pFactor);
}
#else
-asm csXyz csXyz::operator*(float) {
+asm csXyz csXyz::operator*(f32) {
nofralloc
#include "SComponent/c_sxyz/asm/func_802674E8.s"
}
diff --git a/libs/SSystem/SComponent/c_xyz.cpp b/libs/SSystem/SComponent/c_xyz.cpp
index fa266902f8..3d398f6a97 100644
--- a/libs/SSystem/SComponent/c_xyz.cpp
+++ b/libs/SSystem/SComponent/c_xyz.cpp
@@ -17,7 +17,7 @@ cXyz cXyz::operator-(const Vec& vec) const {
}
// __ml__4cXyzCFf
-cXyz cXyz::operator*(float scale) const {
+cXyz cXyz::operator*(f32 scale) const {
Vec ret;
PSVECScale(this, &ret, scale);
return cXyz(ret);
@@ -37,7 +37,7 @@ cXyz cXyz::operator*(const Vec& vec) const {
}
// __dv__4cXyzCFf
-cXyz cXyz::operator/(float scale) const {
+cXyz cXyz::operator/(f32 scale) const {
Vec ret;
PSVECScale(this, &ret, /* 1.0 */ lbl_80455070 / scale);
return cXyz(ret);
@@ -90,12 +90,12 @@ cXyz cXyz::normZC(void) const {
if (!local_40.checkEpsilon()) {
cXyz ret;
// ret.baseZ();
- float v = lbl_80455080;
+ f32 v = lbl_80455080;
ret.x = v;
ret.y = v;
v = lbl_80455070;
ret.z = v;
- // should do a struct copy with word and not float loads
+ // should do a struct copy with word and not f32 loads
vec = lbl_8039A868;
vec = ret;
}
@@ -147,14 +147,14 @@ bool cXyz::operator!=(const Vec& vec) const {
// isZero__4cXyzCFv
bool cXyz::isZero(void) const {
- // return (float)fabsf(this->x) < lbl_80455084 * lbl_80450AEC &&
- // (float)fabsf(this->y) < lbl_80455084 * lbl_80450AEC &&
- // (float)fabsf(this->z) < lbl_80455084 * lbl_80450AEC;
- return (float)fabsf(this->x) <
+ // return (f32)fabsf(this->x) < lbl_80455084 * lbl_80450AEC &&
+ // (f32)fabsf(this->y) < lbl_80455084 * lbl_80450AEC &&
+ // (f32)fabsf(this->z) < lbl_80455084 * lbl_80450AEC;
+ return fabsf(this->x) <
/* 32 */ lbl_80455084 *
- /* MSL_C.PPCEABI.bare.H::__float_epsilon */ *(float*)0x80450AEC &&
- (float)fabsf(this->y) < lbl_80455084 * *(float*)0x80450AEC &&
- (float)fabsf(this->z) < lbl_80455084 * *(float*)0x80450AEC;
+ /* MSL_C.PPCEABI.bare.H::__f32_epsilon */ *(f32*)0x80450AEC &&
+ fabsf(this->y) < lbl_80455084 * *(f32*)0x80450AEC &&
+ fabsf(this->z) < lbl_80455084 * *(f32*)0x80450AEC;
}
// atan2sX_Z__4cXyzCFv