diff --git a/include/SSystem/SComponent/c_m3d.h b/include/SSystem/SComponent/c_m3d.h index 58bb9f192..b50854945 100644 --- a/include/SSystem/SComponent/c_m3d.h +++ b/include/SSystem/SComponent/c_m3d.h @@ -3,6 +3,7 @@ #include "MSL_C/math.h" #include "dolphin/types.h" +#include "dolphin/mtx/vec.h" class cM3dGAab; class cM3dGCps; @@ -19,40 +20,38 @@ struct Vec; extern f32 G_CM3D_F_ABS_MIN; -static void cM3d_InDivPos1(const Vec*, const Vec*, f32, Vec*); +void cM3d_InDivPos1(const Vec*, const Vec*, f32, Vec*); void cM3d_InDivPos2(const Vec*, const Vec*, f32, Vec*); f32 cM3d_Len2dSq(f32, f32, f32, f32); bool cM3d_Len2dSqPntAndSegLine(f32, f32, f32, f32, f32, f32, f32*, f32*, f32*); bool cM3d_Len3dSqPntAndSegLine(const cM3dGLin*, const Vec*, Vec*, f32*); f32 cM3d_SignedLenPlaAndPos(const cM3dGPla*, const Vec*); f32 cM3d_VectorProduct2d(f32, f32, f32, f32, f32, f32); -void cM3d_VectorProduct(const cXyz*, const cXyz*, const cXyz*, cXyz*); void cM3d_CalcPla(const Vec*, const Vec*, const Vec*, Vec*, f32*); bool cM3d_Cross_AabAab(const cM3dGAab*, const cM3dGAab*); bool cM3d_Cross_AabCyl(const cM3dGAab*, const cM3dGCyl*); bool cM3d_Cross_AabSph(const cM3dGAab*, const cM3dGSph*); -static int cM3d_Check_LinLin(const cM3dGLin*, const cM3dGLin*, f32*, f32*); -static bool cM3d_CrossInfLineVsInfPlane_proc(f32, f32, const Vec*, const Vec*, Vec*); +int cM3d_Check_LinLin(const cM3dGLin*, const cM3dGLin*, f32*, f32*); bool cM3d_Cross_LinPla(const cM3dGLin*, const cM3dGPla*, Vec*, bool, bool); bool cM3d_Cross_MinMaxBoxLine(const Vec*, const Vec*, const Vec*, const Vec*); -static bool cM3d_InclusionCheckPosIn3PosBox3d(const Vec*, const Vec*, const Vec*, const Vec*, f32); -static bool cM3d_InclusionCheckPosIn3PosBox2d(f32, f32, f32, f32, f32, f32, f32, f32, f32); -static bool cM3d_CrossX_Tri(const cM3dGTri*, const Vec*, f32); -static bool cM3d_CrossX_Tri(const cM3dGTri*, const Vec*); -static bool cM3d_CrossX_LinTri_proc(const cM3dGTri*, const Vec*); +bool cM3d_InclusionCheckPosIn3PosBox3d(const Vec*, const Vec*, const Vec*, const Vec*, f32); +bool cM3d_InclusionCheckPosIn3PosBox2d(f32, f32, f32, f32, f32, f32, f32, f32, f32); +bool cM3d_CrossX_Tri(const cM3dGTri*, const Vec*, f32); +bool cM3d_CrossX_Tri(const cM3dGTri*, const Vec*); +bool cM3d_CrossX_LinTri_proc(const cM3dGTri*, const Vec*); bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*); -static bool cM3d_CrossY_LinTri_proc(const cM3dGTri*, const Vec*); +bool cM3d_CrossY_LinTri_proc(const cM3dGTri*, const Vec*); bool cM3d_CrossY_Tri(const Vec&, const Vec&, const Vec&, const cM3dGPla&, const Vec*); bool cM3d_CrossY_Tri_Front(const Vec&, const Vec&, const Vec&, const Vec*); -static bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, f32*); -static bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, f32); -static bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, const cM3d_Range*, f32*); -static bool cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*, f32); -static bool cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*); -static bool cM3d_CrossZ_LinTri_proc(const cM3dGTri*, const Vec*); +bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, f32*); +bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, f32); +bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, const cM3d_Range*, f32*); +bool cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*, f32); +bool cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*); +bool cM3d_CrossZ_LinTri_proc(const cM3dGTri*, const Vec*); bool cM3d_Cross_LinTri(const cM3dGLin*, const cM3dGTri*, Vec*, bool, bool); -static bool cM3d_Cross_LinTri_Easy(const cM3dGTri*, const Vec*); -static bool cM3d_Cross_SphPnt(const cM3dGSph*, const Vec*); +bool cM3d_Cross_LinTri_Easy(const cM3dGTri*, const Vec*); +bool cM3d_Cross_SphPnt(const cM3dGSph*, const Vec*); bool cM3d_Cross_LinSph(const cM3dGLin*, const cM3dGSph*, Vec*); int cM3d_Cross_LinSph_CrossPos(const cM3dGSph&, const cM3dGLin&, Vec*, Vec*); bool cM3d_Cross_CylSph(const cM3dGCyl*, const cM3dGSph*, f32*); @@ -60,7 +59,7 @@ bool cM3d_Cross_CylSph(const cM3dGCyl*, const cM3dGSph*, Vec*, f32*); bool cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, f32*); bool cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, f32*, f32*); bool cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, Vec*); -static void cM3d_CalcSphVsTriCrossPoint(const cM3dGSph*, const cM3dGTri*, Vec*); +void cM3d_CalcSphVsTriCrossPoint(const cM3dGSph*, const cM3dGTri*, Vec*); bool cM3d_Cross_SphTri(const cM3dGSph*, const cM3dGTri*, Vec*); inline bool cM3d_Cross_SphTri(const cM3dGSph* param_0, const cM3dGTri* param_1) { return cM3d_Cross_SphTri(param_0, param_1, NULL); @@ -69,18 +68,18 @@ bool cM3d_Cross_CylCyl(const cM3dGCyl*, const cM3dGCyl*, f32*); bool cM3d_Cross_CylCyl(const cM3dGCyl*, const cM3dGCyl*, Vec*); bool cM3d_Cross_CylTri(const cM3dGCyl*, const cM3dGTri*, Vec*); int cM3d_Cross_CylLin(const cM3dGCyl*, const cM3dGLin*, Vec*, Vec*); -static int cM3d_Cross_CylPntPnt(const cM3dGCyl*, const Vec*, const Vec*, Vec*, Vec*); -static bool cM3d_Cross_CylPnt(const cM3dGCyl*, const Vec*); +int cM3d_Cross_CylPntPnt(const cM3dGCyl*, const Vec*, const Vec*, Vec*, Vec*); +bool cM3d_Cross_CylPnt(const cM3dGCyl*, const Vec*); bool cM3d_Cross_CpsCps(const cM3dGCps&, const cM3dGCps&, Vec*); bool cM3d_Cross_CpsCyl(const cM3dGCps&, const cM3dGCyl&, Vec*); -static bool cM3d_Cross_CpsSph_CrossPos(const cM3dGCps&, const cM3dGSph&, const Vec&, Vec*); +bool cM3d_Cross_CpsSph_CrossPos(const cM3dGCps&, const cM3dGSph&, const Vec&, Vec*); bool cM3d_Cross_CpsSph(const cM3dGCps&, const cM3dGSph&, Vec*); bool cM3d_Cross_TriTri(const cM3dGTri&, const cM3dGTri&, Vec*); bool cM3d_Cross_CpsTri(const cM3dGCps&, cM3dGTri, Vec*); void cM3d_CalcVecAngle(const Vec&, short*, short*); void cM3d_CalcVecZAngle(const Vec&, csXyz*); -static void cM3d_PlaneCrossLineProcWork(f32, f32, f32, f32, f32, f32, f32, f32*, f32*); -static int cM3d_2PlaneCrossLine(const cM3dGPla&, const cM3dGPla&, cM3dGLin*); +void cM3d_PlaneCrossLineProcWork(f32, f32, f32, f32, f32, f32, f32, f32*, f32*); +int cM3d_2PlaneCrossLine(const cM3dGPla&, const cM3dGPla&, cM3dGLin*); bool cM3d_3PlaneCrossPos(const cM3dGPla&, const cM3dGPla&, const cM3dGPla&, Vec*); f32 cM3d_lineVsPosSuisenCross(const cM3dGLin*, const Vec*, Vec*); f32 cM3d_lineVsPosSuisenCross(const Vec&, const Vec&, const Vec&, Vec*); @@ -95,4 +94,25 @@ inline bool cM3d_IsZero_inverted(f32 param_0) { return !(fabsf(param_0) < G_CM3D_F_ABS_MIN); } -#endif \ No newline at end of file +inline void cM3d_VectorProduct(const Vec* p01, const Vec* p02, Vec* pDst) { + VECCrossProduct(p01, p02, pDst); +} + +inline void cM3d_VectorProduct(const Vec* p0, const Vec* p1, const Vec* p2, Vec* pDst) { + Vec v01, v02; + VECSubtract(p1, p0, &v01); + VECSubtract(p2, p0, &v02); + VECCrossProduct(&v01, &v02, pDst); +} + +inline bool cM3d_CrossInfLineVsInfPlane_proc(f32 a, f32 b, const Vec* pA, const Vec* pB, Vec* pDst) { + if (cM3d_IsZero(a - b)) { + *pDst = *pB; + return false; + } else { + cM3d_InDivPos2(pA, pB, a / (a - b), pDst); + return true; + } +} + +#endif diff --git a/include/SSystem/SComponent/c_m3d_g_lin.h b/include/SSystem/SComponent/c_m3d_g_lin.h index 43f6e4788..94d7683dd 100644 --- a/include/SSystem/SComponent/c_m3d_g_lin.h +++ b/include/SSystem/SComponent/c_m3d_g_lin.h @@ -26,10 +26,11 @@ class cM3dGLin { void CalcPos(Vec*, f32) const; void CalcVec(Vec* pOut) const { VECSubtract(&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; } + const cXyz& GetStartP() const { return mStart; } + cXyz& GetStartP() { return mStart; } + cXyz& GetStart() { return mStart; } + const cXyz& GetEndP() const { return mEnd; } + cXyz& GetEndP() { return mEnd; } cXyz& GetEnd() { return mEnd; } }; // Size = 0x1C diff --git a/include/SSystem/SComponent/c_m3d_g_pla.h b/include/SSystem/SComponent/c_m3d_g_pla.h index 97e388730..e83ff7d35 100644 --- a/include/SSystem/SComponent/c_m3d_g_pla.h +++ b/include/SSystem/SComponent/c_m3d_g_pla.h @@ -2,6 +2,7 @@ #define C_M3D_G_PLA_H_ #include "SSystem/SComponent/c_xyz.h" +#include "dolphin/mtx/vec.h" // Plane with a normal class cM3dGPla { @@ -13,6 +14,10 @@ class cM3dGPla { cM3dGPla() {} void CalcAngleXz(short* pAngleX, short* pAngleY) const; void SetupNP0(const Vec&, const Vec&); + f32 getPlaneFunc(const Vec *p) const { + return mD + VECDotProduct(&mNormal, p); + } + const cXyz * GetNP() const { return &mNormal; } virtual ~cM3dGPla() {} }; diff --git a/src/SSystem/SComponent/c_m3d.cpp b/src/SSystem/SComponent/c_m3d.cpp index d330c1723..f14cc74f8 100644 --- a/src/SSystem/SComponent/c_m3d.cpp +++ b/src/SSystem/SComponent/c_m3d.cpp @@ -4,170 +4,195 @@ // #include "SSystem/SComponent/c_m3d.h" -#include "dolphin/types.h" +#include "SSystem/SComponent/c_m3d_g_aab.h" +#include "SSystem/SComponent/c_m3d_g_cir.h" +#include "SSystem/SComponent/c_m3d_g_cps.h" +#include "SSystem/SComponent/c_m3d_g_cyl.h" +#include "SSystem/SComponent/c_m3d_g_lin.h" +#include "SSystem/SComponent/c_m3d_g_pla.h" +#include "SSystem/SComponent/c_m3d_g_sph.h" +#include "SSystem/SComponent/c_m3d_g_tri.h" /* 8024A400-8024A450 .text cM3d_InDivPos1__FPC3VecPC3VecfP3Vec */ -void cM3d_InDivPos1(const Vec*, const Vec*, float, Vec*) { - /* Nonmatching */ +void cM3d_InDivPos1(const Vec* v0, const Vec* v1, f32 scale, Vec* pDst) { + Vec tmp; + VECScale(v1, &tmp, scale); + VECAdd(&tmp, v0, pDst); } /* 8024A450-8024A4B4 .text cM3d_InDivPos2__FPC3VecPC3VecfP3Vec */ -void cM3d_InDivPos2(const Vec*, const Vec*, float, Vec*) { - /* Nonmatching */ +void cM3d_InDivPos2(const Vec* v0, const Vec* v1, f32 scale, Vec* pDst) { + Vec tmp; + VECSubtract(v1, v0, &tmp); + cM3d_InDivPos1(v0, &tmp, scale, pDst); } /* 8024A4B4-8024A56C .text cM3d_Len2dSqPntAndSegLine__FffffffPfPfPf */ -void cM3d_Len2dSqPntAndSegLine(float, float, float, float, float, float, float*, float*, float*) { +bool cM3d_Len2dSqPntAndSegLine(f32, f32, f32, f32, f32, f32, f32*, f32*, f32*) { /* Nonmatching */ } /* 8024A56C-8024A670 .text cM3d_Len3dSqPntAndSegLine__FPC8cM3dGLinPC3VecP3VecPf */ -void cM3d_Len3dSqPntAndSegLine(const cM3dGLin*, const Vec*, Vec*, float*) { +bool cM3d_Len3dSqPntAndSegLine(const cM3dGLin*, const Vec*, Vec*, f32*) { /* Nonmatching */ } /* 8024A670-8024A6F0 .text cM3d_SignedLenPlaAndPos__FPC8cM3dGPlaPC3Vec */ -void cM3d_SignedLenPlaAndPos(const cM3dGPla*, const Vec*) { - /* Nonmatching */ +f32 cM3d_SignedLenPlaAndPos(const cM3dGPla* plane, const Vec* pos) { + f32 len = VECMag(plane->GetNP()); + if (cM3d_IsZero(len)) + return 0.0f; + else + return plane->getPlaneFunc(pos) / len; } /* 8024A6F0-8024A7BC .text cM3d_CalcPla__FPC3VecPC3VecPC3VecP3VecPf */ -void cM3d_CalcPla(const Vec*, const Vec*, const Vec*, Vec*, float*) { - /* Nonmatching */ +void cM3d_CalcPla(const Vec* p0, const Vec* p1, const Vec* p2, Vec* pDst, f32* pT) { + cM3d_VectorProduct(p0, p1, p2, pDst); + f32 t = VECMag(pDst); + if (fabsf(t) >= 0.02f) { + VECScale(pDst, pDst, 1.0f / t); + *pT = -VECDotProduct(pDst, p0); + } else { + pDst->x = 0.0f; + pDst->y = 0.0f; + pDst->z = 0.0f; + *pT = 0.0f; + } } /* 8024A7BC-8024A8E0 .text cM3d_Cross_AabAab__FPC8cM3dGAabPC8cM3dGAab */ -void cM3d_Cross_AabAab(const cM3dGAab*, const cM3dGAab*) { +bool cM3d_Cross_AabAab(const cM3dGAab*, const cM3dGAab*) { /* Nonmatching */ } /* 8024A8E0-8024A988 .text cM3d_Cross_AabCyl__FPC8cM3dGAabPC8cM3dGCyl */ -void cM3d_Cross_AabCyl(const cM3dGAab*, const cM3dGCyl*) { +bool cM3d_Cross_AabCyl(const cM3dGAab*, const cM3dGCyl*) { /* Nonmatching */ } /* 8024A988-8024AA30 .text cM3d_Cross_AabSph__FPC8cM3dGAabPC8cM3dGSph */ -void cM3d_Cross_AabSph(const cM3dGAab*, const cM3dGSph*) { +bool cM3d_Cross_AabSph(const cM3dGAab*, const cM3dGSph*) { /* Nonmatching */ } /* 8024AA30-8024ACA8 .text cM3d_Check_LinLin__FPC8cM3dGLinPC8cM3dGLinPfPf */ -void cM3d_Check_LinLin(const cM3dGLin*, const cM3dGLin*, float*, float*) { +int cM3d_Check_LinLin(const cM3dGLin*, const cM3dGLin*, f32*, f32*) { /* Nonmatching */ } /* 8024ACA8-8024AE3C .text cM3d_Cross_LinPla__FPC8cM3dGLinPC8cM3dGPlaP3Vecbb */ -void cM3d_Cross_LinPla(const cM3dGLin*, const cM3dGPla*, Vec*, bool, bool) { +bool cM3d_Cross_LinPla(const cM3dGLin*, const cM3dGPla*, Vec*, bool, bool) { /* Nonmatching */ } /* 8024AE3C-8024BA18 .text cM3d_Cross_MinMaxBoxLine__FPC3VecPC3VecPC3VecPC3Vec */ -void cM3d_Cross_MinMaxBoxLine(const Vec*, const Vec*, const Vec*, const Vec*) { +bool cM3d_Cross_MinMaxBoxLine(const Vec*, const Vec*, const Vec*, const Vec*) { /* Nonmatching */ } /* 8024BA18-8024BB50 .text cM3d_InclusionCheckPosIn3PosBox3d__FPC3VecPC3VecPC3VecPC3Vecf */ -void cM3d_InclusionCheckPosIn3PosBox3d(const Vec*, const Vec*, const Vec*, const Vec*, float) { +bool cM3d_InclusionCheckPosIn3PosBox3d(const Vec*, const Vec*, const Vec*, const Vec*, f32) { /* Nonmatching */ } /* 8024BB50-8024BD34 .text cM3d_CrossX_Tri__FPC8cM3dGTriPC3Vecf */ -void cM3d_CrossX_Tri(const cM3dGTri*, const Vec*, float) { +bool cM3d_CrossX_Tri(const cM3dGTri*, const Vec*, f32) { /* Nonmatching */ } /* 8024BD34-8024BF1C .text cM3d_CrossX_Tri__FPC8cM3dGTriPC3Vec */ -void cM3d_CrossX_Tri(const cM3dGTri*, const Vec*) { +bool cM3d_CrossX_Tri(const cM3dGTri*, const Vec*) { /* Nonmatching */ } /* 8024BF1C-8024BFA0 .text cM3d_CrossX_Tri__FPC8cM3dGTriPC3VecPf */ -void cM3d_CrossX_Tri(const cM3dGTri*, const Vec*, float*) { +void cM3d_CrossX_Tri(const cM3dGTri*, const Vec*, f32*) { /* Nonmatching */ } /* 8024BFA0-8024C188 .text cM3d_CrossY_Tri__FPC8cM3dGTriPC3Vec */ -void cM3d_CrossY_Tri(const cM3dGTri*, const Vec*) { +bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*) { /* Nonmatching */ } /* 8024C188-8024C370 .text cM3d_CrossY_Tri__FRC3VecRC3VecRC3VecRC8cM3dGPlaPC3Vec */ -void cM3d_CrossY_Tri(const Vec&, const Vec&, const Vec&, const cM3dGPla&, const Vec*) { +bool cM3d_CrossY_Tri(const Vec&, const Vec&, const Vec&, const cM3dGPla&, const Vec*) { /* Nonmatching */ } /* 8024C370-8024C4D0 .text cM3d_CrossY_Tri_Front__FRC3VecRC3VecRC3VecPC3Vec */ -void cM3d_CrossY_Tri_Front(const Vec&, const Vec&, const Vec&, const Vec*) { +bool cM3d_CrossY_Tri_Front(const Vec&, const Vec&, const Vec&, const Vec*) { /* Nonmatching */ } /* 8024C4D0-8024C554 .text cM3d_CrossY_Tri__FPC8cM3dGTriPC3VecPf */ -void cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, float*) { +bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, f32*) { /* Nonmatching */ } /* 8024C554-8024C738 .text cM3d_CrossY_Tri__FPC8cM3dGTriPC3Vecf */ -void cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, float) { +bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, f32) { /* Nonmatching */ } /* 8024C738-8024C828 .text cM3d_CrossY_Tri__FPC8cM3dGTriPC3VecPC10cM3d_RangePf */ -void cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, const cM3d_Range*, float*) { +bool cM3d_CrossY_Tri(const cM3dGTri*, const Vec*, const cM3d_Range*, f32*) { /* Nonmatching */ } /* 8024C828-8024CA0C .text cM3d_CrossZ_Tri__FPC8cM3dGTriPC3Vecf */ -void cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*, float) { +bool cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*, f32) { /* Nonmatching */ } /* 8024CA0C-8024CBF4 .text cM3d_CrossZ_Tri__FPC8cM3dGTriPC3Vec */ -void cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*) { +bool cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*) { /* Nonmatching */ } /* 8024CBF4-8024CC78 .text cM3d_CrossZ_Tri__FPC8cM3dGTriPC3VecPf */ -void cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*, float*) { +void cM3d_CrossZ_Tri(const cM3dGTri*, const Vec*, f32*) { /* Nonmatching */ } /* 8024CC78-8024CD50 .text cM3d_Cross_LinTri__FPC8cM3dGLinPC8cM3dGTriP3Vecbb */ -void cM3d_Cross_LinTri(const cM3dGLin*, const cM3dGTri*, Vec*, bool, bool) { +bool cM3d_Cross_LinTri(const cM3dGLin*, const cM3dGTri*, Vec*, bool, bool) { /* Nonmatching */ } /* 8024CD50-8024CE0C .text cM3d_Cross_LinTri_Easy__FPC8cM3dGTriPC3Vec */ -void cM3d_Cross_LinTri_Easy(const cM3dGTri*, const Vec*) { +bool cM3d_Cross_LinTri_Easy(const cM3dGTri*, const Vec*) { /* Nonmatching */ } /* 8024CE0C-8024CE54 .text cM3d_Cross_SphPnt__FPC8cM3dGSphPC3Vec */ -void cM3d_Cross_SphPnt(const cM3dGSph*, const Vec*) { +bool cM3d_Cross_SphPnt(const cM3dGSph*, const Vec*) { /* Nonmatching */ } /* 8024CE54-8024D0BC .text cM3d_Cross_LinSph__FPC8cM3dGLinPC8cM3dGSphP3Vec */ -void cM3d_Cross_LinSph(const cM3dGLin*, const cM3dGSph*, Vec*) { +bool cM3d_Cross_LinSph(const cM3dGLin*, const cM3dGSph*, Vec*) { /* Nonmatching */ } /* 8024D0BC-8024D378 .text cM3d_Cross_LinSph_CrossPos__FRC8cM3dGSphRC8cM3dGLinP3VecP3Vec */ -void cM3d_Cross_LinSph_CrossPos(const cM3dGSph&, const cM3dGLin&, Vec*, Vec*) { +int cM3d_Cross_LinSph_CrossPos(const cM3dGSph&, const cM3dGLin&, Vec*, Vec*) { /* Nonmatching */ } /* 8024D378-8024DB34 .text cM3d_Cross_CylSph__FPC8cM3dGCylPC8cM3dGSphP3VecPf */ -void cM3d_Cross_CylSph(const cM3dGCyl*, const cM3dGSph*, Vec*, float*) { +bool cM3d_Cross_CylSph(const cM3dGCyl*, const cM3dGSph*, Vec*, f32*) { /* Nonmatching */ } /* 8024DB34-8024E1B4 .text cM3d_Cross_SphSph__FPC8cM3dGSphPC8cM3dGSphPfPf */ -void cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, float*, float*) { +bool cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, f32*, f32*) { /* Nonmatching */ } /* 8024E1B4-8024E288 .text cM3d_Cross_SphSph__FPC8cM3dGSphPC8cM3dGSphP3Vec */ -void cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, Vec*) { +bool cM3d_Cross_SphSph(const cM3dGSph*, const cM3dGSph*, Vec*) { /* Nonmatching */ } @@ -177,67 +202,67 @@ void cM3d_CalcSphVsTriCrossPoint(const cM3dGSph*, const cM3dGTri*, Vec*) { } /* 8024E330-8024E694 .text cM3d_Cross_SphTri__FPC8cM3dGSphPC8cM3dGTriP3Vec */ -void cM3d_Cross_SphTri(const cM3dGSph*, const cM3dGTri*, Vec*) { +bool cM3d_Cross_SphTri(const cM3dGSph*, const cM3dGTri*, Vec*) { /* Nonmatching */ } /* 8024E694-8024EF80 .text cM3d_Cross_CylCyl__FPC8cM3dGCylPC8cM3dGCylPf */ -void cM3d_Cross_CylCyl(const cM3dGCyl*, const cM3dGCyl*, float*) { +bool cM3d_Cross_CylCyl(const cM3dGCyl*, const cM3dGCyl*, f32*) { /* Nonmatching */ } /* 8024EF80-8024F11C .text cM3d_Cross_CylCyl__FPC8cM3dGCylPC8cM3dGCylP3Vec */ -void cM3d_Cross_CylCyl(const cM3dGCyl*, const cM3dGCyl*, Vec*) { +bool cM3d_Cross_CylCyl(const cM3dGCyl*, const cM3dGCyl*, Vec*) { /* Nonmatching */ } /* 8024F11C-8024F410 .text cM3d_Cross_CylTri__FPC8cM3dGCylPC8cM3dGTriP3Vec */ -void cM3d_Cross_CylTri(const cM3dGCyl*, const cM3dGTri*, Vec*) { +bool cM3d_Cross_CylTri(const cM3dGCyl*, const cM3dGTri*, Vec*) { /* Nonmatching */ } /* 8024F410-8024FA90 .text cM3d_Cross_CylLin__FPC8cM3dGCylPC8cM3dGLinP3VecP3Vec */ -void cM3d_Cross_CylLin(const cM3dGCyl*, const cM3dGLin*, Vec*, Vec*) { +int cM3d_Cross_CylLin(const cM3dGCyl*, const cM3dGLin*, Vec*, Vec*) { /* Nonmatching */ } /* 8024FA90-8024FB04 .text cM3d_Cross_CylPntPnt__FPC8cM3dGCylPC3VecPC3VecP3VecP3Vec */ -void cM3d_Cross_CylPntPnt(const cM3dGCyl*, const Vec*, const Vec*, Vec*, Vec*) { +int cM3d_Cross_CylPntPnt(const cM3dGCyl*, const Vec*, const Vec*, Vec*, Vec*) { /* Nonmatching */ } /* 8024FB04-8024FB68 .text cM3d_Cross_CylPnt__FPC8cM3dGCylPC3Vec */ -void cM3d_Cross_CylPnt(const cM3dGCyl*, const Vec*) { +bool cM3d_Cross_CylPnt(const cM3dGCyl*, const Vec*) { /* Nonmatching */ } /* 8024FB68-8024FF10 .text cM3d_Cross_CpsCps__FRC8cM3dGCpsRC8cM3dGCpsP3Vec */ -void cM3d_Cross_CpsCps(const cM3dGCps&, const cM3dGCps&, Vec*) { +bool cM3d_Cross_CpsCps(const cM3dGCps&, const cM3dGCps&, Vec*) { /* Nonmatching */ } /* 8024FF10-802506D4 .text cM3d_Cross_CpsCyl__FRC8cM3dGCpsRC8cM3dGCylP3Vec */ -void cM3d_Cross_CpsCyl(const cM3dGCps&, const cM3dGCyl&, Vec*) { +bool cM3d_Cross_CpsCyl(const cM3dGCps&, const cM3dGCyl&, Vec*) { /* Nonmatching */ } /* 802506D4-80250840 .text cM3d_Cross_CpsSph_CrossPos__FRC8cM3dGCpsRC8cM3dGSphRC3VecP3Vec */ -void cM3d_Cross_CpsSph_CrossPos(const cM3dGCps&, const cM3dGSph&, const Vec&, Vec*) { +bool cM3d_Cross_CpsSph_CrossPos(const cM3dGCps&, const cM3dGSph&, const Vec&, Vec*) { /* Nonmatching */ } /* 80250840-802509B0 .text cM3d_Cross_CpsSph__FRC8cM3dGCpsRC8cM3dGSphP3Vec */ -void cM3d_Cross_CpsSph(const cM3dGCps&, const cM3dGSph&, Vec*) { +bool cM3d_Cross_CpsSph(const cM3dGCps&, const cM3dGSph&, Vec*) { /* Nonmatching */ } /* 802509B0-80250D70 .text cM3d_Cross_TriTri__FRC8cM3dGTriRC8cM3dGTriP3Vec */ -void cM3d_Cross_TriTri(const cM3dGTri&, const cM3dGTri&, Vec*) { +bool cM3d_Cross_TriTri(const cM3dGTri&, const cM3dGTri&, Vec*) { /* Nonmatching */ } /* 80250D70-80251280 .text cM3d_Cross_CpsTri__FRC8cM3dGCps8cM3dGTriP3Vec */ -void cM3d_Cross_CpsTri(const cM3dGCps&, cM3dGTri, Vec*) { +bool cM3d_Cross_CpsTri(const cM3dGCps&, cM3dGTri, Vec*) { /* Nonmatching */ } @@ -257,41 +282,58 @@ void cM3d_CalcVecZAngle(const Vec&, csXyz*) { } /* 80251634-8025172C .text cM3d_UpMtx_Base__FRC3VecRC3VecPA4_f */ -void cM3d_UpMtx_Base(const Vec&, const Vec&, float(*)[4]) { +void cM3d_UpMtx_Base(const Vec&, const Vec&, f32(*)[4]) { /* Nonmatching */ } /* 8025172C-80251758 .text cM3d_PlaneCrossLineProcWork__FfffffffPfPf */ -void cM3d_PlaneCrossLineProcWork(float, float, float, float, float, float, float, float*, float*) { - /* Nonmatching */ +void cM3d_PlaneCrossLineProcWork(f32 v0, f32 v1, f32 v2, f32 v3, f32 v4, f32 v5, f32 v6, f32* p0, f32* p1) { + *p0 = (v1 * v6 - v3 * v5) / v4; + *p1 = (v2 * v5 - v0 * v6) / v4; } /* 80251758-802518F0 .text cM3d_2PlaneCrossLine__FRC8cM3dGPlaRC8cM3dGPlaP8cM3dGLin */ -void cM3d_2PlaneCrossLine(const cM3dGPla&, const cM3dGPla&, cM3dGLin*) { +int cM3d_2PlaneCrossLine(const cM3dGPla&, const cM3dGPla&, cM3dGLin*) { /* Nonmatching */ } /* 802518F0-80251A10 .text cM3d_3PlaneCrossPos__FRC8cM3dGPlaRC8cM3dGPlaRC8cM3dGPlaP3Vec */ -void cM3d_3PlaneCrossPos(const cM3dGPla&, const cM3dGPla&, const cM3dGPla&, Vec*) { - /* Nonmatching */ +bool cM3d_3PlaneCrossPos(const cM3dGPla& p0, const cM3dGPla& p1, const cM3dGPla& p2, Vec* pDst) { + cM3dGLin lin; + if (!cM3d_2PlaneCrossLine(p0, p1, &lin)) + return false; + + Vec& start = lin.GetStart(); + Vec& end = lin.GetEnd(); + if (!cM3d_CrossInfLineVsInfPlane_proc(p2.getPlaneFunc(&start), p2.getPlaneFunc(&end), &start, &end, pDst)) + return false; + + return true; } /* 80251A10-80251AE4 .text cM3d_lineVsPosSuisenCross__FPC8cM3dGLinPC3VecP3Vec */ -void cM3d_lineVsPosSuisenCross(const cM3dGLin*, const Vec*, Vec*) { +f32 cM3d_lineVsPosSuisenCross(const cM3dGLin*, const Vec*, Vec*) { /* Nonmatching */ } /* 80251AE4-80251BC0 .text cM3d_lineVsPosSuisenCross__FRC3VecRC3VecRC3VecP3Vec */ -void cM3d_lineVsPosSuisenCross(const Vec&, const Vec&, const Vec&, Vec*) { +f32 cM3d_lineVsPosSuisenCross(const Vec&, const Vec&, const Vec&, Vec*) { /* Nonmatching */ } /* 80251BC0-80251C44 .text cM3d_2PlaneLinePosNearPos__FRC8cM3dGPlaRC8cM3dGPlaPC3VecP3Vec */ -void cM3d_2PlaneLinePosNearPos(const cM3dGPla&, const cM3dGPla&, const Vec*, Vec*) { - /* Nonmatching */ +int cM3d_2PlaneLinePosNearPos(const cM3dGPla& p0, const cM3dGPla& p1, const Vec* line, Vec* pDst) { + cM3dGLin lin; + s32 ret = cM3d_2PlaneCrossLine(p0, p1, &lin); + if (ret != 0) + cM3d_lineVsPosSuisenCross(&lin, line, pDst); + return ret != 0; } /* 80251C44-80251CC4 .text cM3d_CrawVec__FRC3VecRC3VecP3Vec */ -void cM3d_CrawVec(const Vec&, const Vec&, Vec*) { - /* Nonmatching */ +void cM3d_CrawVec(const Vec& v0, const Vec& v1, Vec* pDst) { + Vec tmp; + f32 sq = fabsf(v1.x * v0.x + v1.y * v0.y + v1.z * v0.z); + VECScale(&v0, &tmp, sq); + VECAdd(&tmp, &v1, pDst); }