Skip to content

Commit

Permalink
cm3d work
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Oct 1, 2023
1 parent 4361fab commit 7504c94
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 92 deletions.
70 changes: 45 additions & 25 deletions include/SSystem/SComponent/c_m3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "MSL_C/math.h"
#include "dolphin/types.h"
#include "dolphin/mtx/vec.h"

class cM3dGAab;
class cM3dGCps;
Expand All @@ -19,48 +20,46 @@ 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*);
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);
Expand All @@ -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*);
Expand All @@ -95,4 +94,25 @@ inline bool cM3d_IsZero_inverted(f32 param_0) {
return !(fabsf(param_0) < G_CM3D_F_ABS_MIN);
}

#endif
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
9 changes: 5 additions & 4 deletions include/SSystem/SComponent/c_m3d_g_lin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions include/SSystem/SComponent/c_m3d_g_pla.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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() {}
};
Expand Down
Loading

0 comments on commit 7504c94

Please sign in to comment.