c_m3d done except for regalloc

This commit is contained in:
LagoLunatic
2025-02-05 18:04:26 -05:00
parent 9875a39ee6
commit 7297cbaf38
5 changed files with 1138 additions and 72 deletions
+33 -2
View File
@@ -1,7 +1,7 @@
#ifndef C_M3D_H_
#define C_M3D_H_
#include "math.h"
#include "math.h" // IWYU pragma: keep
#include "dolphin/types.h"
#include "dolphin/mtx/vec.h"
#include "dolphin/mtx/mtx.h"
@@ -20,6 +20,33 @@ struct Vec;
extern const f32 G_CM3D_F_ABS_MIN;
extern const u32 BPCP_OUTCODE0;
extern const u32 BPCP_OUTCODE1;
extern const u32 BPCP_OUTCODE4;
extern const u32 BPCP_OUTCODE5;
extern const u32 BPCP_OUTCODE2;
extern const u32 BPCP_OUTCODE3;
extern const u32 BEVEL2D_OUTCODE0;
extern const u32 BEVEL2D_OUTCODE1;
extern const u32 BEVEL2D_OUTCODE2;
extern const u32 BEVEL2D_OUTCODE3;
extern const u32 BEVEL2D_OUTCODE4;
extern const u32 BEVEL2D_OUTCODE5;
extern const u32 BEVEL2D_OUTCODE6;
extern const u32 BEVEL2D_OUTCODE7;
extern const u32 BEVEL2D_OUTCODE8;
extern const u32 BEVEL2D_OUTCODE9;
extern const u32 BEVEL2D_OUTCODE10;
extern const u32 BEVEL2D_OUTCODE11;
extern const u32 BEVEL3D_OUTCODE0;
extern const u32 BEVEL3D_OUTCODE1;
extern const u32 BEVEL3D_OUTCODE2;
extern const u32 BEVEL3D_OUTCODE3;
extern const u32 BEVEL3D_OUTCODE4;
extern const u32 BEVEL3D_OUTCODE5;
extern const u32 BEVEL3D_OUTCODE6;
extern const u32 BEVEL3D_OUTCODE7;
struct cM3d_Range {
f32 start;
f32 end;
@@ -90,7 +117,7 @@ f32 cM3d_lineVsPosSuisenCross(const cM3dGLin*, const Vec*, Vec*);
f32 cM3d_lineVsPosSuisenCross(const Vec&, const Vec&, const Vec&, Vec*);
int cM3d_2PlaneLinePosNearPos(const cM3dGPla&, const cM3dGPla&, const Vec*, Vec*);
void cM3d_CrawVec(const Vec&, const Vec&, Vec*);
void cM3d_UpMtx_Base(const Vec&, const Vec&, MtxP);
int cM3d_UpMtx_Base(const Vec&, const Vec&, MtxP);
inline bool cM3d_IsZero(f32 f) {
return std::fabsf(f) < G_CM3D_F_ABS_MIN;
@@ -121,4 +148,8 @@ inline bool cM3d_CrossInfLineVsInfPlane_proc(f32 a, f32 b, const Vec* pA, const
}
}
inline f32 cM3d_LenSq(const Vec* a, const Vec* b) {
return VECSquareDistance(a, b);
}
#endif
+8 -3
View File
@@ -13,7 +13,7 @@ private:
public:
cM3dGLin() {}
cM3dGLin(const cXyz&, const cXyz&);
cM3dGLin(const cXyz& start, const cXyz& end) : mStart(start), mEnd(end) {}
virtual ~cM3dGLin() {}
void SetStartEnd(const cXyz& start, const cXyz& end) {
mStart = start;
@@ -27,7 +27,12 @@ public:
mStart = start;
mEnd = end;
}
void CalcPos(Vec*, f32) const { /* TODO */ }
void CalcPos(Vec* out, f32 scale) const {
Vec tmp;
VECSubtract(&mEnd, &mStart, &tmp);
VECScale(&tmp, &tmp, scale);
VECAdd(&tmp, &mStart, out);
}
void CalcVec(Vec* pOut) const { VECSubtract(&this->mEnd, &this->mStart, pOut); }
void SetEnd(const cXyz& pos) { mEnd = pos; }
const cXyz* GetStartP() const { return &mStart; }
@@ -43,4 +48,4 @@ public:
STATIC_ASSERT(0x1C == sizeof(cM3dGLin));
#endif /* C_M3D_G_LIN_H */
#endif /* C_M3D_G_LIN_H */
+3 -1
View File
@@ -51,12 +51,14 @@ public:
void SetupFrom3Vtx(const Vec* a, const Vec* b, const Vec* c) {
cM3d_CalcPla(a, b, c, &mNormal, &mD);
}
bool cross(const cM3dGLin& line, Vec& point) const {
return cM3d_Cross_LinPla(&line, this, &point, true, true);
}
virtual ~cM3dGPla() {}
// TODO
cM3dGPla(const cXyz*, f32) {}
void cross(const cM3dGLin&, Vec&) const {}
}; // Size: 0x14
#endif
+1 -3
View File
@@ -36,9 +36,7 @@ void C_MTXLightPerspective(Mtx m, f32 fovY, f32 aspect, f32 scale_s, f32 scale_t
void C_MTXLightOrtho(Mtx m, f32 top, f32 bottom, f32 left, f32 right, f32 scale_s, f32 scale_t,
f32 trans_s, f32 trans_t);
inline void C_MTXRotAxisRad(Mtx m, const Vec* axis, f32 rad) {
PSMTXRotAxisRad(m, axis, rad);
}
void C_MTXRotAxisRad(Mtx m, const Vec* axis, f32 rad);
#define MTXDegToRad(deg) ((deg) * 0.01745329252f)
#define MTXRadToDeg(rad) ((rad) * 57.29577951f)
File diff suppressed because it is too large Load Diff