mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-12 05:28:43 -04:00
Fix collision data loading (64-bit & BE)
This commit is contained in:
@@ -5,8 +5,13 @@
|
||||
#include "f_pc/f_pc_base.h"
|
||||
#include "SSystem/SComponent/c_bg_s_grp_pass_chk.h"
|
||||
#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:
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define C_M3D_G_TRI_H_
|
||||
|
||||
#include "SSystem/SComponent/c_m3d_g_pla.h"
|
||||
#include "dusk/endian.h"
|
||||
|
||||
class cM3dGCyl;
|
||||
|
||||
@@ -23,7 +24,7 @@ public:
|
||||
virtual ~cM3dGTri() {}
|
||||
bool cross(const cM3dGCyl*, Vec*) const;
|
||||
void setPos(const Vec*, const Vec*, const Vec*);
|
||||
void setBg(const Vec*, const Vec*, const Vec*, const cM3dGPla*);
|
||||
void setBg(const BE(Vec)*, const BE(Vec)*, const BE(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); }
|
||||
|
||||
+39
-36
@@ -6,6 +6,9 @@
|
||||
#include "d/d_bg_w_base.h"
|
||||
#include <dolphin/mtx.h>
|
||||
#include <dolphin/types.h>
|
||||
#include "dusk/offset_ptr.h"
|
||||
#include "dusk/endian.h"
|
||||
#include "dusk/endian_ssystem.h"
|
||||
|
||||
class cBgS_GrpPassChk;
|
||||
class cBgS_PolyPassChk;
|
||||
@@ -54,58 +57,58 @@ struct cBgW_BlkElm {
|
||||
}; // Size: 0x6
|
||||
|
||||
struct cBgD_Tri_t {
|
||||
/* 0x0 */ u16 m_vtx_idx0;
|
||||
/* 0x2 */ u16 m_vtx_idx1;
|
||||
/* 0x4 */ u16 m_vtx_idx2;
|
||||
/* 0x6 */ u16 m_id;
|
||||
/* 0x8 */ u16 m_grp;
|
||||
/* 0x0 */ BE(u16) m_vtx_idx0;
|
||||
/* 0x2 */ BE(u16) m_vtx_idx1;
|
||||
/* 0x4 */ BE(u16) m_vtx_idx2;
|
||||
/* 0x6 */ BE(u16) m_id;
|
||||
/* 0x8 */ BE(u16) m_grp;
|
||||
}; // Size: 0xA
|
||||
|
||||
struct cBgD_Ti_t {
|
||||
/* 0x0 */ u32 m_info0;
|
||||
/* 0x4 */ u32 m_info1;
|
||||
/* 0x8 */ u32 m_info2;
|
||||
/* 0xC */ u32 m_passFlag;
|
||||
/* 0x0 */ BE(u32) m_info0;
|
||||
/* 0x4 */ BE(u32) m_info1;
|
||||
/* 0x8 */ BE(u32) m_info2;
|
||||
/* 0xC */ BE(u32) m_passFlag;
|
||||
};
|
||||
|
||||
struct cBgD_Blk_t {
|
||||
/* 0x0 */ u16 field_0x0;
|
||||
/* 0x0 */ BE(u16) field_0x0;
|
||||
};
|
||||
|
||||
struct cBgD_Tree_t {
|
||||
/* 0x0 */ u16 m_flag;
|
||||
/* 0x2 */ u16 m_parent_id;
|
||||
/* 0x4 */ u16 m_id[8];
|
||||
/* 0x0 */ BE(u16) m_flag;
|
||||
/* 0x2 */ BE(u16) m_parent_id;
|
||||
/* 0x4 */ BE(u16) m_id[8];
|
||||
}; // Size: 0x14
|
||||
|
||||
struct cBgD_Grp_t {
|
||||
/* 0x00 */ char* m_name;
|
||||
/* 0x04 */ cXyz m_scale;
|
||||
/* 0x10 */ csXyz m_rotation;
|
||||
/* 0x18 */ cXyz m_translation;
|
||||
/* 0x24 */ u16 m_parent;
|
||||
/* 0x26 */ u16 m_next_sibling;
|
||||
/* 0x28 */ u16 m_first_child;
|
||||
/* 0x2A */ u16 m_room_id;
|
||||
/* 0x2C */ u16 m_first_vtx_idx;
|
||||
/* 0x2E */ u16 m_tree_idx;
|
||||
/* 0x30 */ u32 m_info;
|
||||
/* 0x04 */ BE(cXyz) m_scale;
|
||||
/* 0x10 */ BE(csXyz) m_rotation;
|
||||
/* 0x18 */ BE(cXyz) m_translation;
|
||||
/* 0x24 */ BE(u16) m_parent;
|
||||
/* 0x26 */ BE(u16) m_next_sibling;
|
||||
/* 0x28 */ BE(u16) m_first_child;
|
||||
/* 0x2A */ BE(u16) m_room_id;
|
||||
/* 0x2C */ BE(u16) m_first_vtx_idx;
|
||||
/* 0x2E */ BE(u16) m_tree_idx;
|
||||
/* 0x30 */ BE(u32) m_info;
|
||||
}; // Size: 0x34
|
||||
|
||||
struct cBgD_t {
|
||||
/* 0x00 */ int m_v_num; // vertex num
|
||||
/* 0x04 */ cBgD_Vtx_t* m_v_tbl; // vertex table
|
||||
/* 0x08 */ int m_t_num; // triangle num
|
||||
/* 0x0C */ cBgD_Tri_t* m_t_tbl; // triangle table
|
||||
/* 0x10 */ int m_b_num;
|
||||
/* 0x14 */ cBgD_Blk_t* m_b_tbl;
|
||||
/* 0x18 */ int m_tree_num;
|
||||
/* 0x1C */ cBgD_Tree_t* m_tree_tbl;
|
||||
/* 0x20 */ int m_g_num;
|
||||
/* 0x24 */ cBgD_Grp_t* m_g_tbl;
|
||||
/* 0x28 */ int m_ti_num;
|
||||
/* 0x2C */ cBgD_Ti_t* m_ti_tbl;
|
||||
/* 0x30 */ int mFlags;
|
||||
/* 0x00 */ BE(int) m_v_num; // vertex num
|
||||
/* 0x04 */ OFFSET_PTR(cBgD_Vtx_t) m_v_tbl; // vertex table
|
||||
/* 0x08 */ BE(int) m_t_num; // triangle num
|
||||
/* 0x0C */ OFFSET_PTR(cBgD_Tri_t) m_t_tbl; // triangle table
|
||||
/* 0x10 */ BE(int) m_b_num;
|
||||
/* 0x14 */ OFFSET_PTR(cBgD_Blk_t) m_b_tbl;
|
||||
/* 0x18 */ BE(int) m_tree_num;
|
||||
/* 0x1C */ OFFSET_PTR(cBgD_Tree_t) m_tree_tbl;
|
||||
/* 0x20 */ BE(int) m_g_num;
|
||||
/* 0x24 */ OFFSET_PTR(cBgD_Grp_t) m_g_tbl;
|
||||
/* 0x28 */ BE(int) m_ti_num;
|
||||
/* 0x2C */ OFFSET_PTR(cBgD_Ti_t) m_ti_tbl;
|
||||
/* 0x30 */ BE(int) mFlags;
|
||||
};
|
||||
|
||||
class cBgW : public dBgW_Base {
|
||||
|
||||
@@ -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 Vec* vtx_a, const Vec* vtx_b, const Vec* vtx_c, const cM3dGPla* plane) {
|
||||
void cM3dGTri::setBg(const BE(Vec)* vtx_a, const BE(Vec)* vtx_b, const BE(Vec)* vtx_c, const cM3dGPla* plane) {
|
||||
mA.x = vtx_a->x;
|
||||
mA.y = vtx_a->y;
|
||||
mA.z = vtx_a->z;
|
||||
|
||||
+27
-13
@@ -10,6 +10,7 @@
|
||||
#include "d/d_bg_w.h"
|
||||
#include "d/d_com_inf_game.h"
|
||||
#include "f_op/f_op_actor_mng.h"
|
||||
#include "dusk/offset_ptr.h"
|
||||
|
||||
void cBgS_ChkElm::Init() {
|
||||
m_bgw_base_ptr = NULL;
|
||||
@@ -141,34 +142,34 @@ f32 cBgS::GroundCross(cBgS_GndChk* p_gnd) {
|
||||
// u32 is needed to match in ConvDzb ?
|
||||
struct cBgD_t_ {
|
||||
// Vertex Info
|
||||
/* 0x00 */ int m_v_num;
|
||||
/* 0x04 */ u32 m_v_tbl;
|
||||
/* 0x00 */ BE(int) m_v_num;
|
||||
/* 0x04 */ OFFSET_PTR_RAW m_v_tbl;
|
||||
|
||||
// Triangle Info
|
||||
/* 0x08 */ int m_t_num;
|
||||
/* 0x0C */ u32 m_t_tbl;
|
||||
/* 0x08 */ BE(int) m_t_num;
|
||||
/* 0x0C */ OFFSET_PTR_RAW m_t_tbl;
|
||||
|
||||
// Spatial List Info
|
||||
/* 0x10 */ int m_b_num;
|
||||
/* 0x14 */ u32 m_b_tbl;
|
||||
/* 0x10 */ BE(int) m_b_num;
|
||||
/* 0x14 */ OFFSET_PTR_RAW m_b_tbl;
|
||||
|
||||
// Face Group Data Info
|
||||
/* 0x18 */ int m_tree_num;
|
||||
/* 0x1C */ u32 m_tree_tbl;
|
||||
/* 0x18 */ BE(int) m_tree_num;
|
||||
/* 0x1C */ OFFSET_PTR_RAW m_tree_tbl;
|
||||
|
||||
// String Group Info
|
||||
/* 0x20 */ int m_g_num;
|
||||
/* 0x24 */ u32 m_g_tbl;
|
||||
/* 0x20 */ BE(int) m_g_num;
|
||||
/* 0x24 */ OFFSET_PTR_RAW m_g_tbl;
|
||||
|
||||
// Surface Property Info
|
||||
/* 0x28 */ int m_ti_num;
|
||||
/* 0x2C */ u32 m_ti_tbl;
|
||||
/* 0x28 */ BE(int) m_ti_num;
|
||||
/* 0x2C */ OFFSET_PTR_RAW m_ti_tbl;
|
||||
|
||||
/* 0x30 */ u32 m_flags;
|
||||
}; // Size: 0x34
|
||||
|
||||
struct cBgD_Grp_t_ {
|
||||
u32 strOffset;
|
||||
OFFSET_PTR_RAW strOffset;
|
||||
u8 data[0x30];
|
||||
};
|
||||
|
||||
@@ -181,6 +182,18 @@ void* cBgS::ConvDzb(void* p_dzb) {
|
||||
return p_dzb;
|
||||
}
|
||||
|
||||
#if TARGET_PC
|
||||
pbgd->m_v_tbl.setBase(p_dzb);
|
||||
pbgd->m_t_tbl.setBase(p_dzb);
|
||||
pbgd->m_b_tbl.setBase(p_dzb);
|
||||
pbgd->m_tree_tbl.setBase(p_dzb);
|
||||
pbgd->m_g_tbl.setBase(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);
|
||||
}
|
||||
#else
|
||||
if (pbgd->m_v_tbl != 0) {
|
||||
pbgd->m_v_tbl += (uintptr_t)p_dzb;
|
||||
}
|
||||
@@ -195,6 +208,7 @@ void* cBgS::ConvDzb(void* p_dzb) {
|
||||
((cBgD_Grp_t_*)pbgd->m_g_tbl)[i].strOffset =
|
||||
(uintptr_t)p_dzb + ((cBgD_Grp_t_*)pbgd->m_g_tbl)[i].strOffset;
|
||||
}
|
||||
#endif
|
||||
|
||||
return p_dzb;
|
||||
}
|
||||
|
||||
+25
-2
@@ -60,12 +60,25 @@ void cBgW::GlobalVtx() {
|
||||
if (pm_base != NULL) {
|
||||
if (!mNeedsFullTransform) {
|
||||
for (int i = 0; i < pm_bgd->m_v_num; i++) {
|
||||
Vec* vtx = &pm_vtx_tbl[i];
|
||||
BE(Vec)* vtx = &pm_vtx_tbl[i];
|
||||
#if TARGET_LITTLE_ENDIAN
|
||||
Vec copy = *vtx;
|
||||
VECAdd(©, &mTransVel, ©);
|
||||
*vtx = copy;
|
||||
#else
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,9 +120,19 @@ void cBgW::CalcPlane() {
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < pm_bgd->m_t_num; i++) {
|
||||
#if TARGET_LITTLE_ENDIAN
|
||||
Vec copy1 = pm_vtx_tbl[tri[i].m_vtx_idx0];
|
||||
Vec copy2 = pm_vtx_tbl[tri[i].m_vtx_idx1];
|
||||
Vec copy3 = pm_vtx_tbl[tri[i].m_vtx_idx2];
|
||||
pm_tri[i].m_plane.SetupFrom3Vtx(
|
||||
©1,
|
||||
©2,
|
||||
©3);
|
||||
#else
|
||||
pm_tri[i].m_plane.SetupFrom3Vtx(&pm_vtx_tbl[tri[i].m_vtx_idx0],
|
||||
&pm_vtx_tbl[tri[i].m_vtx_idx1],
|
||||
&pm_vtx_tbl[tri[i].m_vtx_idx2]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,7 +213,7 @@ void cBgW::MakeBlckTransMinMax(cXyz* i_min, cXyz* i_max) {
|
||||
}
|
||||
|
||||
void cBgW::MakeBlckMinMax(int vtx_index, cXyz* i_min, cXyz* i_max) {
|
||||
Vec* vtx = &pm_vtx_tbl[vtx_index];
|
||||
BE(Vec)* vtx = &pm_vtx_tbl[vtx_index];
|
||||
|
||||
if (i_min->x > vtx->x) {
|
||||
i_min->x = vtx->x;
|
||||
|
||||
@@ -1002,9 +1002,18 @@ int dDlst_shadowPoly_c::set(cBgD_Vtx_t* i_vtx, u16 param_1, u16 param_2, u16 par
|
||||
b.z *= temp_f3;
|
||||
b *= 2.0f;
|
||||
|
||||
#if TARGET_LITTLE_ENDIAN
|
||||
Vec copy1 = vtx[param_1];
|
||||
Vec copy2 = vtx[param_2];
|
||||
Vec copy3 = vtx[param_3];
|
||||
PSVECAdd(©1, &b, &dst->mPos[0]);
|
||||
PSVECAdd(©2, &b, &dst->mPos[1]);
|
||||
PSVECAdd(©3, &b, &dst->mPos[2]);
|
||||
#else
|
||||
PSVECAdd(&vtx[param_1], &b, &dst->mPos[0]);
|
||||
PSVECAdd(&vtx[param_2], &b, &dst->mPos[1]);
|
||||
PSVECAdd(&vtx[param_3], &b, &dst->mPos[2]);
|
||||
#endif
|
||||
mCount++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user