mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-08 20:24:47 -04:00
setup dolphin VEC/MTX function defines (#1903)
* setup VEC function defines * setup MTX function defines
This commit is contained in:
@@ -129,7 +129,7 @@ public:
|
||||
|
||||
MtxP getGlbMtx() { return mGlobalMtx; }
|
||||
|
||||
void setMtx(Mtx m) { PSMTXCopy(m, mPositionMtx); }
|
||||
void setMtx(Mtx m) { MTXCopy(m, mPositionMtx); }
|
||||
|
||||
void translate(f32 transX, f32 transY) {
|
||||
mTranslateX = transX;
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
bool isCpuSkinningOn() const { return (mFlags & J3DMdlFlag_SkinPosCpu) && (mFlags & J3DMdlFlag_SkinNrmCpu); }
|
||||
|
||||
Mtx& getBaseTRMtx() { return mBaseTransformMtx; }
|
||||
void i_setBaseTRMtx(Mtx m) { PSMTXCopy(m, mBaseTransformMtx); }
|
||||
void i_setBaseTRMtx(Mtx m) { MTXCopy(m, mBaseTransformMtx); }
|
||||
u32 getMtxCalcMode() const { return mFlags & 0x03; }
|
||||
J3DVertexBuffer* getVertexBuffer() const { return (J3DVertexBuffer*)&mVertexBuffer; }
|
||||
J3DMatPacket* getMatPacket(u16 idx) const { return &mMatPacket[idx]; }
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
/* 80326EF0 */ void calcBBoardMtx();
|
||||
|
||||
MtxP getAnmMtx(int idx) const { return mpAnmMtx[idx]; }
|
||||
void setAnmMtx(int i, Mtx m) { PSMTXCopy(m, (MtxP)mpAnmMtx[i]); }
|
||||
void setAnmMtx(int i, Mtx m) { MTXCopy(m, (MtxP)mpAnmMtx[i]); }
|
||||
MtxP getWeightAnmMtx(int idx) const { return mpWeightEvlpMtx[idx]; }
|
||||
|
||||
void setScaleFlag(int idx, u8 flag) { mpScaleFlagArr[idx] = flag; }
|
||||
|
||||
@@ -124,7 +124,7 @@ struct J3DSys {
|
||||
Mtx& getModelDrawMtx(u16 no) const { return mModelDrawMtx[no]; }
|
||||
J3DShapePacket* getShapePacket() const { return mShapePacket; }
|
||||
|
||||
void setViewMtx(Mtx m) { PSMTXCopy(m, mViewMtx); }
|
||||
void setViewMtx(Mtx m) { MTXCopy(m, mViewMtx); }
|
||||
|
||||
J3DModel* getModel() { return mModel; }
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ struct TVec3<f32> {
|
||||
}
|
||||
|
||||
f32 length() const {
|
||||
return PSVECMag((Vec*)this);
|
||||
return VECMag((Vec*)this);
|
||||
}
|
||||
|
||||
void scale(register f32 sc) {
|
||||
@@ -247,7 +247,7 @@ struct TVec3<f32> {
|
||||
}
|
||||
|
||||
void cross(const TVec3<f32>& a, const TVec3<f32>& b) {
|
||||
PSVECCrossProduct(a, b, *this);
|
||||
VECCrossProduct(a, b, *this);
|
||||
}
|
||||
|
||||
void setLength(f32 len) {
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
class JPADrawInfo {
|
||||
public:
|
||||
JPADrawInfo(Mtx param_0, f32 fovY, f32 aspect) {
|
||||
PSMTXCopy(param_0, mCamMtx);
|
||||
MTXCopy(param_0, mCamMtx);
|
||||
C_MTXLightPerspective(mPrjMtx, fovY, aspect, 0.5f, -0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
JPADrawInfo(Mtx param_0, f32 top, f32 bottom, f32 left, f32 right) {
|
||||
PSMTXCopy(param_0, mCamMtx);
|
||||
MTXCopy(param_0, mCamMtx);
|
||||
C_MTXLightOrtho(mPrjMtx, top, bottom, left, right, 0.5f, 0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
Mtx mCamMtx;
|
||||
Mtx mPrjMtx;
|
||||
|
||||
void getCamMtx(Mtx* dst) const { PSMTXCopy(mCamMtx, *dst); }
|
||||
void getPrjMtx(Mtx* dst) const { PSMTXCopy(mPrjMtx, *dst); }
|
||||
void getCamMtx(Mtx* dst) const { MTXCopy(mCamMtx, *dst); }
|
||||
void getPrjMtx(Mtx* dst) const { MTXCopy(mPrjMtx, *dst); }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -15,7 +15,7 @@ template <>
|
||||
struct SMatrix34C<f32> {
|
||||
f32 data[3][4];
|
||||
|
||||
void identity() { PSMTXIdentity(data); }
|
||||
void identity() { MTXIdentity(data); }
|
||||
|
||||
typedef f32 ArrType[4];
|
||||
void set(const ArrType* src) { JMath::gekko_ps_copy12((f32*)data, (f32*)src); }
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
void SetStartEnd(const cXyz&, const cXyz&);
|
||||
void SetStartEnd(const Vec&, const Vec&);
|
||||
void CalcPos(Vec*, f32) const;
|
||||
void CalcVec(Vec* pOut) const { PSVECSubtract(&this->mEnd, &this->mStart, pOut); }
|
||||
void 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; }
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
|
||||
virtual ~cM3dGPla() {}
|
||||
|
||||
f32 getPlaneFunc(const Vec* pPoint) const { return mD + PSVECDotProduct(&mNormal, pPoint); }
|
||||
f32 getPlaneFunc(const Vec* pPoint) const { return mD + VECDotProduct(&mNormal, pPoint); }
|
||||
const cXyz& GetNP() const { return mNormal; }
|
||||
const cXyz* i_GetNP() const { return &mNormal; }
|
||||
f32 GetD() const { return mD; }
|
||||
|
||||
@@ -52,9 +52,9 @@ struct cXyz : Vec {
|
||||
y -= f;
|
||||
z -= f;
|
||||
}
|
||||
void operator-=(const Vec& other) { PSVECSubtract(this, &other, this); }
|
||||
void operator+=(const Vec& other) { PSVECAdd(this, &other, this); }
|
||||
void operator*=(f32 scale) { PSVECScale(this, this, scale); }
|
||||
void operator-=(const Vec& other) { VECSubtract(this, &other, this); }
|
||||
void operator+=(const Vec& other) { VECAdd(this, &other, this); }
|
||||
void operator*=(f32 scale) { VECScale(this, this, scale); }
|
||||
/* 80266C6C */ cXyz getCrossProduct(Vec const&) const;
|
||||
/* 80266CBC */ cXyz outprod(Vec const&) const;
|
||||
/* 80266CE4 */ cXyz norm() const;
|
||||
@@ -111,8 +111,8 @@ struct cXyz : Vec {
|
||||
}
|
||||
}
|
||||
|
||||
float getSquareMag() const { return PSVECSquareMag(this); }
|
||||
f32 getSquareDistance(const Vec& other) const { return PSVECSquareDistance(this, &other); }
|
||||
float getSquareMag() const { return VECSquareMag(this); }
|
||||
f32 getSquareDistance(const Vec& other) const { return VECSquareDistance(this, &other); }
|
||||
|
||||
static float getNearZeroValue() { return 8e-11f; }
|
||||
|
||||
@@ -134,7 +134,7 @@ struct cXyz : Vec {
|
||||
f32 absXZ(const Vec& other) const { return sqrtf(this->abs2XZ(other)); }
|
||||
f32 getMagXZ() const { return cXyz(this->x, 0, this->z).getSquareMag(); }
|
||||
|
||||
f32 getDotProduct(const Vec& other) const { return PSVECDotProduct(this, &other); }
|
||||
f32 getDotProduct(const Vec& other) const { return VECDotProduct(this, &other); }
|
||||
f32 inprod(const Vec& other) const { return getDotProduct(other); }
|
||||
};
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ public:
|
||||
/* 8007B0B0 */ virtual bool ChkShdwDrawThrough(int, cBgS_PolyPassChk*);
|
||||
/* 8007B0DC */ virtual bool ChkGrpThrough(int, cBgS_GrpPassChk*, int);
|
||||
|
||||
u32 GetOldInvMtx(Mtx m) { return PSMTXInverse(m_inv_mtx, m); }
|
||||
u32 GetOldInvMtx(Mtx m) { return MTXInverse(m_inv_mtx, m); }
|
||||
MtxP GetBaseMtxP() { return pm_base; }
|
||||
bool ChkNoCalcVtx() { return mFlags & NO_CALC_VTX_e; }
|
||||
bool ChkFlush() { return field_0x91 & 8; }
|
||||
|
||||
@@ -40,6 +40,35 @@ inline void C_MTXRotAxisRad(Mtx m, const Vec* axis, f32 rad) {
|
||||
PSMTXRotAxisRad(m, axis, rad);
|
||||
}
|
||||
|
||||
/* When compiling in debug mode, use C implementations */
|
||||
#ifdef DEBUG
|
||||
#define MTXIdentity C_MTXIdentity
|
||||
#define MTXCopy C_MTXCopy
|
||||
#define MTXConcat C_MTXConcat
|
||||
#define MTXInverse C_MTXInverse
|
||||
#define MTXRotRad C_MTXRotRad
|
||||
#define MTXRotTrig C_MTXRotTrig
|
||||
#define MTXRotAxisRad C_MTXRotAxisRad
|
||||
#define MTXTrans C_MTXTrans
|
||||
#define MTXTransApply C_MTXTransApply
|
||||
#define MTXScale C_MTXScale
|
||||
#define MTXScaleApply C_MTXScaleApply
|
||||
#define MTXQuat C_MTXQuat
|
||||
#else
|
||||
#define MTXIdentity PSMTXIdentity
|
||||
#define MTXCopy PSMTXCopy
|
||||
#define MTXConcat PSMTXConcat
|
||||
#define MTXInverse PSMTXInverse
|
||||
#define MTXRotRad PSMTXRotRad
|
||||
#define MTXRotTrig PSMTXRotTrig
|
||||
#define MTXRotAxisRad PSMTXRotAxisRad
|
||||
#define MTXTrans PSMTXTrans
|
||||
#define MTXTransApply PSMTXTransApply
|
||||
#define MTXScale PSMTXScale
|
||||
#define MTXScaleApply PSMTXScaleApply
|
||||
#define MTXQuat PSMTXQuat
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -12,6 +12,19 @@ void PSMTXMultVecSR(const Mtx m, const Vec* src, Vec* dst);
|
||||
void PSMTXMultVecArray(const Mtx m, const Vec* srcBase, Vec* dstBase, u32 count);
|
||||
void PSMTXMultVecArraySR(const Mtx m, const Vec* srcBase, Vec* dstBase, u32 count);
|
||||
|
||||
/* When compiling in debug mode, use C implementations */
|
||||
#ifdef DEBUG
|
||||
#define MTXMultVec C_MTXMultVec
|
||||
#define MTXMultVecSR C_MTXMultVecSR
|
||||
#define MTXMultVecArray C_MTXMultVecArray
|
||||
#define MTXMultVecArraySR C_MTXMultVecArraySR
|
||||
#else
|
||||
#define MTXMultVec PSMTXMultVec
|
||||
#define MTXMultVecSR PSMTXMultVecSR
|
||||
#define MTXMultVecArray PSMTXMultVecArray
|
||||
#define MTXMultVecArraySR PSMTXMultVecArraySR
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,13 @@ void PSQUATMultiply(const Quaternion* a, const Quaternion* b, Quaternion* ab);
|
||||
void C_QUATRotAxisRad(Quaternion* q, const Vec* axis, f32 rad);
|
||||
void C_QUATSlerp(const Quaternion* p, const Quaternion* q, Quaternion* r, f32 t);
|
||||
|
||||
/* When compiling in debug mode, use C implementations */
|
||||
#ifdef DEBUG
|
||||
#define QUATMultiply C_QUATMultiply
|
||||
#else
|
||||
#define QUATMultiply PSQUATMultiply
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -80,10 +80,36 @@ inline f32 C_VECSquareMag(const Vec* v) {
|
||||
lfs z, 8(src)
|
||||
ps_madd res, z, z, x_y
|
||||
ps_sum0 res, res, x_y, x_y
|
||||
};
|
||||
}
|
||||
;
|
||||
return res;
|
||||
}
|
||||
|
||||
/* When compiling in debug mode, use C implementations */
|
||||
#ifdef DEBUG
|
||||
#define VECAdd C_VECAdd
|
||||
#define VECSubtract C_VECSubtract
|
||||
#define VECScale C_VECScale
|
||||
#define VECNormalize C_VECNormalize
|
||||
#define VECSquareMag C_VECSquareMag
|
||||
#define VECMag C_VECMag
|
||||
#define VECDotProduct C_VECDotProduct
|
||||
#define VECCrossProduct C_VECCrossProduct
|
||||
#define VECSquareDistance C_VECSquareDistance
|
||||
#define VECDistance C_VECDistance
|
||||
#else
|
||||
#define VECAdd PSVECAdd
|
||||
#define VECSubtract PSVECSubtract
|
||||
#define VECScale PSVECScale
|
||||
#define VECNormalize PSVECNormalize
|
||||
#define VECSquareMag PSVECSquareMag
|
||||
#define VECMag PSVECMag
|
||||
#define VECDotProduct PSVECDotProduct
|
||||
#define VECCrossProduct PSVECCrossProduct
|
||||
#define VECSquareDistance PSVECSquareDistance
|
||||
#define VECDistance PSVECDistance
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
+20
-20
@@ -26,31 +26,31 @@ void mDoMtx_inverseTranspose(f32 const (*param_0)[4], f32 (*param_1)[4]);
|
||||
void mDoMtx_QuatConcat(Quaternion const* param_0, Quaternion const* param_1, Quaternion* param_2);
|
||||
|
||||
inline void mDoMtx_multVecSR(Mtx m, const Vec* src, Vec* dst) {
|
||||
PSMTXMultVecSR(m, src, dst);
|
||||
MTXMultVecSR(m, src, dst);
|
||||
}
|
||||
|
||||
inline void cMtx_concat(const Mtx a, const Mtx b, Mtx ab) {
|
||||
PSMTXConcat(a, b, ab);
|
||||
MTXConcat(a, b, ab);
|
||||
}
|
||||
|
||||
inline void cMtx_scale(Mtx m, f32 x, f32 y, f32 z) {
|
||||
PSMTXScale(m, x, y, z);
|
||||
MTXScale(m, x, y, z);
|
||||
}
|
||||
|
||||
inline void mDoMtx_multVec(Mtx m, const Vec* src, Vec* dst) {
|
||||
PSMTXMultVec(m, src, dst);
|
||||
MTXMultVec(m, src, dst);
|
||||
}
|
||||
|
||||
inline void mDoMtx_multVecArray(Mtx m, const Vec* src, Vec* dst, u32 count) {
|
||||
PSMTXMultVecArray(m, src, dst, count);
|
||||
MTXMultVecArray(m, src, dst, count);
|
||||
}
|
||||
|
||||
inline void mDoMtx_copy(const Mtx src, Mtx dst) {
|
||||
PSMTXCopy(src, dst);
|
||||
MTXCopy(src, dst);
|
||||
}
|
||||
|
||||
inline void mDoMtx_trans(Mtx m, f32 x, f32 y, f32 z) {
|
||||
PSMTXTrans(m, x, y, z);
|
||||
MTXTrans(m, x, y, z);
|
||||
}
|
||||
|
||||
inline void cMtx_XrotM(Mtx mtx, s16 x) {
|
||||
@@ -92,7 +92,7 @@ inline void mDoMtx_multVecZero(MtxP param_0, Vec* param_1) {
|
||||
}
|
||||
|
||||
inline void mDoMtx_quatMultiply(const Quaternion* a, const Quaternion* b, Quaternion* ab) {
|
||||
PSQUATMultiply(a,b,ab);
|
||||
QUATMultiply(a,b,ab);
|
||||
}
|
||||
|
||||
inline void mDoMtx_quatSlerp(const Quaternion* a, const Quaternion* b, Quaternion* ab, f32 param_4) {
|
||||
@@ -100,15 +100,15 @@ inline void mDoMtx_quatSlerp(const Quaternion* a, const Quaternion* b, Quaternio
|
||||
}
|
||||
|
||||
inline void mDoMtx_identity(Mtx m) {
|
||||
PSMTXIdentity(m);
|
||||
MTXIdentity(m);
|
||||
}
|
||||
|
||||
inline void mDoMtx_concat(const Mtx a, const Mtx b, Mtx c) {
|
||||
PSMTXConcat(a, b, c);
|
||||
MTXConcat(a, b, c);
|
||||
}
|
||||
|
||||
inline void mDoMtx_inverse(const Mtx a, Mtx b) {
|
||||
PSMTXInverse(a, b);
|
||||
MTXInverse(a, b);
|
||||
}
|
||||
|
||||
inline void cMtx_inverse(const Mtx a, Mtx b) {
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
* @param y The y-axis translation value
|
||||
* @param z The z-axis translation value
|
||||
*/
|
||||
static void transS(f32 x, f32 y, f32 z) { PSMTXTrans(now, x, y, z); }
|
||||
static void transS(f32 x, f32 y, f32 z) { MTXTrans(now, x, y, z); }
|
||||
|
||||
/**
|
||||
* Scales the `now` Matrix by the given X, Y, and Z values
|
||||
@@ -199,21 +199,21 @@ public:
|
||||
* @param y The y-axis scale value
|
||||
* @param z The z-axis scale value
|
||||
*/
|
||||
static void scaleS(f32 x, f32 y, f32 z) { PSMTXScale(now, x, y, z); }
|
||||
static void scaleS(f32 x, f32 y, f32 z) { MTXScale(now, x, y, z); }
|
||||
|
||||
/**
|
||||
* Multiplies a given Vec `a` by the `now` Matrix and places the result into Vec `b`
|
||||
* @param a The source Vec
|
||||
* @param b The output Vec
|
||||
*/
|
||||
static void multVec(const Vec* a, Vec* b) { PSMTXMultVec(now, a, b); }
|
||||
static void multVec(const Vec* a, Vec* b) { MTXMultVec(now, a, b); }
|
||||
|
||||
/**
|
||||
* Multiplies a given Vec `a` by the `now` Matrix's "Scale-and-Rotate" component and places the result into Vec `b`
|
||||
* @param a The source Vec
|
||||
* @param b The output Vec
|
||||
*/
|
||||
static void multVecSR(const Vec* a, Vec* b) { PSMTXMultVecSR(now, a, b); }
|
||||
static void multVecSR(const Vec* a, Vec* b) { MTXMultVecSR(now, a, b); }
|
||||
|
||||
static void multVecZero(Vec* v) { mDoMtx_multVecZero(now, v); }
|
||||
|
||||
@@ -224,7 +224,7 @@ public:
|
||||
* @param count The size of the array
|
||||
*/
|
||||
static void multVecArray(const Vec* src, Vec* dst, u32 count) {
|
||||
PSMTXMultVecArray(now, src, dst, count);
|
||||
MTXMultVecArray(now, src, dst, count);
|
||||
}
|
||||
|
||||
static void XYZrotS(s16 x, s16 y, s16 z) { mDoMtx_XYZrotS(now, x, y, z); }
|
||||
@@ -277,7 +277,7 @@ public:
|
||||
*/
|
||||
static void ZrotM(s16 z) { mDoMtx_ZrotM(now, z); }
|
||||
|
||||
static void inverse() { PSMTXInverse(now, now); }
|
||||
static void inverse() { MTXInverse(now, now); }
|
||||
|
||||
static void inverseTranspose() { mDoMtx_inverseTranspose(now, now); }
|
||||
|
||||
@@ -285,15 +285,15 @@ public:
|
||||
* Concatenates the `now` matrix with the given Matrix `m`
|
||||
* @param m The matrix to concatenate with `now`
|
||||
*/
|
||||
static void concat(const Mtx m) { PSMTXConcat(now, m, now); }
|
||||
static void concat(const Mtx m) { MTXConcat(now, m, now); }
|
||||
|
||||
static void revConcat(const Mtx m) { PSMTXConcat(m, now, now); }
|
||||
static void revConcat(const Mtx m) { MTXConcat(m, now, now); }
|
||||
|
||||
/**
|
||||
* Copies a given matrix `m` to the `now` matrix
|
||||
* @param m The source matrix to copy
|
||||
*/
|
||||
static void copy(const Mtx m) { PSMTXCopy(m, now); }
|
||||
static void copy(const Mtx m) { MTXCopy(m, now); }
|
||||
|
||||
static Mtx now;
|
||||
static Mtx buffer[16];
|
||||
|
||||
Reference in New Issue
Block a user