From 2d430eb9a1bcb2cb3a901cb10ed08c2041df2463 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 12 Mar 2026 23:49:00 -0700 Subject: [PATCH] shadow fix --- include/SSystem/SComponent/c_bg_s_chk.h | 4 -- include/SSystem/SComponent/c_m3d_g_tri.h | 2 +- src/SSystem/SComponent/c_m3d_g_tri.cpp | 2 +- src/d/d_bg_s.cpp | 55 ++++++++---------------- src/d/d_bg_w.cpp | 17 +------- 5 files changed, 21 insertions(+), 59 deletions(-) diff --git a/include/SSystem/SComponent/c_bg_s_chk.h b/include/SSystem/SComponent/c_bg_s_chk.h index 51c7eb6015..adbc0c1807 100644 --- a/include/SSystem/SComponent/c_bg_s_chk.h +++ b/include/SSystem/SComponent/c_bg_s_chk.h @@ -7,11 +7,7 @@ #include "SSystem/SComponent/c_bg_s_poly_pass_chk.h" #include "dusk/endian.h" -#if TARGET_LITTLE_ENDIAN -struct cBgD_Vtx_t : public BE(Vec) {}; -#else struct cBgD_Vtx_t : public Vec {}; -#endif class cBgS_Chk { public: diff --git a/include/SSystem/SComponent/c_m3d_g_tri.h b/include/SSystem/SComponent/c_m3d_g_tri.h index 3b8d847f48..ff780046b8 100644 --- a/include/SSystem/SComponent/c_m3d_g_tri.h +++ b/include/SSystem/SComponent/c_m3d_g_tri.h @@ -24,7 +24,7 @@ public: virtual ~cM3dGTri() {} bool cross(const cM3dGCyl*, Vec*) const; void setPos(const Vec*, const Vec*, const Vec*); - void setBg(const BE(Vec)*, const BE(Vec)*, const BE(Vec)*, const cM3dGPla*); + void setBg(const Vec*, const Vec*, const Vec*, const cM3dGPla*); void set(const Vec*, const Vec*, const Vec*, const Vec*); bool Cross(cM3dGCps const& cps, cXyz* xyz) const { return cM3d_Cross_CpsTri(cps, *this, xyz); } bool Cross(cM3dGCyl const& cyl, cXyz* xyz) const { return this->cross(&cyl, xyz); } diff --git a/src/SSystem/SComponent/c_m3d_g_tri.cpp b/src/SSystem/SComponent/c_m3d_g_tri.cpp index 714848f241..fcf135b3b8 100644 --- a/src/SSystem/SComponent/c_m3d_g_tri.cpp +++ b/src/SSystem/SComponent/c_m3d_g_tri.cpp @@ -20,7 +20,7 @@ void cM3dGTri::setPos(const Vec* vtx_a, const Vec* vtx_b, const Vec* vtx_c) { JUT_ASSERT(99, !cM3d_IsZero(GetNP()->x) || !cM3d_IsZero(GetNP()->y) || !cM3d_IsZero(GetNP()->z)); } -void cM3dGTri::setBg(const BE(Vec)* vtx_a, const BE(Vec)* vtx_b, const BE(Vec)* vtx_c, const cM3dGPla* plane) { +void cM3dGTri::setBg(const Vec* vtx_a, const Vec* vtx_b, const Vec* vtx_c, const cM3dGPla* plane) { mA.x = vtx_a->x; mA.y = vtx_a->y; mA.z = vtx_a->z; diff --git a/src/d/d_bg_s.cpp b/src/d/d_bg_s.cpp index 44cf033a9b..d4d675b732 100644 --- a/src/d/d_bg_s.cpp +++ b/src/d/d_bg_s.cpp @@ -138,46 +138,18 @@ f32 cBgS::GroundCross(cBgS_GndChk* p_gnd) { return p_gnd->GetNowY(); } -// this is identical to cBgD_t except using u32's for the table offsets. -// u32 is needed to match in ConvDzb ? -struct cBgD_t_ { - // Vertex Info - /* 0x00 */ BE(int) m_v_num; - /* 0x04 */ OFFSET_PTR_RAW m_v_tbl; - - // Triangle Info - /* 0x08 */ BE(int) m_t_num; - /* 0x0C */ OFFSET_PTR_RAW m_t_tbl; - - // Spatial List Info - /* 0x10 */ BE(int) m_b_num; - /* 0x14 */ OFFSET_PTR_RAW m_b_tbl; - - // Face Group Data Info - /* 0x18 */ BE(int) m_tree_num; - /* 0x1C */ OFFSET_PTR_RAW m_tree_tbl; - - // String Group Info - /* 0x20 */ BE(int) m_g_num; - /* 0x24 */ OFFSET_PTR_RAW m_g_tbl; - - // Surface Property Info - /* 0x28 */ BE(int) m_ti_num; - /* 0x2C */ OFFSET_PTR_RAW m_ti_tbl; - - /* 0x30 */ u32 m_flags; -}; // Size: 0x34 - -struct cBgD_Grp_t_ { - OFFSET_PTR_RAW strOffset; - u8 data[0x30]; -}; +template <> +void be_swap(cBgD_Vtx_t& val) { + be_swap(val.x); + be_swap(val.y); + be_swap(val.z); +} void* cBgS::ConvDzb(void* p_dzb) { - cBgD_t_* pbgd = (cBgD_t_*)p_dzb; + cBgD_t* pbgd = (cBgD_t*)p_dzb; - if (((pbgd->m_flags & 0x80000000) == 0)) { - pbgd->m_flags |= 0x80000000; + if (((pbgd->mFlags & 0x80000000) == 0)) { + pbgd->mFlags |= 0x80000000; } else { return p_dzb; } @@ -191,8 +163,15 @@ void* cBgS::ConvDzb(void* p_dzb) { pbgd->m_ti_tbl.setBase(p_dzb); for (int i = 0; i < pbgd->m_g_num; i++) { - ((cBgD_Grp_t_*)pbgd->m_g_tbl)[i].strOffset.setBase(p_dzb); + ((cBgD_Grp_t*)pbgd->m_g_tbl)[i].m_name.setBase(p_dzb); } + +#if TARGET_LITTLE_ENDIAN + for (int i = 0; i < pbgd->m_v_num; i++) { + be_swap(pbgd->m_v_tbl[i]); + } +#endif + #else if (pbgd->m_v_tbl != 0) { pbgd->m_v_tbl += (uintptr_t)p_dzb; diff --git a/src/d/d_bg_w.cpp b/src/d/d_bg_w.cpp index 768c3e4393..5e9f9183ef 100644 --- a/src/d/d_bg_w.cpp +++ b/src/d/d_bg_w.cpp @@ -60,25 +60,12 @@ void cBgW::GlobalVtx() { if (pm_base != NULL) { if (!mNeedsFullTransform) { for (int i = 0; i < pm_bgd->m_v_num; i++) { - BE(Vec)* vtx = &pm_vtx_tbl[i]; -#if TARGET_LITTLE_ENDIAN - Vec copy = *vtx; - VECAdd(©, &mTransVel, ©); - *vtx = copy; -#else + Vec* vtx = &pm_vtx_tbl[i]; VECAdd(vtx, &mTransVel, vtx); -#endif } } else { for (int i = 0; i < pm_bgd->m_v_num; i++) { -#if TARGET_LITTLE_ENDIAN - Vec copy1 = pm_bgd->m_v_tbl[i]; - Vec copy2; - MTXMultVec(pm_base, ©1, ©2); - *(BE(Vec)*)&pm_vtx_tbl[i] = copy2; -#else MTXMultVec(pm_base, &pm_bgd->m_v_tbl[i], &pm_vtx_tbl[i]); -#endif } } } @@ -213,7 +200,7 @@ void cBgW::MakeBlckTransMinMax(cXyz* i_min, cXyz* i_max) { } void cBgW::MakeBlckMinMax(int vtx_index, cXyz* i_min, cXyz* i_max) { - BE(Vec)* vtx = &pm_vtx_tbl[vtx_index]; + cBgD_Vtx_t* vtx = &pm_vtx_tbl[vtx_index]; if (i_min->x > vtx->x) { i_min->x = vtx->x;