d_bg_w progress

This commit is contained in:
LagoLunatic
2025-03-06 01:12:50 -05:00
parent a80f464ab7
commit d882c16b55
28 changed files with 362 additions and 93 deletions
-3
View File
@@ -1,12 +1,9 @@
#ifndef C_BG_S_CHK_H
#define C_BG_S_CHK_H
#include "dolphin/mtx/vec.h"
#include "f_pc/f_pc_base.h"
#include "global.h"
struct cBgD_Vtx_t : public Vec {};
class cBgS_GrpPassChk {
public:
virtual ~cBgS_GrpPassChk() {}
@@ -7,6 +7,7 @@
#include "global.h"
class cBgW;
class cBgS_PolyInfo {
private:
/* 0x00 */ u16 mPolyIndex;
+9 -8
View File
@@ -33,7 +33,7 @@ public:
}
};
struct cBgD_Vtx_t;
struct cBgD_Vtx_t : public Vec {};
struct cBgD_Blk_t {
/* 0x00 */ u16 startTri;
@@ -201,6 +201,7 @@ public:
BOOL ChkPriority(int prio) { return mWallCorrectPriority == prio; }
Mtx* GetBaseMtxP() { return pm_base; }
void SetBaseMtxP(Mtx* mtx_p) { pm_base = mtx_p; }
u32 GetPolyInfId(int poly_index) const {
JUT_ASSERT(0x2f1, 0 <= poly_index && poly_index < pm_bgd->m_t_num);
return pm_bgd->m_t_tbl[poly_index].id;
@@ -222,8 +223,8 @@ public:
return pm_bgd->m_ti_tbl[id].mPolyInf3;
}
int GetVtxNum() const { return pm_bgd->m_v_num; }
Vec* GetVtxTbl() const { return pm_vtx_tbl; }
void SetVtxTbl(Vec* v) { pm_vtx_tbl = v; }
cBgD_Vtx_t* GetVtxTbl() const { return pm_vtx_tbl; }
void SetVtxTbl(Vec* v) { pm_vtx_tbl = (cBgD_Vtx_t*)v; }
bool GroundCross(cBgS_GndChk* chk) {
return GroundCrossGrpRp(chk, m_rootGrpIdx, 1);
}
@@ -231,6 +232,10 @@ public:
return LineCheckGrpRp(chk, m_rootGrpIdx, 1);
}
void ShdwDraw(cBgS_ShdwDraw* shdw) {
ShdwDrawGrpRp(shdw, m_rootGrpIdx);
}
void GetOldInvMtx(Mtx) const {}
bool ChkFlush() { return mIgnorePlaneType & 8; }
void ChkGroundRegist() {}
@@ -238,10 +243,6 @@ public:
void ChkThrough() {}
void ChkWallRegist() {}
void OffRoofRegist() {}
void SetBaseMtxP(Mtx* mtx_p) { pm_base = mtx_p; }
void ShdwDraw(cBgS_ShdwDraw* shdw) {
ShdwDrawGrpRp(shdw, m_rootGrpIdx);
}
virtual ~cBgW();
virtual u32 GetGrpToRoomIndex(int) const;
@@ -264,7 +265,7 @@ public:
/* 0x7C */ cXyz mTransVel;
/* 0x88 */ cBgW_TriElm* pm_tri;
/* 0x8C */ cBgW_RwgElm* pm_rwg;
/* 0x90 */ Vec* pm_vtx_tbl;
/* 0x90 */ cBgD_Vtx_t* pm_vtx_tbl;
/* 0x94 */ cBgD_t* pm_bgd;
/* 0x98 */ cBgW_BlkElm* pm_blk;
/* 0x9C */ cBgW_GrpElm* pm_grp;
+2
View File
@@ -332,6 +332,8 @@ private:
/* 0x00 vtable */
}; // Size = 0x4
STATIC_ASSERT(sizeof(cCcD_GStts) == 0x4);
class cCcD_Stts {
private:
/* 0x00 */ cXyz m_cc_move;
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef C_M2D_H
#define C_M2D_H
#include "dolphin/types.h"
#include "global.h"
struct cM2dGCir;
+6
View File
@@ -52,6 +52,12 @@ struct cM3d_Range {
f32 end;
};
inline f32 cM3d_Len2dSq(f32 x0, f32 y0, f32 x1, f32 y1) {
f32 x = x0 - x1;
f32 y = y0 - y1;
return x*x + y*y;
}
void cM3d_InDivPos1(const Vec*, const Vec*, f32, Vec*);
void cM3d_InDivPos2(const Vec*, const Vec*, f32, Vec*);
bool cM3d_Len2dSqPntAndSegLine(f32, f32, f32, f32, f32, f32, f32*, f32*, f32*);
+7 -3
View File
@@ -1,7 +1,7 @@
#ifndef C_M3D_G_CIR_H
#define C_M3D_G_CIR_H
#include "dolphin/types.h"
#include "global.h"
class cM2dGCir {
public:
@@ -20,7 +20,9 @@ public:
cM2dGCir() {}
virtual ~cM2dGCir() {}
};
}; // Size: 0x10
STATIC_ASSERT(sizeof(cM2dGCir) == 0x10);
class cM3dGCir : public cM2dGCir {
f32 mPosZ;
@@ -32,6 +34,8 @@ public:
cM2dGCir::Set(x, y, r);
mPosZ = z;
}
};
}; // Size: 0x14
STATIC_ASSERT(sizeof(cM3dGCir) == 0x14);
#endif /* C_M3D_G_CIR_H */
+3
View File
@@ -4,6 +4,7 @@
#include "SSystem/SComponent/c_xyz.h"
#include "SSystem/SComponent/c_m3d.h"
#include "dolphin/mtx/vec.h"
#include "global.h"
// Plane with a normal
class cM3dGPla {
@@ -61,4 +62,6 @@ public:
cM3dGPla(const cXyz*, f32) {}
}; // Size: 0x14
STATIC_ASSERT(sizeof(cM3dGPla) == 0x14);
#endif
+3 -1
View File
@@ -45,7 +45,9 @@ public:
cXyz temp;
return cM3d_Cross_CylSph(cyl, this, &temp, out);
}
void cross(const cM3dGTri*) const {}
bool cross(const cM3dGTri *param_1) const {
return cM3d_Cross_SphTri(this, param_1);
}
const cXyz& GetC() const { return mCenter; }
cXyz& GetC() { return mCenter; }
const cXyz* GetCP() const { return &mCenter; }
+1 -1
View File
@@ -61,7 +61,7 @@ public:
void setUp() {
SetupFrom3Vtx(&mA, &mB, &mC);
}
~cM3dGTri() {}
virtual ~cM3dGTri() {}
}; // Size: 0x38
#endif
+1 -1
View File
@@ -94,4 +94,4 @@ STATIC_ASSERT(sizeof(daItemBase_c) == 0x63C);
int CheckItemCreateHeap(fopAc_ac_c*);
int CheckFieldItemCreateHeap(fopAc_ac_c*);
#endif /* D_A_ITEMBASE_H */
#endif /* D_A_ITEMBASE_H */
+1 -2
View File
@@ -9,7 +9,6 @@
#include "SSystem/SComponent/c_m3d_g_cyl.h"
#include "d/d_bg_s_chk.h"
#include "d/d_bg_w.h"
#include "global.h"
#include "f_pc/f_pc_manager.h"
class cBgS_LinChk;
@@ -210,4 +209,4 @@ public:
u32 dBgS_GetRoomPathPntNo(u32 polyinfo2);
void dBgS_ChangeAttributeCode(u32 code, u32* dst);
#endif /* D_BG_D_BG_S_H */
#endif /* D_BG_D_BG_S_H */
+56 -15
View File
@@ -40,15 +40,23 @@ public:
f32 GetWallR() { return m_wall_r; }
s16 GetWallAngleY() { return m_wall_angle_y; }
void SetWallH(f32 h) { m_wall_h = h; }
f32 GetWallRR() { return m_wall_rr; }
void SetWallAngleY(s16 i_angle) { m_wall_angle_y = i_angle; }
bool ChkWallHit() { return m_flags & WALL_HIT; }
void SetWallHit() { m_flags |= WALL_HIT; }
void ClrWallHit() { m_flags &= ~WALL_HIT; ClearPi(); }
bool ChkWallHDirect() { return m_flags & WALL_H_DIRECT; }
void SetWallHDirect(f32 h) { m_flags |= WALL_H_DIRECT; m_wall_h_direct = h; }
void ClrWallHDirect() { m_flags &= ~WALL_H_DIRECT; }
bool ChkWallHit() { return m_flags & WALL_HIT; }
void ClrWallHit() {
m_flags &= ~WALL_HIT;
ClearPi();
}
f32 GetWallHDirect() { return m_wall_h_direct; }
void SetCir(cXyz& pos) { m_cir.Set(pos.x, pos.z, pos.y + GetWallH(), m_wall_r); }
cM3dGCir* GetCirP() { return &m_cir; }
void SetWallPolyIndex(int poly_index) {
SetPolyIndex(poly_index);
}
}; // Size: 0x40
class dBgS;
@@ -92,25 +100,32 @@ public:
void SetGroundUpY(f32);
f32 GetWallAllLowH();
f32 GetWallAllLowH_R();
f32 GetSpeedY();
f32 GetWallAddY(Vec&);
f32 GetSpeedY() {
if (pm_speed != NULL) {
return pm_speed->y;
}
return 0.0f;
}
void SetNowActorInfo(int bg_index, void* bgw, fpc_ProcID apid) {
m_bg_index = bg_index;
field_0x78 = bgw;
m_ap_id = apid;
}
void SetWallPolyIndex(int, int);
void CalcMovePosWork();
void SetWallPolyIndex(int index, int poly_index) {
JUT_ASSERT(628, index <= m_tbl_size);
pm_acch_cir[index].SetActorInfo(m_bg_index, field_0x78, m_ap_id);
pm_acch_cir[index].SetWallPolyIndex(poly_index);
}
void CalcMovePosWork() {
SetWallCir();
SetLin();
CalcWallBmdCyl();
}
void CalcWallRR() {
for (s32 i = 0; i < m_tbl_size; i++)
pm_acch_cir[i].CalcWallRR();
}
void SetGndThinCellingOff();
void ClrGndThinCellingOff();
bool ChkGndThinCellingOff();
void OnWallSort();
bool ChkWallSort();
bool ChkLineDown();
bool GetOnePolyInfo(cBgS_PolyInfo*);
f32 GetWallAddY(Vec&, int);
@@ -174,6 +189,30 @@ public:
bool ChkSeaIn() { return m_flags & SEA_IN;}
cM3dGCyl* GetWallBmdCylP() { return &m_wall_cyl; }
cM3dGCir* GetWallCirP(int index) {
JUT_ASSERT(761, index <= m_tbl_size);
return pm_acch_cir[index].GetCirP();
}
int GetTblSize() { return m_tbl_size; }
f32 GetWallH(int i_no) { return pm_acch_cir[i_no].GetWallH(); }
f32 GetWallR(int i_no) { return pm_acch_cir[i_no].GetWallR(); }
bool ChkWallHDirect(int i_no) { return pm_acch_cir[i_no].ChkWallHDirect(); }
f32 GetWallHDirect(int i_no) { return pm_acch_cir[i_no].GetWallHDirect(); }
f32 GetWallRR(int i_no) { return pm_acch_cir[i_no].GetWallRR(); }
void SetWallCirHit(int i_no) { pm_acch_cir[i_no].SetWallHit(); }
void SetWallAngleY(int i_no, s16 i_angle) { pm_acch_cir[i_no].SetWallAngleY(i_angle); }
f32 GetCx() const { return pm_pos->x; }
f32 GetCz() const { return pm_pos->z; }
// TODO
void ChkGroundAway() {}
void DrawWall(dBgS&) {}
void OnLineCheckHit() {}
void SetOld() {}
public:
/* 0x028 */ u32 m_flags;
/* 0x02C */ cXyz* pm_pos;
@@ -226,4 +265,6 @@ public:
virtual ~dBgS_ObjAcch() {}
}; // Size: 0x1C4
STATIC_ASSERT(sizeof(dBgS_ObjAcch) == 0x1C4);
#endif /* D_BG_D_BG_S_ACCH_H */
+5 -5
View File
@@ -3,8 +3,8 @@
#include "SSystem/SComponent/c_bg_s_poly_info.h"
#include "SSystem/SComponent/c_m3d_g_sph.h"
#include "SSystem/SComponent/c_xyz.h"
#include "d/d_bg_s_chk.h"
#include "SSystem/SComponent/c_bg_w.h"
class dBgS_SphChk : public cM3dGSph, public cBgS_PolyInfo, public cBgS_Chk, public dBgS_Chk {
public:
@@ -15,11 +15,11 @@ public:
virtual ~dBgS_SphChk() {}
typedef void(*Callback)(dBgS_SphChk*, cBgD_Vtx_t*, int, int, int, cM3dGPla*, void*);
void SetCallback(Callback cb) { mpCallback = cb; }
typedef void(*SphChk_Callback)(dBgS_SphChk*, cBgD_Vtx_t*, int, int, int, cM3dGPla*, void*);
void SetCallback(SphChk_Callback cb) { mpCallback = cb; }
public:
/* 0x4c */ Callback mpCallback;
/* 0x4c */ SphChk_Callback mpCallback;
}; // Size: 0x50
#endif /* D_BG_D_BG_S_SPH_CHK_H */
#endif /* D_BG_D_BG_S_SPH_CHK_H */
+3
View File
@@ -52,6 +52,8 @@ public:
bool WallCrrPos(dBgS_CrrPos*);
void ChangeAttributeCodeByPathPntNo(int, u32);
void dummyfunc(); // for assert. TODO remove later
virtual ~dBgW() {}
virtual bool ChkPolyThrough(int, cBgS_PolyPassChk*);
virtual bool ChkShdwDrawThrough(int, cBgS_PolyPassChk*);
@@ -66,6 +68,7 @@ public:
void SetRideCallback(dBgW_RideCallBack func) { mpRideCb = func; }
void SetPushPullCallback(dBgW_PPCallBack func) { mpPushPullCb = func; }
// TODO:
void CalcDiffShapeAngleY(s16) {}
void CaptPoly(dBgS_CaptPoly&) {}
void CaptPolyGrpRp(dBgS_CaptPoly&, int) {}
+9 -3
View File
@@ -201,6 +201,8 @@ public:
/* 0x1C */ u32 mFlag;
}; // Size = 0x20
STATIC_ASSERT(sizeof(dCcD_GStts) == 0x20);
class dCcD_Stts : public cCcD_Stts, public dCcD_GStts {
public:
dCcD_Stts() {}
@@ -224,6 +226,8 @@ public:
/* 0x1C */ /* dCcD_GStts */
}; // Size = 0x3C
STATIC_ASSERT(sizeof(dCcD_Stts) == 0x3C);
class dCcD_GObjInf;
typedef void (*dCcD_HitCallback)(fopAc_ac_c*, dCcD_GObjInf*, fopAc_ac_c*, dCcD_GObjInf*);
@@ -483,7 +487,7 @@ public:
/* 0xF8 */ /* cCcD_CylAttr */
void Set(dCcD_SrcCyl const&);
cCcD_ShapeAttr* GetShapeAttr() { return this; }
virtual cCcD_ShapeAttr* GetShapeAttr() { return this; }
void StartCAt(cXyz&);
void StartCTg(cXyz&);
void MoveCAtTg(cXyz&);
@@ -493,6 +497,8 @@ public:
dCcD_Cyl() {}
}; // Size = 0x130
STATIC_ASSERT(sizeof(dCcD_Cyl) == 0x130);
// Sphere
class dCcD_Sph : public dCcD_GObjInf, public cCcD_SphAttr {
public:
@@ -511,7 +517,7 @@ public:
/* 0xF8 */ /* cCcD_CpsAttr */
void Set(dCcD_SrcCps const&);
cCcD_ShapeAttr* GetShapeAttr() { return (cCcD_ShapeAttr*)this; }
virtual cCcD_ShapeAttr* GetShapeAttr() { return (cCcD_ShapeAttr*)this; }
void CalcAtVec() {
cXyz* atVecP = GetAtVecP();
CalcVec(atVecP);
@@ -525,7 +531,7 @@ public:
class dCcD_Tri : public dCcD_GObjInf, public cCcD_TriAttr {
public:
void Set(dCcD_SrcTri const&);
cCcD_ShapeAttr* GetShapeAttr() { return this; }
virtual cCcD_ShapeAttr* GetShapeAttr() { return this; }
virtual ~dCcD_Tri() {}
dCcD_Tri() {}
};
@@ -12,7 +12,7 @@
#define FP_NAN FP_QNAN
#define fpclassify(x) ((sizeof(x) == sizeof(float)) ? __fpclassifyf(x) : __fpclassifyd(x))
#define fpclassify(x) ((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) : __fpclassifyd((double)(x)) )
#define signbit(x) ((sizeof(x) == sizeof(float)) ? __signbitf(x) : __signbitd(x))
#define isfinite(x) ((fpclassify(x) > 2))
#define isnan(x) ((fpclassify(x) == FP_NAN))
+1 -1
View File
@@ -78,7 +78,7 @@ bool cBgW::SetVtx() {
pm_vtx_tbl = NULL;
} else {
if (ChkMoveBg()) {
pm_vtx_tbl = new Vec[pm_bgd->m_v_num];
pm_vtx_tbl = (cBgD_Vtx_t*)new Vec[pm_bgd->m_v_num];
if (pm_vtx_tbl == NULL)
return true;
+1 -1
View File
@@ -8,7 +8,7 @@
#include "f_pc/f_pc_manager.h"
#include "dolphin/types.h"
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) : __fpclassifyd((double)(x)) ) == 1));
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(fpclassify(x) == 1));
#define CHECK_FLOAT_RANGE(line, x) JUT_ASSERT(line, -1.0e32f < x && x < 1.0e32f);
#define CHECK_VEC3_RANGE(line, v) JUT_ASSERT(line, -1.0e32f < v.x && v.x < 1.0e32f && -1.0e32f < v.y && v.y < 1.0e32f && -1.0e32f < v.z && v.z < 1.0e32f)
+1 -1
View File
@@ -6,7 +6,7 @@
#include "SSystem/SComponent/c_cc_s.h"
#include "JSystem/JUtility/JUTAssert.h"
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) : __fpclassifyd((double)(x)) ) == 1));
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(fpclassify(x) == 1));
#define CHECK_FLOAT_RANGE(line, x) JUT_ASSERT(line, -1.0e32f < x && x < 1.0e32f);
#define CHECK_VEC3_RANGE(line, v) JUT_ASSERT(line, -1.0e32f < v.x && v.x < 1.0e32f && -1.0e32f < v.y && v.y < 1.0e32f && -1.0e32f < v.z && v.z < 1.0e32f)
#define CHECK_PVEC3_RANGE(line, v) JUT_ASSERT(line, -1.0e32f < v->x && v->x < 1.0e32f && -1.0e32f < v->y && v->y < 1.0e32f && -1.0e32f < v->z && v->z < 1.0e32f)
+1 -7
View File
@@ -15,7 +15,7 @@
#include "SSystem/SComponent/c_math.h"
#include "SSystem/SComponent/c_sxyz.h"
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) : __fpclassifyd((double)(x)) ) == 1));
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(fpclassify(x) == 1));
#define CHECK_FLOAT_RANGE(line, x) JUT_ASSERT(line, -1.0e32f < x && x < 1.0e32f);
#define CHECK_VEC3_RANGE(line, v) JUT_ASSERT(line, -1.0e32f < v.x && v.x < 1.0e32f && -1.0e32f < v.y && v.y < 1.0e32f && -1.0e32f < v.z && v.z < 1.0e32f)
#define CHECK_PVEC3_RANGE(line, v) JUT_ASSERT(line, -1.0e32f < v->x && v->x < 1.0e32f && -1.0e32f < v->y && v->y < 1.0e32f && -1.0e32f < v->z && v->z < 1.0e32f)
@@ -41,12 +41,6 @@ void cM3d_InDivPos2(const Vec* v0, const Vec* v1, f32 scale, Vec* pDst) {
cM3d_InDivPos1(v0, &tmp, scale, pDst);
}
inline f32 cM3d_Len2dSq(f32 x0, f32 y0, f32 x1, f32 y1) {
f32 x = x0 - x1;
f32 y = y0 - y1;
return x*x + y*y;
}
/* 8024A4B4-8024A56C .text cM3d_Len2dSqPntAndSegLine__FffffffPfPfPf */
bool cM3d_Len2dSqPntAndSegLine(f32 xp, f32 yp, f32 x0, f32 y0, f32 x1, f32 y1, f32* outx, f32* outy,
f32* seg) {
+1 -1
View File
@@ -8,7 +8,7 @@
#include "JSystem/JUtility/JUTAssert.h"
#include "float.h"
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) : __fpclassifyd((double)(x)) ) == 1));
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(fpclassify(x) == 1));
#define CHECK_FLOAT_RANGE(line, x) JUT_ASSERT(line, -1.0e32f < x && x < 1.0e32f);
#define CHECK_VEC3_RANGE(line, v) JUT_ASSERT(line, -1.0e32f < v.x && v.x < 1.0e32f && -1.0e32f < v.y && v.y < 1.0e32f && -1.0e32f < v.z && v.z < 1.0e32f)
+1 -1
View File
@@ -8,7 +8,7 @@
#include "JSystem/JUtility/JUTAssert.h"
#include "float.h"
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) : __fpclassifyd((double)(x)) ) == 1));
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(fpclassify(x) == 1));
#define CHECK_FLOAT_RANGE(line, x) JUT_ASSERT(line, -1.0e32f < x && x < 1.0e32f);
#define CHECK_VEC3_RANGE(line, v) JUT_ASSERT(line, -1.0e32f < v.x && v.x < 1.0e32f && -1.0e32f < v.y && v.y < 1.0e32f && -1.0e32f < v.z && v.z < 1.0e32f)
+1 -1
View File
@@ -9,7 +9,7 @@
#include "d/d_com_inf_game.h"
#include "f_op/f_op_actor_mng.h"
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) : __fpclassifyd((double)(x)) ) == 1));
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(fpclassify(x) == 1));
#define CHECK_FLOAT_RANGE(line, x) JUT_ASSERT(line, -1.0e32f < x && x < 1.0e32f);
#define CHECK_VEC3_RANGE(line, v) JUT_ASSERT(line, -1.0e32f < v.x && v.x < 1.0e32f && -1.0e32f < v.y && v.y < 1.0e32f && -1.0e32f < v.z && v.z < 1.0e32f)
#define CHECK_PVEC3_RANGE(line, v) JUT_ASSERT(line, -1.0e32f < v->x && v->x < 1.0e32f && -1.0e32f < v->y && v->y < 1.0e32f && -1.0e32f < v->z && v->z < 1.0e32f)
+1 -1
View File
@@ -11,7 +11,7 @@
#include "d/d_com_inf_game.h"
#include "d/actor/d_a_sea.h"
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) : __fpclassifyd((double)(x)) ) == 1));
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(fpclassify(x) == 1));
#define CHECK_FLOAT_RANGE(line, x) JUT_ASSERT(line, -1.0e32f < x && x < 1.0e32f);
#define CHECK_VEC3_RANGE(line, v) JUT_ASSERT(line, -1.0e32f < v.x && v.x < 1.0e32f && -1.0e32f < v.y && v.y < 1.0e32f && -1.0e32f < v.z && v.z < 1.0e32f)
#define CHECK_PVEC3_RANGE(line, v) JUT_ASSERT(line, -1.0e32f < v->x && v->x < 1.0e32f && -1.0e32f < v->y && v->y < 1.0e32f && -1.0e32f < v->z && v->z < 1.0e32f)
+241 -31
View File
@@ -7,8 +7,10 @@
#include "d/d_bg_s.h"
#include "d/d_bg_s_acch.h"
#include "d/d_bg_s_sph_chk.h"
#include "SSystem/SComponent/c_m2d.h"
#include "SSystem/SComponent/c_math.h"
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) : __fpclassifyd((double)(x)) ) == 1));
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(fpclassify(x) == 1));
/* 800A5C3C-800A5CA8 .text __ct__4dBgWFv */
dBgW::dBgW() {
@@ -39,8 +41,218 @@ void dBgW::positionWallCorrect(dBgS_Acch* acch, f32 dist, cM3dGPla& plane, cXyz*
}
/* 800A5E64-800A6DF8 .text RwgWallCorrect__4dBgWFP9dBgS_AcchUs */
bool dBgW::RwgWallCorrect(dBgS_Acch*, u16) {
/* Nonmatching */
bool dBgW::RwgWallCorrect(dBgS_Acch* pwi, u16 i_poly_idx) {
bool correct = false;
while (true) {
cBgW_RwgElm* rwg_elm = &pm_rwg[i_poly_idx];
if (!ChkPolyThrough(i_poly_idx, pwi->GetPolyPassChk())) {
cBgW_TriElm* tri = &pm_tri[i_poly_idx];
f32 sp68 = std::sqrtf(tri->m_plane.GetNP()->x * tri->m_plane.GetNP()->x +
tri->m_plane.GetNP()->z * tri->m_plane.GetNP()->z);
if (cM3d_IsZero(sp68)) {
if (rwg_elm->next != 0xFFFF) {
i_poly_idx = rwg_elm->next;
continue;
}
break;
}
f32 sp6C = 1.0f / sp68;
cBgD_Tri_t* tri_data = &pm_bgd->m_t_tbl[i_poly_idx];
int cir_index = 0;
while (cir_index < pwi->GetTblSize()) {
f32 sp78 = sp6C * pwi->GetWallR(cir_index);
Vec sp50;
sp50.x = sp78 * tri->m_plane.GetNP()->x;
sp50.y = 0.0f;
sp50.z = sp78 * tri->m_plane.GetNP()->z;
f32 sp7C;
if (!pwi->ChkWallHDirect(cir_index)) {
sp7C =
(pwi->GetWallAddY(sp50, cir_index) + (pwi->GetPos()->y + pwi->GetWallH(cir_index))) -
pwi->GetSpeedY();
} else {
sp7C = pwi->GetWallHDirect(cir_index);
}
f32 sp5C[3];
sp5C[0] = pm_vtx_tbl[tri_data->vtx0].y - sp7C;
sp5C[1] = pm_vtx_tbl[tri_data->vtx1].y - sp7C;
sp5C[2] = pm_vtx_tbl[tri_data->vtx2].y - sp7C;
if ((!(sp5C[0] > 0.0f) || !(sp5C[1] > 0.0f) || !(sp5C[2] > 0.0f)) &&
(!(sp5C[0] < 0.0f) || !(sp5C[1] < 0.0f) || !(sp5C[2] < 0.0f)))
{
int sp8C = 0;
if (cM3d_IsZero(sp5C[0])) {
sp8C++;
}
if (cM3d_IsZero(sp5C[1])) {
sp8C++;
}
if (cM3d_IsZero(sp5C[2])) {
sp8C++;
}
int sp80, sp84, sp88;
if (sp8C != 1) {
if ((sp5C[0] > 0.0f && (sp5C[1] <= 0.0f) && (sp5C[2] <= 0.0f)) ||
(sp5C[0] < 0.0f && (sp5C[1] >= 0.0f) && (sp5C[2] >= 0.0f)))
{
sp80 = 0;
sp84 = 1;
sp88 = 2;
} else if ((sp5C[1] > 0.0f && (sp5C[0] <= 0.0f) && (sp5C[2] <= 0.0f)) ||
(sp5C[1] < 0.0f && (sp5C[0] >= 0.0f) && (sp5C[2] >= 0.0f)))
{
sp80 = 1;
sp84 = 0;
sp88 = 2;
} else {
sp80 = 2;
sp84 = 0;
sp88 = 1;
}
f32 sp90 = sp5C[sp80] - sp5C[sp84];
f32 sp94 = sp5C[sp80] - sp5C[sp88];
if (!cM3d_IsZero(sp90) && !cM3d_IsZero(sp94)) {
f32 sp98 = -sp5C[sp84] / sp90;
f32 sp9C = -sp5C[sp88] / sp94;
f32 vtx0_x = pm_vtx_tbl[tri_data->vtx0].x;
f32 vtx0_z = pm_vtx_tbl[tri_data->vtx0].z;
f32 vtx1_x = pm_vtx_tbl[tri_data->vtx1].x;
f32 vtx1_z = pm_vtx_tbl[tri_data->vtx1].z;
f32 vtx2_x = pm_vtx_tbl[tri_data->vtx2].x;
f32 vtx2_z = pm_vtx_tbl[tri_data->vtx2].z;
f32 cx0, cy0, cx1, cy1;
if (sp80 == 0) {
cx0 = vtx1_x + sp98 * (vtx0_x - vtx1_x);
cy0 = vtx1_z + sp98 * (vtx0_z - vtx1_z);
cx1 = vtx2_x + sp9C * (vtx0_x - vtx2_x);
cy1 = vtx2_z + sp9C * (vtx0_z - vtx2_z);
} else if (sp80 == 1) {
cx0 = vtx0_x + sp98 * (vtx1_x - vtx0_x);
cy0 = vtx0_z + sp98 * (vtx1_z - vtx0_z);
cx1 = vtx2_x + sp9C * (vtx1_x - vtx2_x);
cy1 = vtx2_z + sp9C * (vtx1_z - vtx2_z);
} else {
cx0 = vtx0_x + sp98 * (vtx2_x - vtx0_x);
cy0 = vtx0_z + sp98 * (vtx2_z - vtx0_z);
cx1 = vtx1_x + sp9C * (vtx2_x - vtx1_x);
cy1 = vtx1_z + sp9C * (vtx2_z - vtx1_z);
}
cx0 += sp50.x;
cy0 += sp50.z;
cx1 += sp50.x;
cy1 += sp50.z;
f32 spC8, spCC, spD0;
bool sp107 = cM3d_Len2dSqPntAndSegLine(
pwi->GetCx(), pwi->GetCz(),
cx0, cy0,
cx1, cy1,
&spCC, &spD0,
&spC8
);
f32 spD4 = spCC - pwi->GetCx();
f32 spD8 = spD0 - pwi->GetCz();
f32 spDC = pwi->GetWallRR(cir_index);
if (!(spC8 > spDC) && !(spD4 * sp50.x + spD8 * sp50.z < 0.0f)) {
if (sp107 == 1) {
positionWallCorrect(pwi, sp6C, tri->m_plane, pwi->GetPos(),
std::sqrtf(spC8));
pwi->CalcMovePosWork();
pwi->SetWallCirHit(cir_index);
pwi->SetWallPolyIndex(cir_index, i_poly_idx);
pwi->SetWallAngleY(
cir_index,
cM_atan2s(tri->m_plane.GetNP()->x, tri->m_plane.GetNP()->z)
);
correct = true;
} else {
cx0 -= sp50.x;
cy0 -= sp50.z;
cx1 -= sp50.x;
cy1 -= sp50.z;
f32 spE0 = cM3d_Len2dSq(cx0, cy0, pwi->GetPos()->x, pwi->GetPos()->z);
f32 spE4 = cM3d_Len2dSq(cx1, cy1, pwi->GetPos()->x, pwi->GetPos()->z);
f32 onx = -tri->m_plane.GetNP()->x;
f32 ony = -tri->m_plane.GetNP()->z;
JUT_ASSERT(463, !(cM3d_IsZero(onx) && cM3d_IsZero(ony)));
if (spE0 < spE4) {
if (!(spE0 > spDC) && !(std::fabsf(spE0 - spDC) < 0.008f)) {
f32 spF0, spF4;
cM2d_CrossCirLin(*pwi->GetWallCirP(cir_index), cx0, cy0,
onx, ony, &spF0, &spF4);
pwi->GetPos()->x += cx0 - spF0;
pwi->GetPos()->z += cy0 - spF4;
CHECK_FLOAT_CLASS(484, pwi->GetPos()->x);
CHECK_FLOAT_CLASS(485, pwi->GetPos()->z);
pwi->CalcMovePosWork();
pwi->SetWallCirHit(cir_index);
pwi->SetWallPolyIndex(cir_index, i_poly_idx);
pwi->SetWallAngleY(
cir_index,
cM_atan2s(tri->m_plane.GetNP()->x, tri->m_plane.GetNP()->z)
);
correct = true;
pwi->SetWallHit();
}
} else if (!(spE4 > spDC) && !(std::fabsf(spE4 - spDC) < 0.008f)) {
f32 spF8, spFC;
cM2d_CrossCirLin(*pwi->GetWallCirP(cir_index), cx1, cy1,
onx, ony, &spF8, &spFC);
pwi->GetPos()->x += cx1 - spF8;
pwi->GetPos()->z += cy1 - spFC;
CHECK_FLOAT_CLASS(524, pwi->GetPos()->x);
CHECK_FLOAT_CLASS(525, pwi->GetPos()->z);
pwi->CalcMovePosWork();
pwi->SetWallCirHit(cir_index);
pwi->SetWallPolyIndex(cir_index, i_poly_idx);
pwi->SetWallAngleY(
cir_index,
cM_atan2s(tri->m_plane.GetNP()->x, tri->m_plane.GetNP()->z)
);
correct = true;
pwi->SetWallHit();
}
}
}
}
}
}
cir_index++;
}
}
if (rwg_elm->next == 0xFFFF) {
break;
}
i_poly_idx = rwg_elm->next;
}
return correct;
}
/* 800A6DF8-800A7004 .text WallCorrectRp__4dBgWFP9dBgS_Acchi */
@@ -80,7 +292,6 @@ bool dBgW::WallCorrectRp(dBgS_Acch* acch, int i) {
/* 800A7004-800A7120 .text WallCorrectGrpRp__4dBgWFP9dBgS_Acchii */
bool dBgW::WallCorrectGrpRp(dBgS_Acch* acch, int grp_id, int depth) {
/* Nonmatching */
if (ChkGrpThrough(grp_id, acch->GetGrpPassChk(), depth))
return false;
@@ -108,8 +319,6 @@ bool dBgW::WallCorrectGrpRp(dBgS_Acch* acch, int grp_id, int depth) {
/* 800A7120-800A72E0 .text RwgRoofChk__4dBgWFUsP12dBgS_RoofChk */
bool dBgW::RwgRoofChk(u16 poly_index, dBgS_RoofChk* chk) {
/* Nonmatching */
bool ret = false;
while (true) {
f32 y;
@@ -134,7 +343,6 @@ bool dBgW::RwgRoofChk(u16 poly_index, dBgS_RoofChk* chk) {
/* 800A72E0-800A7514 .text RoofChkRp__4dBgWFP12dBgS_RoofChki */
bool dBgW::RoofChkRp(dBgS_RoofChk* chk, int i) {
/* Nonmatching */
cBgW_NodeTree* node = &m_nt_tbl[i];
// if (!node->CrossY(chk->GetPosP()) || !node->UnderPlaneYUnder(chk->GetNowY()) || node->TopPlaneYUnder(chk->GetPosP()->y))
if (!node->CrossY(chk->GetPosP()) || !(node->GetMinY() < chk->GetNowY()) || node->TopPlaneYUnder(chk->GetPosP()->y))
@@ -198,8 +406,6 @@ bool dBgW::RoofChkGrpRp(dBgS_RoofChk* chk, int grp_id, int depth) {
/* 800A767C-800A783C .text RwgSplGrpChk__4dBgWFUsP14dBgS_SplGrpChk */
bool dBgW::RwgSplGrpChk(u16 poly_index, dBgS_SplGrpChk* chk) {
/* Nonmatching */
bool ret = false;
while (true) {
f32 y;
@@ -286,36 +492,35 @@ bool dBgW::SplGrpChkGrpRp(dBgS_SplGrpChk* chk, int grp_id, int depth) {
}
/* 800A7BDC-800A7DCC .text RwgSphChk__4dBgWFUsP11dBgS_SphChkPv */
bool dBgW::RwgSphChk(u16 poly_index, dBgS_SphChk* chk, void* user) {
/* Nonmatching */
cM3dGTri gtri;
bool dBgW::RwgSphChk(u16 i_poly_idx, dBgS_SphChk* i_sphchk, void* i_data) {
cM3dGTri tri;
cBgW_RwgElm* rwg;
cBgD_Tri_t* tri_t;
bool ret = false;
bool chk = false;
while (true) {
if (!ChkPolyThrough(poly_index, chk->GetPolyPassChk())) {
cBgW_TriElm* tri_elm;
cBgD_Tri_t* tri;
rwg = &pm_rwg[i_poly_idx];
if (!ChkPolyThrough(i_poly_idx, i_sphchk->GetPolyPassChk())) {
tri_t = &pm_bgd->m_t_tbl[i_poly_idx];
tri.setBg(&pm_vtx_tbl[tri_t->vtx0], &pm_vtx_tbl[tri_t->vtx1],
&pm_vtx_tbl[tri_t->vtx2], &pm_tri[i_poly_idx].m_plane);
tri = &pm_bgd->m_t_tbl[poly_index];
tri_elm = &pm_tri[poly_index];
gtri.setBg(&pm_vtx_tbl[tri->vtx0], &pm_vtx_tbl[tri->vtx1], &pm_vtx_tbl[tri->vtx2], &tri_elm->m_plane);
if (cM3d_Cross_SphTri(chk, &gtri)) {
if (chk->mpCallback != NULL) {
chk->mpCallback(chk, (cBgD_Vtx_t*)pm_vtx_tbl, tri->vtx0, tri->vtx1, tri->vtx2, &pm_tri[poly_index].m_plane, user);
if (i_sphchk->cross(&tri)) {
if (i_sphchk->mpCallback != NULL) {
i_sphchk->mpCallback(i_sphchk, pm_vtx_tbl, tri_t->vtx0, tri_t->vtx1,
tri_t->vtx2, &pm_tri[i_poly_idx].m_plane, i_data);
}
chk->SetPolyIndex(poly_index);
ret = true;
i_sphchk->SetPolyIndex(i_poly_idx);
chk = true;
}
}
if (pm_rwg[poly_index].next == 0xFFFF)
if (rwg->next == 0xFFFF)
break;
poly_index = pm_rwg[poly_index].next;
i_poly_idx = rwg->next;
}
return ret;
return chk;
}
/* 800A7DCC-800A8038 .text SphChkRp__4dBgWFP11dBgS_SphChkPvi */
@@ -396,6 +601,13 @@ bool dBgW::RwgWallCrrPos(u16, dBgS_CrrPos*) {
/* Nonmatching */
}
void dBgW::dummyfunc() {
// TODO: find where this assert actually comes from
// cBgW::RwgShdwDraw ?
int index;
JUT_ASSERT(0, 0 <= index && index < pm_bgd->m_t_num);
}
/* 800A8964-800A8B70 .text WallCrrPosRp__4dBgWFP11dBgS_CrrPosi */
bool dBgW::WallCrrPosRp(dBgS_CrrPos* crr, int i) {
cBgW_NodeTree* node = &m_nt_tbl[i];
@@ -477,7 +689,6 @@ void dBgW::TransPos(cBgS_PolyInfo& poly, void* user, bool accept, cXyz* pos, csX
/* 800A8D2C-800A9474 .text ChkPolyThrough__4dBgWFiP16cBgS_PolyPassChk */
bool dBgW::ChkPolyThrough(int poly_index, cBgS_PolyPassChk* chk) {
/* Nonmatching */
if (chk == NULL)
return false;
if (chk->mbObjThrough && GetPolyInf3(GetPolyInfId(poly_index)) & 0x02)
@@ -499,7 +710,6 @@ bool dBgW::ChkPolyThrough(int poly_index, cBgS_PolyPassChk* chk) {
/* 800A9474-800A9684 .text ChkShdwDrawThrough__4dBgWFiP16cBgS_PolyPassChk */
bool dBgW::ChkShdwDrawThrough(int poly_index, cBgS_PolyPassChk* chk) {
/* Nonmatching */
if ((GetPolyInf0(GetPolyInfId(poly_index)) >> 27) & 1)
return true;
+3 -3
View File
@@ -55,9 +55,9 @@ void dBgWHf::CalcPlane() {
if (isEven) {
for (int x = 0; x < m_gridx; r30++, x++) {
u16 triIdx = mC8[r30];
Vec* vtx0 = &pm_vtx_tbl[tri_tbl[triIdx].vtx0];
Vec* vtx1 = &pm_vtx_tbl[tri_tbl[triIdx].vtx1];
Vec* vtx2 = &pm_vtx_tbl[tri_tbl[triIdx].vtx2];
cBgD_Vtx_t* vtx0 = &pm_vtx_tbl[tri_tbl[triIdx].vtx0];
cBgD_Vtx_t* vtx1 = &pm_vtx_tbl[tri_tbl[triIdx].vtx1];
cBgD_Vtx_t* vtx2 = &pm_vtx_tbl[tri_tbl[triIdx].vtx2];
normal.x = vtx1->y - vtx0->y;
normal.y = mC4;
normal.z = vtx1->y - vtx2->y;
+1 -1
View File
@@ -64,7 +64,7 @@ s32 fopAc_Draw(void* pProc) {
return ret;
}
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) : __fpclassifyd((double)(x)) ) == 1));
#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !(fpclassify(x) == 1));
#define CHECK_VEC3_RANGE(line, v) JUT_ASSERT(line, -1.0e32f < v.x && v.x < 1.0e32f && -1.0e32f < v.y && v.y < 1.0e32f && -1.0e32f < v.z && v.z < 1.0e32f)
/* 8002362C-80023BDC .text fopAc_Execute__FPv */