d_jnt_col OK (#174)

* d_jnt_col almost ok

* OK: Thanks Robo!
This commit is contained in:
Elijah Thomas
2025-05-24 03:42:26 -04:00
committed by GitHub
parent 9efc1e0ab9
commit 4c62e01025
13 changed files with 475 additions and 69 deletions
+2 -2
View File
@@ -7,8 +7,8 @@
#include "d/a/obj/d_a_obj_bomb.h"
#include "d/col/bg/d_bg_s_acch.h"
#include "d/col/cc/d_cc_d.h"
#include "d/d_jnt_col.h"
#include "d/d_shadow.h"
#include "d/flag/sceneflag_manager.h"
#include "m/m3d/m_anmmatclr.h"
#include "m/m3d/m_anmtexpat.h"
#include "m/m_angle.h"
@@ -139,7 +139,7 @@ private:
/* 0x600 */ dBgS_ObjAcch mObjAcch;
/* 0x9B0 */ STATE_MGR_DECLARE(dAcEsm_c);
/* 0x9EC */ dAcRef_c<dAcBomb_c> mBombRef;
/* 0x9F8 */ todoStruct00 field_0x9f8;
/* 0x9F8 */ dJntCol_c mJntCol;
/* 0xA0C */ EffectsStruct mEffArr[2];
/* 0xA74 */ TimeAreaStruct mTimeArea;
/* 0xA80 */ mVec3_c mPosCopy1;
+7 -25
View File
@@ -1,11 +1,12 @@
#ifndef D_A_OBJ_BASE_H
#define D_A_OBJ_BASE_H
#include "c/c_math.h"
#include "common.h"
#include "d/a/d_a_base.h"
#include "d/col/c/c_cc_d.h"
#include "d/col/c/c_m3d_g_aab.h"
#include "d/col/c/c_m3d_g_lin.h"
#include "d/d_jnt_col.h"
#include "egg/math/eggMath.h"
#include "m/m3d/m_shadow.h"
#include "m/m3d/m_smdl.h"
@@ -14,33 +15,10 @@
#include "m/m_mtx.h"
#include "m/m_vec.h"
#include "m/types_m.h"
#include "rvl/MTX/mtx.h"
class dAcObjBase_c;
class dBgS_Acch;
// This is found in dAcObamboo, dAcPy, and dAcEsm
// Since they have object in common, it will reside here
// until further notice.
#include "m/m3d/m_mdl.h"
struct todoStruct00 {
struct InternalData {
u16 field_0x00;
f32 field_0x04;
InternalData *pNextData;
};
todoStruct00();
void Set(dAcObjBase_c *pActor, InternalData *pData, m3d::mdl_c *pMdl, u32);
/* 0x00 */ InternalData *field_0x00;
/* 0x04 */ m3d::mdl_c *mpMdl;
/* 0x08 */ dAcObjBase_c *mpActor;
/* 0x0C */ u32 mCount; // Guess
/* 0x10 */ u32 field_0x10;
};
// Size: 0xA8
struct ActorCarryStruct {
/* 0x00 */ dAcRefBase_c actorLink;
@@ -61,7 +39,7 @@ struct ActorCarryStruct {
ActorCarryStruct();
/* vt 0x9C */
virtual ~ActorCarryStruct();
/* 0xA0 */ u32 field_0xA0;
/* 0xA0 */ dJntCol_c *field_0xA0;
/* 0xA4 */ u32 field_0xA4;
void set(u32 flags, f32 x, f32 y, f32 z, void *unk);
@@ -189,6 +167,10 @@ public:
return mObjectActorFlags & property;
}
void SetJntCol(dJntCol_c *pCol) {
mActorCarryInfo.field_0xA0 = pCol;
}
// could be their own thing?
/* 8002de40 */ static void *getOarcFile(const char *oarcName, const char *fileName);
/* 8002de60 */ static void *getOarcSubEntry(const char *oarcName, const char *fileName);
+18 -7
View File
@@ -3,9 +3,10 @@
#include "common.h"
#include "math.h"
#include "nw4r/math.h" // IWYU pragma: export
#include "nw4r/types_nw4r.h"
#include "nw4r/math.h" // IWYU pragma: export
class cM3dGAab;
class cM3dGCps;
class cM3dGCyl;
@@ -21,18 +22,24 @@ extern const f32 G_CM3D_F_ABS_MIN;
bool cM3d_Len2dSqPntAndSegLine(f32, f32, f32, f32, f32, f32, f32 *, f32 *, f32 *);
bool cM3d_Len3dSqPntAndSegLine(const cM3dGLin &, const nw4r::math::VEC3 &, nw4r::math::VEC3 *, f32 *, f32 *);
f32 cM3d_SignedLenPlaAndPos(const cM3dGPla &, const nw4r::math::VEC3 *);
void cM3d_CalcPla(const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, nw4r::math::VEC3 *, f32 *);
f32 cM3d_SignedLenPlaAndPos(const cM3dGPla *, const nw4r::math::VEC3 *);
void cM3d_CalcPla(
const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, nw4r::math::VEC3 *, f32 *
);
int cM3d_Check_LinLin(const cM3dGLin &, const cM3dGLin *, f32 *, f32 *);
bool cM3d_Cross_LinPla(const cM3dGLin &, const cM3dGPla *, nw4r::math::VEC3 *, bool, bool);
bool cM3d_Cross_MinMaxBoxLine(const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *);
bool cM3d_Cross_MinMaxBoxLine(
const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *
);
bool cM3d_InclusionCheckPosIn3PosBox3d(
const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, const nw4r::math::VEC3 *, f32
);
bool cM3d_CrossX_Tri(const cM3dGTri &, const nw4r::math::VEC3 *, f32);
bool cM3d_CrossX_Tri(const cM3dGTri &, const nw4r::math::VEC3 *);
bool cM3d_CrossY_Tri(const cM3dGTri &, const nw4r::math::VEC3 *);
bool cM3d_CrossY_Tri_Front(const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 *);
bool cM3d_CrossY_Tri_Front(
const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 *
);
bool cM3d_CrossY_Tri(const cM3dGTri &, const nw4r::math::VEC3 *, f32 *);
bool cM3d_CrossY_Tri(const cM3dGTri &, const nw4r::math::VEC3 *, f32);
bool cM3d_CrossY_Tri(const cM3dGTri &, const nw4r::math::VEC3 *, const cM3d_Range *, f32 *);
@@ -59,7 +66,9 @@ bool cM3d_Cross_CylCyl(const cM3dGCyl &, const cM3dGCyl &, f32 *);
bool cM3d_Cross_CylCyl(const cM3dGCyl &, const cM3dGCyl &, nw4r::math::VEC3 *);
bool cM3d_Cross_CylTri(const cM3dGCyl &, const cM3dGTri &, nw4r::math::VEC3 *);
int cM3d_Cross_CylLin(const cM3dGCyl &, const cM3dGLin &, nw4r::math::VEC3 *, nw4r::math::VEC3 *);
int cM3d_Cross_CylPntPnt(const cM3dGCyl &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, nw4r::math::VEC3 *, nw4r::math::VEC3 *);
int cM3d_Cross_CylPntPnt(
const cM3dGCyl &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, nw4r::math::VEC3 *, nw4r::math::VEC3 *
);
bool cM3d_Cross_CylPnt(const cM3dGCyl &, const nw4r::math::VEC3 &);
bool cM3d_Cross_CpsCps(const cM3dGCps &, const cM3dGCps &, nw4r::math::VEC3 *, f32 *, f32 *);
bool cM3d_Cross_CpsCyl(const cM3dGCps &, const cM3dGCyl &, nw4r::math::VEC3 *);
@@ -72,7 +81,9 @@ 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 &, nw4r::math::VEC3 *);
f32 cM3d_lineVsPosSuisenCross(const cM3dGLin &, const nw4r::math::VEC3 &, nw4r::math::VEC3 *);
f32 cM3d_lineVsPosSuisenCross(const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, nw4r::math::VEC3 *);
f32 cM3d_lineVsPosSuisenCross(
const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, const nw4r::math::VEC3 &, nw4r::math::VEC3 *
);
bool cM3d_Cross_UnkTri(const cM3dGUnk &, cM3dGTri &, nw4r::math::VEC3 *);
bool cM3d_Cross_CylUnk(const cM3dGCyl &, cM3dGUnk &, nw4r::math::VEC3 *);
+7 -1
View File
@@ -5,6 +5,7 @@
#include "d/col/c/c_m3d.h"
#include "m/m_angle.h"
#include "m/m_vec.h"
#include "rvl/MTX/vec.h"
// Plane with a normal
class cM3dGPla {
@@ -22,8 +23,13 @@ public:
mAng GetAngle(mAng) const;
mAng GetNegativeAngle(mAng) const;
void SetupNP0(const mVec3_c &normal, const mVec3_c &point) {
mNormal = normal;
VECNormalize(mNormal, mNormal);
mD = -VECDotProduct(mNormal, point);
}
// Unused
// void SetupNP0(const mVec3_c &, const mVec3_c &);
// void SetupNP(const mVec3_c &, const mVec3_c &);
// bool getCrossY(const mVec3_c &, f32 *) const;
// void Set(const cM3dGPla *);
+68
View File
@@ -0,0 +1,68 @@
#ifndef D_JNT_COL_H
#define D_JNT_COL_H
#include "d/col/c/c_m3d_g_lin.h"
#include "m/m3d/m_mdl.h"
#include "m/m_mtx.h"
#include "m/m_vec.h"
class dAcObjBase_c;
class dJntColData_c {
public:
/* 0x0 */ u8 field_0x0;
/* 0x1 */ u8 mType;
/* 0x2 */ s16 mJntNum;
/* 0x4 */ f32 field_0x4;
/* 0x8 */ Vec *field_0x8;
mVec3_c getVec(int i) const {
return field_0x8[i];
}
};
class dJntCol_c {
public:
dJntCol_c();
void getAnmMtx(s32, mMtx_c *) const;
int init(dAcObjBase_c *, dJntColData_c const *, m3d::mdl_c *, int);
static void setNowLine(cM3dGLin *, mVec3_c const *, mAng3_c const *, mVec3_c *);
int searchNearPos(cM3dGLin const *, mVec3_c const *, mVec3_c *, int) const;
int getArrowOffsetPosAndAngle(mVec3_c const *, mAng3_c const *, mVec3_c *, mVec3_c *, bool) const;
int getHitmarkPosAndAngle(mVec3_c const *, mAng3_c const *, mVec3_c *, mAng3_c *, int) const;
void setArrowPosAndAngle(mVec3_c const *, mVec3_c const *, int, mVec3_c *, mAng3_c *);
bool checkPassNum(int bit) const {
return field_0x10 & (1 << bit);
}
void onPassNum(int num) {
field_0x10 |= (1 << num);
}
void offPassNum(int num) {
field_0x10 &= ~(1 << num);
}
s8 getType(int i) const {
return mData[i].mType;
}
int getJntNum(int i) const {
return mData[i].mJntNum;
}
u8 getfield_0x0(int i) const {
return mData[i].field_0x0;
}
f32 getfield_0x4(int i) const {
return mData[i].field_0x4;
}
mVec3_c getVec(int i) const {
return mData->field_0x8[i];
}
/* 0x00 */ const dJntColData_c *mData;
/* 0x04 */ m3d::mdl_c *mpModel;
/* 0x08 */ dAcObjBase_c *mpActor;
/* 0x0C */ int field_0xC;
/* 0x10 */ int field_0x10;
};
#endif /* D_D_JNT_COL_H */
+40 -11
View File
@@ -35,7 +35,7 @@ public:
operator const nw4r::math::MTX34 *() const {
return (nw4r::math::MTX34 *)(this);
}
operator const nw4r::math::MTX34 &() const {
operator const nw4r::math::MTX34 &() const {
return *(nw4r::math::MTX34 *)(this);
}
@@ -78,9 +78,15 @@ public:
void ZYXrotM(const mAng3_c &ang) {
ZYXrotM(ang.x, ang.y, ang.z);
}
void ZXYrotS(const mAng3_c &ang) {
ZXYrotS(ang.x, ang.y, ang.z);
}
void toRot(mAng3_c &out) const; ///< Converts the matrix to a rotation vector.
void inverse() {
MTXInverse(*this, *this);
}
void multVecZero(nw4r::math::VEC3 &out) const; ///< Converts the matrix to a vector.
void zero(); ///< Zeroes out the matrix.
@@ -88,34 +94,57 @@ public:
bool quatRelated();
void transS(const mVec3_c &v) {
PSMTXTrans(*this, v.x, v.y, v.z);
MTXTrans(*this, v.x, v.y, v.z);
}
void transS(f32 x, f32 y, f32 z) {
PSMTXTrans(*this, x, y, z);
MTXTrans(*this, x, y, z);
}
mVec3_c multVec(const mVec3_c &v) const {
mVec3_c ret = v;
PSMTXMultVec(*this, ret, ret);
return ret;
void transM(const mVec3_c &v) {
mMtx_c m;
MTXTrans(m, v.x, v.y, v.z);
*this += m;
}
void transM(f32 x, f32 y, f32 z) {
mMtx_c m;
MTXTrans(m, x, y, z);
*this += m;
}
void multVec(const mVec3_c &in, mVec3_c &out) const {
PSMTXMultVec(*this, in, out);
MTXMultVec(*this, in, out);
}
mVec3_c multVec(const mVec3_c &v) const {
mVec3_c ret = v;
MTXMultVec(*this, ret, ret);
return ret;
}
void multVecSR(const mVec3_c &in, mVec3_c &out) const {
MTXMultVecSR(*this, in, out);
}
mVec3_c multVecSR(const mVec3_c &v) const {
mVec3_c ret = v;
MTXMultVecSR(*this, ret, ret);
return ret;
}
mMtx_c &operator+=(const mMtx_c &rhs) {
PSMTXConcat(*this, rhs, *this);
MTXConcat(*this, rhs, *this);
return *this;
}
mVec3_c operator*(const mVec3_c &rhs) {
mVec3_c out;
PSMTXMultVec(*this, rhs, out);
MTXMultVec(*this, rhs, out);
return out;
}
void applyQuat(mQuat_c &quat) {
PSMTXMultVec(m, quat.v, quat.v);
MTXMultVec(m, quat.v, quat.v);
}
f32 baseLen(int i) const {
return m[0][i] * m[0][i] + m[1][i] * m[1][i] + m[2][i] * m[2][i];
}
void fn_802F1C40(s32, s32);
+13
View File
@@ -5,6 +5,7 @@
#include "common.h"
#include "egg/math/eggMath.h"
#include "egg/math/eggVector.h"
#include "nw4r/math/math_arithmetic.h"
#include "nw4r/math/math_types.h"
#include "nw4r/types_nw4r.h"
#include "rvl/MTX/vec.h"
@@ -247,6 +248,18 @@ public:
f32 inprodXZ(const mVec3_c &other) const {
return x * other.x + z * other.z;
}
f32 getSquareMag() const {
return VEC3LenSq(*this);
}
f32 absXZ() const {
return EGG::Math<f32>::sqrt(squareMagXZ());
}
s16 atan2sX_Z() const {
return cM::atan2s(x, z);
}
s16 atan2sY_XZ() const {
return cM::atan2s(-y, absXZ());
}
static mVec3_c Zero;
static mVec3_c Ex;