d_bg_w_hf 70%

This commit is contained in:
LagoLunatic
2024-02-11 00:19:36 -05:00
parent e34d6b1036
commit a38191d6ee
12 changed files with 276 additions and 97 deletions
+22 -22
View File
@@ -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];
+24 -31
View File
@@ -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 */