From a38191d6ee72f7542785e17c3eb7489c73531db3 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Sun, 11 Feb 2024 00:19:36 -0500 Subject: [PATCH] d_bg_w_hf 70% --- include/SSystem/SComponent/c_bg_s_shdw_draw.h | 2 +- include/SSystem/SComponent/c_bg_w.h | 2 +- include/SSystem/SComponent/c_m3d_g_aab.h | 41 +++- include/SSystem/SComponent/c_m3d_g_cyl.h | 9 +- include/d/d_bg_w_hf.h | 27 +++ include/d/d_bg_w_sv.h | 2 + src/SSystem/SComponent/c_bg_w.cpp | 44 ++--- src/SSystem/SComponent/c_cc_d.cpp | 55 +++--- src/d/d_bg_w.cpp | 2 +- src/d/d_bg_w_deform.cpp | 4 +- src/d/d_bg_w_hf.cpp | 176 +++++++++++++++--- src/d/d_cc_mass_s.cpp | 9 +- 12 files changed, 276 insertions(+), 97 deletions(-) create mode 100644 include/d/d_bg_w_hf.h diff --git a/include/SSystem/SComponent/c_bg_s_shdw_draw.h b/include/SSystem/SComponent/c_bg_s_shdw_draw.h index 28feed198..8899412e6 100644 --- a/include/SSystem/SComponent/c_bg_s_shdw_draw.h +++ b/include/SSystem/SComponent/c_bg_s_shdw_draw.h @@ -14,7 +14,7 @@ class cBgS_ShdwDraw : public cBgS_Chk { public: cBgS_ShdwDraw() {} virtual ~cBgS_ShdwDraw() {} - void Set(cXyz& min, cXyz& max) { mM3dGAab.Set(min, max); } + void Set(cXyz& min, cXyz& max) { mM3dGAab.Set(&min, &max); } void SetCallback(cBgS_ShdwDraw_Callback callback) { mCallbackFun = callback; } cM3dGAab* GetBndP() { return &mM3dGAab; } diff --git a/include/SSystem/SComponent/c_bg_w.h b/include/SSystem/SComponent/c_bg_w.h index d359b55ce..65c647050 100644 --- a/include/SSystem/SComponent/c_bg_w.h +++ b/include/SSystem/SComponent/c_bg_w.h @@ -268,7 +268,7 @@ public: /* 0x94 */ cBgD_t* pm_bgd; /* 0x98 */ cBgW_BlkElm* pm_blk; /* 0x9C */ cBgW_GrpElm* pm_grp; - /* 0xA0 */ cBgW_NodeTree* pm_node_tree; + /* 0xA0 */ cBgW_NodeTree* m_nt_tbl; /* 0xA4 */ int m_rootGrpIdx; }; diff --git a/include/SSystem/SComponent/c_m3d_g_aab.h b/include/SSystem/SComponent/c_m3d_g_aab.h index 84f229730..291983145 100644 --- a/include/SSystem/SComponent/c_m3d_g_aab.h +++ b/include/SSystem/SComponent/c_m3d_g_aab.h @@ -9,16 +9,20 @@ // Axis aligned bounding box class cM3dGAab { private: -public: /* 0x00 */ cXyz mMin; /* 0x0C */ cXyz mMax; - /* 0x18 vtable */ + /* 0x18 */ /* vtable */ +public: virtual ~cM3dGAab() {} void SetMinMax(const cXyz&); - void Set(const cXyz& min, const cXyz& max) { - mMin = min; - mMax = max; + void SetMinMax(const cM3dGAab& aab) { + SetMinMax(aab.mMin); + SetMinMax(aab.mMax); + } + void Set(const cXyz* min, const cXyz* max) { + mMin = *min; + mMax = *max; } void SetMin(const cXyz&); void SetMax(const cXyz&); @@ -56,6 +60,26 @@ public: mMax.y = -1000000000.0f; mMax.x = -1000000000.0f; } + void ClearForMinMaxY() { + mMin.y = 1000000000.0f; + mMax.y = -1000000000.0f; + } + void SetMinMaxY(f32 y) { + if (mMin.y > y) { + mMin.y = y; + } + if (mMax.y < y) { + mMax.y = y; + } + } + void PlusR(f32 r) { + mMin.x -= r; + mMin.y -= r; + mMin.z -= r; + mMax.x += r; + mMax.y += r; + mMax.z += r; + } bool CrossY(const cXyz* v) const { if (mMin.x > v->x || mMax.x < v->x || mMin.z > v->z || mMax.z < v->z) { return false; @@ -69,6 +93,13 @@ public: bool TopPlaneYUnder(f32 y) const { return mMax.y < y; } + + void Cross(const cM3dGAab*) const {} + void Cross(const cM3dGCyl*) const {} + void Cross(const cM3dGLin*) const {} + void Cross(const cM3dGSph*) const {} + void SetMaxY(f32) {} + void SetMinY(f32) {} }; // Size = 0x1C STATIC_ASSERT(0x1C == sizeof(cM3dGAab)); diff --git a/include/SSystem/SComponent/c_m3d_g_cyl.h b/include/SSystem/SComponent/c_m3d_g_cyl.h index 2a6099ee6..2f5cb12b2 100644 --- a/include/SSystem/SComponent/c_m3d_g_cyl.h +++ b/include/SSystem/SComponent/c_m3d_g_cyl.h @@ -44,14 +44,13 @@ public: bool cross(const cM3dGCyl*, f32*) const; bool Cross(const cM3dGCps* cps, cXyz* dst) const { return cM3d_Cross_CpsCyl(*cps, *this, dst); } bool Cross(const cM3dGTri& tri, cXyz* dst) const { return cM3d_Cross_CylTri(this, &tri, dst); } + cXyz& GetC() { return mCenter; } + const cXyz& GetC() const { return mCenter; } + cXyz* GetCP() { return &mCenter; } const cXyz* GetCP() const { return &mCenter; } f32 GetR() const { return mRadius; } + f32* GetRP() { return &mRadius; } f32 GetH() const { return mHeight; } - cXyz& GetC() { return mCenter; } - - void GetC() const {} - void GetCP() {} - void GetRP() {} }; // Size = 0x18 STATIC_ASSERT(0x18 == sizeof(cM3dGCyl)); diff --git a/include/d/d_bg_w_hf.h b/include/d/d_bg_w_hf.h new file mode 100644 index 000000000..153109821 --- /dev/null +++ b/include/d/d_bg_w_hf.h @@ -0,0 +1,27 @@ +#ifndef D_BG_W_HF_H +#define D_BG_W_HF_H + +#include "d/d_bg_w_sv.h" + +class dBgWHf : public dBgWSv { +public: + virtual ~dBgWHf() {} + + bool Set(cBgD_t*, u16*, f32, int, int, u32); + void CalcPlane(); + void ClassifyPlane(); + void MoveHf(); + void MakeBlckMinMaxHf(int, f32*, f32*); + void MakeBlckBndHf(int, f32*, f32*); + void MakeNodeTreeRpHf(int); + void MakeNodeTreeGrpRpHf(int); + void MakeNodeTreeHf(); + +public: + /* 0xC4 */ f32 mC4; + /* 0xC8 */ u16* mC8; + /* 0xCC */ int m_gridx; + /* 0xD0 */ int m_gridz; +}; // Size: 0xD4 + +#endif /* D_BG_W_HF_H */ diff --git a/include/d/d_bg_w_sv.h b/include/d/d_bg_w_sv.h index 46591f254..ae8c6b141 100644 --- a/include/d/d_bg_w_sv.h +++ b/include/d/d_bg_w_sv.h @@ -5,6 +5,8 @@ class dBgWSv : public dBgW { public: + virtual ~dBgWSv() {} + virtual void MatrixCrrPos(cBgS_PolyInfo&, void*, bool, cXyz*, csXyz*, csXyz*) {} bool ChkNoCrrPos() { return mSvFlag & 1; } void SetFlag(u32 flag) { mSvFlag = flag; } diff --git a/src/SSystem/SComponent/c_bg_w.cpp b/src/SSystem/SComponent/c_bg_w.cpp index a46e48671..2ceed93f4 100644 --- a/src/SSystem/SComponent/c_bg_w.cpp +++ b/src/SSystem/SComponent/c_bg_w.cpp @@ -32,7 +32,7 @@ cBgW::cBgW() { pm_tri = NULL; pm_rwg = NULL; pm_blk = NULL; - pm_node_tree = NULL; + m_nt_tbl = NULL; pm_grp = NULL; pm_vtx_tbl = NULL; pm_base = NULL; @@ -52,7 +52,7 @@ cBgW::~cBgW() { void cBgW::FreeArea() { pm_tri = NULL; pm_rwg = NULL; - pm_node_tree = NULL; + m_nt_tbl = NULL; pm_blk = NULL; pm_grp = NULL; pm_vtx_tbl = NULL; @@ -243,18 +243,18 @@ void cBgW::MakeNodeTreeRp(int i) { // leaf s32 block = tree->mBlock; if (block != 0xFFFF) { - MakeBlckBnd(tree->mBlock, pm_node_tree[i].GetMinP(), pm_node_tree[i].GetMaxP()); + MakeBlckBnd(tree->mBlock, m_nt_tbl[i].GetMinP(), m_nt_tbl[i].GetMaxP()); } } else { // branch - pm_node_tree[i].ClearForMinMax(); + m_nt_tbl[i].ClearForMinMax(); for (s32 j = 0; j < 8; j++) { s32 child = tree->mChild[j]; if (child == 0xFFFF) continue; MakeNodeTreeRp(child); - pm_node_tree[i].SetMinMax(*pm_node_tree[child].GetMinP()); - pm_node_tree[i].SetMinMax(*pm_node_tree[child].GetMaxP()); + m_nt_tbl[i].SetMinMax(*m_nt_tbl[child].GetMinP()); + m_nt_tbl[i].SetMinMax(*m_nt_tbl[child].GetMaxP()); } } } @@ -264,8 +264,8 @@ void cBgW::MakeNodeTreeGrpRp(int grp_id) { u32 tree_idx = pm_bgd->m_g_tbl[grp_id].m_tree_idx; if (tree_idx != 0xFFFF) { MakeNodeTreeRp(tree_idx); - pm_grp[grp_id].aab.SetMin(*pm_node_tree[pm_bgd->m_g_tbl[grp_id].m_tree_idx].GetMinP()); - pm_grp[grp_id].aab.SetMax(*pm_node_tree[pm_bgd->m_g_tbl[grp_id].m_tree_idx].GetMaxP()); + pm_grp[grp_id].aab.SetMin(*m_nt_tbl[pm_bgd->m_g_tbl[grp_id].m_tree_idx].GetMinP()); + pm_grp[grp_id].aab.SetMax(*m_nt_tbl[pm_bgd->m_g_tbl[grp_id].m_tree_idx].GetMaxP()); } s32 child_idx = pm_bgd->m_g_tbl[grp_id].m_first_child; @@ -305,7 +305,7 @@ void cBgW::MakeNodeTree() { /* 80248178-802481C4 .text ChkMemoryError__4cBgWFv */ bool cBgW::ChkMemoryError() { - if (pm_tri == NULL || pm_rwg == NULL || pm_blk == NULL || pm_node_tree == NULL || pm_grp == NULL) + if (pm_tri == NULL || pm_rwg == NULL || pm_blk == NULL || m_nt_tbl == NULL || pm_grp == NULL) return true; return false; } @@ -318,7 +318,7 @@ bool cBgW::Set(cBgD_t* bgd, u32 flag, Mtx* mtx) { pm_tri = NULL; pm_rwg = NULL; pm_blk = NULL; - pm_node_tree = NULL; + m_nt_tbl = NULL; pm_grp = NULL; mMoveCounter = cM_rndF(128.0f); if (bgd == NULL) @@ -353,8 +353,8 @@ bool cBgW::Set(cBgD_t* bgd, u32 flag, Mtx* mtx) { return true; } - pm_node_tree = new cBgW_NodeTree[pm_bgd->m_tree_num]; - if (pm_node_tree == NULL) { + m_nt_tbl = new cBgW_NodeTree[pm_bgd->m_tree_num]; + if (m_nt_tbl == NULL) { FreeArea(); return true; } @@ -412,7 +412,7 @@ static void dummy() { /* 802485FC-80248868 .text LineCheckRp__4cBgWFP11cBgS_LinChki */ bool cBgW::LineCheckRp(cBgS_LinChk* chk, int i) { - cBgW_NodeTree* node = &pm_node_tree[i]; + cBgW_NodeTree* node = &m_nt_tbl[i]; // node->Cross(chk->GetLinP()); if (!cM3d_Cross_MinMaxBoxLine(node->GetMinP(), node->GetMaxP(), chk->GetLinP()->GetStartP(), chk->GetLinP()->GetEndP())) return false; @@ -531,49 +531,49 @@ bool cBgW::GroundCrossRp(cBgS_GndChk* chk, int i) { return ret; } else { if (tree->mChild[2] != 0xFFFF) { - cBgW_NodeTree* node = &pm_node_tree[tree->mChild[2]]; + cBgW_NodeTree* node = &m_nt_tbl[tree->mChild[2]]; if (node->CrossY(chk->GetPointP()) && node->UnderPlaneYUnder(chk->GetPointP()->y) && !node->TopPlaneYUnder(chk->mNowY) && GroundCrossRp(chk, tree->mChild[2])) ret = true; } if (tree->mChild[3] != 0xFFFF) { - cBgW_NodeTree* node = &pm_node_tree[tree->mChild[3]]; + cBgW_NodeTree* node = &m_nt_tbl[tree->mChild[3]]; if (node->CrossY(chk->GetPointP()) && node->UnderPlaneYUnder(chk->GetPointP()->y) && !node->TopPlaneYUnder(chk->mNowY) && GroundCrossRp(chk, tree->mChild[3])) ret = true; } if (tree->mChild[6] != 0xFFFF) { - cBgW_NodeTree* node = &pm_node_tree[tree->mChild[6]]; + cBgW_NodeTree* node = &m_nt_tbl[tree->mChild[6]]; if (node->CrossY(chk->GetPointP()) && node->UnderPlaneYUnder(chk->GetPointP()->y) && !node->TopPlaneYUnder(chk->mNowY) && GroundCrossRp(chk, tree->mChild[6])) ret = true; } if (tree->mChild[7] != 0xFFFF) { - cBgW_NodeTree* node = &pm_node_tree[tree->mChild[7]]; + cBgW_NodeTree* node = &m_nt_tbl[tree->mChild[7]]; if (node->CrossY(chk->GetPointP()) && node->UnderPlaneYUnder(chk->GetPointP()->y) && !node->TopPlaneYUnder(chk->mNowY) && GroundCrossRp(chk, tree->mChild[7])) ret = true; } if (tree->mChild[0] != 0xFFFF) { - cBgW_NodeTree* node = &pm_node_tree[tree->mChild[0]]; + cBgW_NodeTree* node = &m_nt_tbl[tree->mChild[0]]; if (node->CrossY(chk->GetPointP()) && node->UnderPlaneYUnder(chk->GetPointP()->y) && !node->TopPlaneYUnder(chk->mNowY) && GroundCrossRp(chk, tree->mChild[0])) ret = true; } if (tree->mChild[1] != 0xFFFF) { - cBgW_NodeTree* node = &pm_node_tree[tree->mChild[1]]; + cBgW_NodeTree* node = &m_nt_tbl[tree->mChild[1]]; if (node->CrossY(chk->GetPointP()) && node->UnderPlaneYUnder(chk->GetPointP()->y) && !node->TopPlaneYUnder(chk->mNowY) && GroundCrossRp(chk, tree->mChild[1])) ret = true; } if (tree->mChild[4] != 0xFFFF) { - cBgW_NodeTree* node = &pm_node_tree[tree->mChild[4]]; + cBgW_NodeTree* node = &m_nt_tbl[tree->mChild[4]]; if (node->CrossY(chk->GetPointP()) && node->UnderPlaneYUnder(chk->GetPointP()->y) && !node->TopPlaneYUnder(chk->mNowY) && GroundCrossRp(chk, tree->mChild[4])) ret = true; } if (tree->mChild[5] != 0xFFFF) { - cBgW_NodeTree* node = &pm_node_tree[tree->mChild[5]]; + cBgW_NodeTree* node = &m_nt_tbl[tree->mChild[5]]; if (node->CrossY(chk->GetPointP()) && node->UnderPlaneYUnder(chk->GetPointP()->y) && !node->TopPlaneYUnder(chk->mNowY) && GroundCrossRp(chk, tree->mChild[5])) ret = true; } @@ -670,7 +670,7 @@ void cBgW::RwgShdwDraw(int index, cBgS_ShdwDraw* shdw) { /* 80249698-80249840 .text ShdwDrawRp__4cBgWFP13cBgS_ShdwDrawi */ void cBgW::ShdwDrawRp(cBgS_ShdwDraw* shdw, int i) { - if (!pm_node_tree[i].Cross(shdw->GetBndP())) + if (!m_nt_tbl[i].Cross(shdw->GetBndP())) return; cBgD_Tree_t* tree = &pm_bgd->m_tree_tbl[i]; diff --git a/src/SSystem/SComponent/c_cc_d.cpp b/src/SSystem/SComponent/c_cc_d.cpp index 3d51893fd..f294b7571 100644 --- a/src/SSystem/SComponent/c_cc_d.cpp +++ b/src/SSystem/SComponent/c_cc_d.cpp @@ -52,8 +52,8 @@ void cCcD_DivideArea::CalcDivideInfo(cCcD_DivideInfo* pDivideInfo, const cM3dGAa } else { u32 divInfo, yDivInfo, zDivInfo; if (!mXDiffIsZero) { - s32 var1 = mInvScaledXDiff * (aab.mMin.x - mMin.x); - s32 var3 = mInvScaledXDiff * (aab.mMax.x - mMin.x); + s32 var1 = mInvScaledXDiff * (aab.GetMinP()->x - GetMinP()->x); + s32 var3 = mInvScaledXDiff * (aab.GetMaxP()->x - GetMinP()->x); if (10 < var3) { var3 = 10; } @@ -68,8 +68,8 @@ void cCcD_DivideArea::CalcDivideInfo(cCcD_DivideInfo* pDivideInfo, const cM3dGAa } if (!mYDiffIsZero) { - s32 var1 = mInvScaledYDiff * (aab.mMin.y - mMin.y); - s32 var3 = mInvScaledYDiff * (aab.mMax.y - mMin.y); + s32 var1 = mInvScaledYDiff * (aab.GetMinP()->y - GetMinP()->y); + s32 var3 = mInvScaledYDiff * (aab.GetMaxP()->y - GetMinP()->y); if (9 < var3) { var3 = 9; } @@ -85,8 +85,8 @@ void cCcD_DivideArea::CalcDivideInfo(cCcD_DivideInfo* pDivideInfo, const cM3dGAa divInfo |= yDivInfo << 11; if (!mZDiffIsZero) { - s32 var1 = mInvScaledZDiff * (aab.mMin.z - mMin.z); - s32 var3 = mInvScaledZDiff * (aab.mMax.z - mMin.z); + s32 var1 = mInvScaledZDiff * (aab.GetMinP()->z - GetMinP()->z); + s32 var3 = mInvScaledZDiff * (aab.GetMaxP()->z - GetMinP()->z); if (10 < var3) { var3 = 10; } @@ -109,8 +109,8 @@ void cCcD_DivideArea::CalcDivideInfo(cCcD_DivideInfo* pDivideInfo, const cM3dGAa void cCcD_DivideArea::CalcDivideInfoOverArea(cCcD_DivideInfo* pDivideInfo, const cM3dGAab& aab) { u32 divInfo, yDivInfo, zDivInfo; if (!mXDiffIsZero) { - s32 var1 = mInvScaledXDiff * (aab.mMin.x - mMin.x); - s32 var3 = mInvScaledXDiff * (aab.mMax.x - mMin.x); + s32 var1 = mInvScaledXDiff * (aab.GetMinP()->x - GetMinP()->x); + s32 var3 = mInvScaledXDiff * (aab.GetMaxP()->x - GetMinP()->x); if ((var1 < 0 && var3 < 0) || (10 < var1 && var3 > 10)) { divInfo = 0; } else { @@ -129,8 +129,8 @@ void cCcD_DivideArea::CalcDivideInfoOverArea(cCcD_DivideInfo* pDivideInfo, const } if (!mYDiffIsZero) { - s32 var1 = mInvScaledYDiff * (aab.mMin.y - mMin.y); - s32 var3 = mInvScaledYDiff * (aab.mMax.y - mMin.y); + s32 var1 = mInvScaledYDiff * (aab.GetMinP()->y - GetMinP()->y); + s32 var3 = mInvScaledYDiff * (aab.GetMaxP()->y - GetMinP()->y); if ((var1 < 0 && var3 < 0) || (9 < var1 && var3 > 9)) { yDivInfo = 0; } else { @@ -150,8 +150,8 @@ void cCcD_DivideArea::CalcDivideInfoOverArea(cCcD_DivideInfo* pDivideInfo, const divInfo |= yDivInfo << 11; if (!mZDiffIsZero) { - s32 var1 = mInvScaledZDiff * (aab.mMin.z - mMin.z); - s32 var3 = mInvScaledZDiff * (aab.mMax.z - mMin.z); + s32 var1 = mInvScaledZDiff * (aab.GetMinP()->z - GetMinP()->z); + s32 var3 = mInvScaledZDiff * (aab.GetMaxP()->z - GetMinP()->z); if ((var1 < 0 && var3 < 0) || (10 < var1 && var3 > 10)) { zDivInfo = 0; } else { @@ -337,16 +337,10 @@ bool cCcD_CpsAttr::CrossCo(const cCcD_SphAttr& sph, f32* dst) const { /* 802421EC-80242294 .text CalcAabBox__12cCcD_CpsAttrFv */ void cCcD_CpsAttr::CalcAabBox() { - mAab.ClearForMinMax(); - mAab.SetMinMax(GetStart()); - mAab.SetMinMax(GetEnd()); - f32 r = mRadius; - mAab.mMin.x -= r; - mAab.mMin.y -= r; - mAab.mMin.z -= r; - mAab.mMax.x += r; - mAab.mMax.y += r; - mAab.mMax.z += r; + GetWorkAab().ClearForMinMax(); + GetWorkAab().SetMinMax(*GetStartP()); + GetWorkAab().SetMinMax(*GetEndP()); + GetWorkAab().PlusR(GetR()); } /* 80242294-802423FC .text GetNVec__12cCcD_CpsAttrCFRC4cXyzP4cXyz */ @@ -442,14 +436,13 @@ bool cCcD_CylAttr::CrossCo(const cCcD_CpsAttr& cps, f32* dst) const { /* 802425E8-8024264C .text CalcAabBox__12cCcD_CylAttrFv */ void cCcD_CylAttr::CalcAabBox() { cXyz min, max; - min.x = mCenter.x - mRadius; - min.y = mCenter.y; - min.z = mCenter.z - mRadius; - max.x = mCenter.x + mRadius; - max.y = mCenter.y + mHeight; - max.z = mCenter.z + mRadius; - mAab.mMin.set(min); - mAab.mMax.set(max); + min.x = GetCP()->x - GetR(); + min.y = GetCP()->y; + min.z = GetCP()->z - GetR(); + max.x = GetCP()->x + GetR(); + max.y = GetCP()->y + GetH(); + max.z = GetCP()->z + GetR(); + mAab.Set(&min, &max); } /* 8024264C-80242734 .text GetNVec__12cCcD_CylAttrCFRC4cXyzP4cXyz */ @@ -546,7 +539,7 @@ void cCcD_SphAttr::CalcAabBox() { max.x += GetR(); max.y += GetR(); max.z += GetR(); - GetWorkAab().Set(min, max); + GetWorkAab().Set(&min, &max); } /* 802429B8-80242A54 .text GetNVec__12cCcD_SphAttrCFRC4cXyzP4cXyz */ diff --git a/src/d/d_bg_w.cpp b/src/d/d_bg_w.cpp index 8fa023626..4150fe7e1 100644 --- a/src/d/d_bg_w.cpp +++ b/src/d/d_bg_w.cpp @@ -109,7 +109,7 @@ bool dBgW::RwgWallCrrPos(u16, dBgS_CrrPos*) { /* 800A8964-800A8B70 .text WallCrrPosRp__4dBgWFP11dBgS_CrrPosi */ bool dBgW::WallCrrPosRp(dBgS_CrrPos* crr, int i) { - cBgW_NodeTree* node = &pm_node_tree[i]; + cBgW_NodeTree* node = &m_nt_tbl[i]; if (!node->Cross(crr->GetCylP())) return false; diff --git a/src/d/d_bg_w_deform.cpp b/src/d/d_bg_w_deform.cpp index e89b752dd..48ab521bd 100644 --- a/src/d/d_bg_w_deform.cpp +++ b/src/d/d_bg_w_deform.cpp @@ -8,12 +8,12 @@ #include "JSystem/J3DGraphAnimator/J3DModelData.h" /* 800A9928-800A9A48 .text Set__10dBgWDeformFP6cBgD_tP8J3DModelUl */ -bool dBgWDeform::Set(cBgD_t* bgd, J3DModel* pmodel, u32 r30) { +bool dBgWDeform::Set(cBgD_t* bgd, J3DModel* pmodel, u32 flag) { JUT_ASSERT(32, pmodel->getModelData()->isDeformablePositionFormat() == true); if (cBgW::Set(bgd, 0x33, NULL)) { return true; } - SetFlag(r30); + SetFlag(flag); if (pmodel->setSkinDeform(this, 1) == J3DErrType_OutOfMemory) { return true; } diff --git a/src/d/d_bg_w_hf.cpp b/src/d/d_bg_w_hf.cpp index 60c750fef..7bab40eba 100644 --- a/src/d/d_bg_w_hf.cpp +++ b/src/d/d_bg_w_hf.cpp @@ -3,61 +3,191 @@ // Translation Unit: d_bg_w_hf.cpp // -#include "d_bg_w_hf.h" +#include "d/d_bg_w_hf.h" #include "dolphin/types.h" +#define CHECK_MINMAX_1(line, min, max) \ + JUT_ASSERT(line, \ + min->x != (1000000000.0f) && min->y != (1000000000.0f) && min->z != (1000000000.0f) && \ + max->x != -(1000000000.0f) && max->y != -(1000000000.0f) && max->z != -(1000000000.0f) \ + ); + +#define CHECK_MINMAX_2(line, min, max) \ + JUT_ASSERT(line, \ + (cM3d_IsZero(max->x - min->x) || min->x <= max->x) && \ + (cM3d_IsZero(max->y - min->y) || min->y <= max->y) && \ + (cM3d_IsZero(max->z - min->z) || min->z <= max->z) \ + ); + /* 800A9A48-800A9AE0 .text Set__6dBgWHfFP6cBgD_tPUsfiiUl */ -void dBgWHf::Set(cBgD_t*, unsigned short*, float, int, int, unsigned long) { - /* Nonmatching */ +bool dBgWHf::Set(cBgD_t* bgd, u16* r5, f32 f1, int r6, int r7, u32 flag) { + m_gridx = r6; + m_gridz = r7; + mC8 = r5; + mC4 = f1; + if (cBgW::Set(bgd, 0x33, NULL)) { + return true; + } + SetFlag(flag); + if (ChkNoCrrPos()) { + return false; + } + SetBackVtx(new Vec[pm_bgd->m_v_num]); + if (GetBackVtx() == NULL) { + return true; + } + return false; } /* 800A9AE0-800A9CD0 .text CalcPlane__6dBgWHfFv */ void dBgWHf::CalcPlane() { /* Nonmatching */ + JUT_ASSERT(0, m_gridx * m_gridz * 2 == pm_bgd->m_t_num); } /* 800A9CD0-800A9E70 .text ClassifyPlane__6dBgWHfFv */ void dBgWHf::ClassifyPlane() { - /* Nonmatching */ + if (pm_vtx_tbl == NULL) { + return; + } + + for (int b = 0; b < pm_bgd->m_b_num; b++) { + JUT_ASSERT(140, 0 <= b && b < pm_bgd->m_b_num); + + int r6 = pm_bgd->m_b_tbl[b].startTri; + int r29; + if (b != pm_bgd->m_b_num - 1) { + r29 = pm_bgd->m_b_tbl[b+1].startTri - 1; + } else { + r29 = pm_bgd->m_t_num - 1; + } + + pm_blk[b].roof = -1; + pm_blk[b].wall = -1; + pm_blk[b].ground = -1; + int sp8 = (u16)-1; + + for (int t = r6; t <= r29; t++) { + JUT_ASSERT(159, 0 <= t && t < pm_bgd->m_t_num); + BlckConnect(&pm_blk[b].ground, &sp8, t); + } + } } /* 800A9E70-800A9EDC .text MoveHf__6dBgWHfFv */ void dBgWHf::MoveHf() { - /* Nonmatching */ + mFlag |= 0x01; + if (ChkLock()) { + return; + } + CalcPlane(); + ClassifyPlane(); + MakeNodeTreeHf(); } /* 800A9EDC-800A9FA0 .text MakeBlckMinMaxHf__6dBgWHfFiPfPf */ -void dBgWHf::MakeBlckMinMaxHf(int, float*, float*) { - /* Nonmatching */ +void dBgWHf::MakeBlckMinMaxHf(int v_index, f32* r30, f32* r31) { + JUT_ASSERT(198, 0 <= v_index && v_index < pm_bgd->m_v_num); + Vec* vtx = &pm_vtx_tbl[v_index]; + if (*r30 > vtx->y) { + *r30 = vtx->y; + } + if (*r31 < vtx->y) { + *r31 = vtx->y; + } } /* 800A9FA0-800AA164 .text MakeBlckBndHf__6dBgWHfFiPfPf */ -void dBgWHf::MakeBlckBndHf(int, float*, float*) { - /* Nonmatching */ +void dBgWHf::MakeBlckBndHf(int blck_id, f32* r28, f32* r29) { + JUT_ASSERT(221, blck_id >= 0 && blck_id < pm_bgd->m_b_num); + + int r7 = pm_bgd->m_b_tbl[blck_id].startTri; + int r31; + if (blck_id != pm_bgd->m_b_num - 1) { + r31 = pm_bgd->m_b_tbl[blck_id+1].startTri - 1; + } else { + r31 = pm_bgd->m_t_num - 1; + } + + *r28 = 1000000000.0f; + *r29 = -1000000000.0f; + + for (int t = r7; t <= r31; t++) { + JUT_ASSERT(238, 0 <= t && t < pm_bgd->m_t_num); + MakeBlckMinMaxHf(pm_bgd->m_t_tbl[t].vtx0, r28, r29); + MakeBlckMinMaxHf(pm_bgd->m_t_tbl[t].vtx1, r28, r29); + MakeBlckMinMaxHf(pm_bgd->m_t_tbl[t].vtx2, r28, r29); + } + + *r28 -= 1.0f; + *r29 += 1.0f; } /* 800AA164-800AA8AC .text MakeNodeTreeRpHf__6dBgWHfFi */ -void dBgWHf::MakeNodeTreeRpHf(int) { - /* Nonmatching */ +void dBgWHf::MakeNodeTreeRpHf(int node_index) { + JUT_ASSERT(258, 0 <= node_index && node_index < pm_bgd->m_tree_num); + + cBgD_Tree_t* r30 = &pm_bgd->m_tree_tbl[node_index]; + if (r30->mFlag & 0x01) { + if (r30->mChild[0] != (u16)-1) { + MakeBlckBndHf(r30->mChild[0], &m_nt_tbl[node_index].GetMinP()->y, &m_nt_tbl[node_index].GetMaxP()->y); + } + } else { + m_nt_tbl[node_index].ClearForMinMaxY(); + if (r30->mChild[0] != (u16)-1) { + MakeNodeTreeRpHf(r30->mChild[0]); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[0]].GetMinP()->y); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[0]].GetMaxP()->y); + } + if (r30->mChild[1] != (u16)-1) { + MakeNodeTreeRpHf(r30->mChild[1]); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[1]].GetMinP()->y); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[1]].GetMaxP()->y); + } + if (r30->mChild[2] != (u16)-1) { + MakeNodeTreeRpHf(r30->mChild[2]); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[2]].GetMinP()->y); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[2]].GetMaxP()->y); + } + if (r30->mChild[3] != (u16)-1) { + MakeNodeTreeRpHf(r30->mChild[3]); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[3]].GetMinP()->y); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[3]].GetMaxP()->y); + } + if (r30->mChild[4] != (u16)-1) { + MakeNodeTreeRpHf(r30->mChild[4]); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[4]].GetMinP()->y); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[4]].GetMaxP()->y); + } + if (r30->mChild[5] != (u16)-1) { + MakeNodeTreeRpHf(r30->mChild[5]); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[5]].GetMinP()->y); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[5]].GetMaxP()->y); + } + if (r30->mChild[6] != (u16)-1) { + MakeNodeTreeRpHf(r30->mChild[6]); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[6]].GetMinP()->y); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[6]].GetMaxP()->y); + } + if (r30->mChild[7] != (u16)-1) { + MakeNodeTreeRpHf(r30->mChild[7]); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[7]].GetMinP()->y); + m_nt_tbl[node_index].SetMinMaxY(m_nt_tbl[r30->mChild[7]].GetMaxP()->y); + } + } + + CHECK_MINMAX_1(353, m_nt_tbl[node_index].GetMinP(), m_nt_tbl[node_index].GetMaxP()); + CHECK_MINMAX_2(365, m_nt_tbl[node_index].GetMinP(), m_nt_tbl[node_index].GetMaxP()); } /* 800AA8AC-800AAA70 .text MakeNodeTreeGrpRpHf__6dBgWHfFi */ -void dBgWHf::MakeNodeTreeGrpRpHf(int) { +void dBgWHf::MakeNodeTreeGrpRpHf(int g) { /* Nonmatching */ + JUT_ASSERT(0, 0 <= g && g < pm_bgd->m_g_num); } /* 800AAA70-800AAB78 .text MakeNodeTreeHf__6dBgWHfFv */ void dBgWHf::MakeNodeTreeHf() { /* Nonmatching */ + MakeNodeTreeGrpRpHf(m_rootGrpIdx); } - -/* 800AAB78-800AABF8 .text __dt__6dBgWHfFv */ -dBgWHf::~dBgWHf() { - /* Nonmatching */ -} - -/* 800AABF8-800AABFC .text MatrixCrrPos__6dBgWSvFR13cBgS_PolyInfoPvbP4cXyzP5csXyzP5csXyz */ -void dBgWSv::MatrixCrrPos(cBgS_PolyInfo&, void*, bool, cXyz*, csXyz*, csXyz*) { - /* Nonmatching */ -} - diff --git a/src/d/d_cc_mass_s.cpp b/src/d/d_cc_mass_s.cpp index 58817a9ef..a9de628c1 100644 --- a/src/d/d_cc_mass_s.cpp +++ b/src/d/d_cc_mass_s.cpp @@ -37,22 +37,19 @@ void dCcMassS_Mng::Prepare() { JUT_ASSERT(61, pobj != 0); attr = pobj->GetShapeAttr(); attr->CalcAabBox(); - area.SetMinMax(attr->GetWorkAab().mMin); - area.SetMinMax(attr->GetWorkAab().mMax); + area.SetMinMax(attr->GetWorkAab()); } for (dCcMassS_Obj* mass = mMassAreas; mass < mMassAreas + mMassAreaCount; mass++) { cCcD_Obj* parea = mass->GetObj(); JUT_ASSERT(73, parea != 0); attr = parea->GetShapeAttr(); attr->CalcAabBox(); - area.SetMinMax(attr->GetWorkAab().mMin); - area.SetMinMax(attr->GetWorkAab().mMax); + area.SetMinMax(attr->GetWorkAab()); } if (mFlag & 1) { mCpsAttr.CalcAabBox(); attr = &mCpsAttr; - area.SetMinMax(attr->GetWorkAab().mMin); - area.SetMinMax(attr->GetWorkAab().mMax); + area.SetMinMax(attr->GetWorkAab()); } mDivideArea.SetArea(area); for (dCcMassS_Obj* mass = mMassObjs; mass < mMassObjs + mMassObjCount; mass++) {