diff --git a/files.cmake b/files.cmake index 9a8de3244d..cae7f66aed 100644 --- a/files.cmake +++ b/files.cmake @@ -117,6 +117,7 @@ set(DOLZEL_FILES src/d/d_bg_plc.cpp src/d/d_bg_s.cpp src/d/d_bg_s_acch.cpp + src/d/d_bg_s_capt_poly.cpp src/d/d_bg_s_chk.cpp src/d/d_bg_s_gnd_chk.cpp src/d/d_bg_s_grp_pass_chk.cpp diff --git a/include/d/d_bg_s.h b/include/d/d_bg_s.h index 1c47356c80..498dfede91 100644 --- a/include/d/d_bg_s.h +++ b/include/d/d_bg_s.h @@ -67,7 +67,6 @@ u8 dKy_pol_sound_get(cBgS_PolyInfo const* param_0); class dBgS_HIO : public JORReflexible { public: -#if DEBUG enum flags_e { FLAG_ACCH_WALL_OFF_e = 0x2, FLAG_CHECK_COUNTER_e = 0x4, @@ -104,7 +103,7 @@ public: } virtual void genMessage(JORMContext*); - virtual ~dBgS_HIO(); + virtual ~dBgS_HIO() {} bool ChkLineOff() { return m_flags2 & FLAG2_LINE_OFF_e; } bool ChkCheckCounter() { return m_flags & FLAG_CHECK_COUNTER_e; } @@ -134,12 +133,10 @@ public: /* 0x18 */ cXyz m_linecheck_end; /* 0x24 */ cXyz m_gndcheck_pos; /* 0x30 */ s32 m_errorCheck_actor_num; -#endif }; class dBgS_InsideHIO : public JORReflexible { public: -#if DEBUG enum flags_e { FLAG_DISP_POLY_e = 0x1, FLAG_DISP_DP_AREA_e = 0x2, @@ -184,7 +181,6 @@ public: /* 0x08 */ f32 m_raise_amount; /* 0x0C */ cXyz m_p0; /* 0x18 */ cXyz m_p1; -#endif }; class dBgS : public cBgS { @@ -237,9 +233,7 @@ public: void DrawPoly(cBgS_PolyInfo const& param_0, GXColor const& param_1); fopAc_ac_c* GetActorPointer(cBgS_PolyInfo const& param_0) const { return cBgS::GetActorPointer(param_0); } - #if DEBUG void DebugDrawPoly(const dBgW_Base& param_1); - #endif #if DEBUG bool LineCross(cBgS_LinChk* i_linChk); @@ -260,10 +254,8 @@ public: void Draw(); void CaptPoly(dBgS_CaptPoly&); -#if DEBUG /* 0x1404 */ u8 field_0x1404[0x1408 - 0x1404]; /* 0x1408 */ dBgS_HIO m_hio; -#endif }; // Size: 0x1404 bool dBgS_CheckBGroundPoly(cBgS_PolyInfo const&); diff --git a/include/d/d_bg_w.h b/include/d/d_bg_w.h index 5168d5bf8b..580e22d904 100644 --- a/include/d/d_bg_w.h +++ b/include/d/d_bg_w.h @@ -337,11 +337,9 @@ public: virtual bool ChkShdwDrawThrough(int, cBgS_PolyPassChk*); virtual bool ChkGrpThrough(int, cBgS_GrpPassChk*, int); - #if DEBUG void DrawBox() const; void DebugDraw() const; void DrawPoly(const cBgS_PolyInfo&, const GXColor&) const; - #endif void SetCrrFunc(dBgW_CrrFunc func) { m_crr_func = func; } void SetRideCallback(dBgW_RideCallback func) { m_ride_callback = func; } diff --git a/include/d/d_bg_w_base.h b/include/d/d_bg_w_base.h index 3ce65c5f83..6940df06fa 100644 --- a/include/d/d_bg_w_base.h +++ b/include/d/d_bg_w_base.h @@ -105,11 +105,9 @@ public: virtual void CallRideCallBack(fopAc_ac_c*, fopAc_ac_c*); virtual void CallArrowStickCallBack(fopAc_ac_c*, fopAc_ac_c*, cXyz&); - #if DEBUG virtual void DebugDraw() const {} virtual void DrawPoly(cBgS_PolyInfo const& param_0, GXColor const& param_1) const {} virtual void DrawBox() const {} - #endif PushPull_CallBack GetPushPullCallback() const { return m_pushPull_Callback; } s16 GetDiffShapeAngleY() { return m_diff_ShapeAngleY; } diff --git a/src/d/d_bg_s.cpp b/src/d/d_bg_s.cpp index 15019e330d..00a450edf5 100644 --- a/src/d/d_bg_s.cpp +++ b/src/d/d_bg_s.cpp @@ -12,10 +12,10 @@ #include "f_op/f_op_actor_mng.h" #include "dusk/offset_ptr.h" -#if DEBUG #include "d/d_debug_viewer.h" #include "d/d_bg_s_capt_poly.h" -#endif + +#include "dusk/imgui/ImGuiConsole.hpp" #if DEBUG int g_ground_counter; @@ -28,8 +28,9 @@ int g_sph_counter; int g_capt_poly_counter; #endif -#if DEBUG + void dBgS_HIO::genMessage(JORMContext* mctx) { +#if DEBUG mctx->genLabel("zelda地形チェック", 0); mctx->genLabel("チェック回数 ----------", 0); @@ -83,11 +84,13 @@ void dBgS_HIO::genMessage(JORMContext* mctx) { mctx->genCheckBox("作業2", &m_flags, 0x40); mctx->genCheckBox("作業3", &m_flags, 0x80); mctx->genCheckBox("作業4", &m_flags, 0x100); +#endif } dBgS_InsideHIO::~dBgS_InsideHIO() {} void dBgS_InsideHIO::genMessage(JORMContext* mctx) { +#if DEBUG mctx->genLabel("デバッグポリゴン描画 -----", 0); mctx->genCheckBox("デバッグポリゴン描画", &m_flags, FLAG_DISP_POLY_e); @@ -117,8 +120,8 @@ void dBgS_InsideHIO::genMessage(JORMContext* mctx) { mctx->genLabel("-----", 0); mctx->genCheckBox("Obj床 プレイヤー下", &m_flags, FLAG_GNDCHK_PLAYER_UNDER_e); -} #endif +} void cBgS_ChkElm::Init() { m_bgw_base_ptr = NULL; @@ -456,9 +459,9 @@ static OSStopwatch s_spl_sw; static OSStopwatch s_shdw_sw; static OSStopwatch s_sph_chk_sw; static OSStopwatch s_capt_poly_sw; +#endif static dBgS_InsideHIO s_InsideHio; -#endif void dBgS::Ct() { cBgS::Ct(); @@ -541,7 +544,6 @@ void dBgS::Move() { #endif } -#if DEBUG void dBgS_AabDraw(cM3dGAab& aab, GXColor& color) { cXyz points[8]; @@ -643,12 +645,16 @@ static int poly_draw(dBgS_CaptPoly* capt, cBgD_Vtx_t* vtxList, int v0, int v1, i return 0; } -#endif void dBgS::Draw() { - #if DEBUG cBgS::Draw(); + if (dusk::g_imguiConsole.isCollisionView()) { + s_InsideHio.m_flags |= dBgS_InsideHIO::FLAG_DISP_POLY_e; + } else { + s_InsideHio.m_flags &= ~dBgS_InsideHIO::FLAG_DISP_POLY_e; + } + if (s_InsideHio.ChkDispPoly()) { cM3dGAab aab; if (s_InsideHio.ChkPlayerAround()) { @@ -696,6 +702,7 @@ void dBgS::Draw() { CaptPoly(capt); } + #if DEBUG if (m_hio.ChkCheckCounter()) { OSReport("ラインチェック %d回\n", g_line_counter); g_line_counter = 0; @@ -721,17 +728,18 @@ void dBgS::Draw() { OSReport("ポリゴンキャプチャ %d\n", g_capt_poly_counter); g_capt_poly_counter = 0; } + #endif if (m_hio.ChkObjLineCheck()) { dBgS_LinChk linechk; linechk.Set(&m_hio.m_linecheck_start, &m_hio.m_linecheck_end, NULL); - dDbVw_drawLineOpa(m_hio.m_linecheck_start, m_hio.m_linecheck_end, (GXColor){0xFF, 0xFF, 0xFF, 0xFF}, TRUE, 12); - dDbVw_drawSphereOpa(m_hio.m_linecheck_start, 10.0f, (GXColor){0xFF, 0, 0, 0xFF}, TRUE); - dDbVw_drawSphereOpa(m_hio.m_linecheck_end, 10.0f, (GXColor){0, 0, 0xFF, 0xFF}, TRUE); + dDbVw_drawLineOpa(m_hio.m_linecheck_start, m_hio.m_linecheck_end, COMPOUND_LITERAL(GXColor){0xFF, 0xFF, 0xFF, 0xFF}, TRUE, 12); + dDbVw_drawSphereOpa(m_hio.m_linecheck_start, 10.0f, COMPOUND_LITERAL(GXColor){0xFF, 0, 0, 0xFF}, TRUE); + dDbVw_drawSphereOpa(m_hio.m_linecheck_end, 10.0f, COMPOUND_LITERAL(GXColor){0, 0, 0xFF, 0xFF}, TRUE); if (LineCross(&linechk)) { - dDbVw_drawSphereOpa(*linechk.GetCrossP(), 10.0f, (GXColor){0, 0xFF, 0, 0xFF}, TRUE); + dDbVw_drawSphereOpa(*linechk.GetCrossP(), 10.0f, COMPOUND_LITERAL(GXColor){0, 0xFF, 0, 0xFF}, TRUE); } } @@ -754,20 +762,18 @@ void dBgS::Draw() { sp3C = sp54; sp3C.y = var_f30; - dDbVw_drawLineOpa(sp54, sp3C, (GXColor){0, 0xFF, 0, 0xFF}, TRUE, 12); - dDbVw_drawPointOpa(sp3C, (GXColor){0xFF, 0, 0, 0xFF}, TRUE, 12); + dDbVw_drawLineOpa(sp54, sp3C, COMPOUND_LITERAL(GXColor){0, 0xFF, 0, 0xFF}, TRUE, 12); + dDbVw_drawPointOpa(sp3C, COMPOUND_LITERAL(GXColor){0xFF, 0, 0, 0xFF}, TRUE, 12); if (var_f30 != G_CM3D_F_INF) { - DrawPoly(gndchk, (GXColor){0xFF, 0xFF, 0, 0xFF}); + DrawPoly(gndchk, COMPOUND_LITERAL(GXColor){0xFF, 0xFF, 0, 0xFF}); } } - - #endif } -#if DEBUG void dBgS::CaptPoly(dBgS_CaptPoly& capt) { if (!m_hio.ChkCaptPolyOff()) { + #if DEBUG if (m_hio.ChkCheckCounter()) { g_capt_poly_counter++; } @@ -775,6 +781,7 @@ void dBgS::CaptPoly(dBgS_CaptPoly& capt) { if (m_hio.ChkCaptPolyTimer()) { OSStartStopwatch(&s_capt_poly_sw); } + #endif cBgS_ChkElm* elm = m_chk_element; for (int i = 0; i < 0x100; i++) { @@ -784,10 +791,12 @@ void dBgS::CaptPoly(dBgS_CaptPoly& capt) { elm++; } + #if DEBUG if (m_hio.ChkCaptPolyTimer()) { OSStopStopwatch(&s_capt_poly_sw); OSDumpStopwatch(&s_capt_poly_sw); } + #endif } } @@ -798,7 +807,6 @@ void dBgS::ChkDeleteActorRegist(fopAc_ac_c* actor) { } } } -#endif bool dBgS::Regist(dBgW_Base* pbgw, fopAc_ac_c* pactor) { if (pbgw == NULL) { @@ -1533,7 +1541,6 @@ fopAc_ac_c* dBgS::PushPullCallBack(const cBgS_PolyInfo& param_0, fopAc_ac_c* i_p return callback(bg_actor, i_pushActor, i_angle, i_label); } -#if DEBUG void dBgS::DebugDrawPoly(const dBgW_Base& param_1) { if (m_hio.ChkShapeDisp()) { param_1.DebugDraw(); @@ -1546,7 +1553,6 @@ void dBgS::DrawPoly(const cBgS_PolyInfo& polyInfo, GXColor const& color) { pdBgw->DrawPoly(polyInfo, color); } } -#endif bool dBgS_CheckBWallPoly(const cBgS_PolyInfo& polyinfo) { cM3dGPla pla; diff --git a/src/d/d_bg_w.cpp b/src/d/d_bg_w.cpp index 3b6dd57111..b5d342d3f8 100644 --- a/src/d/d_bg_w.cpp +++ b/src/d/d_bg_w.cpp @@ -14,9 +14,7 @@ #include "d/d_com_inf_game.h" #include "d/actor/d_a_horse.h" -#if DEBUG #include "d/d_debug_viewer.h" -#endif #if DEBUG static void ASSERT_SOLDHEAP() { @@ -1115,7 +1113,6 @@ bool cBgW::ChkMoveBg() const { return mFlags & MOVE_BG_e; } -#if DEBUG void dBgW::DrawBox() const { cXyz min; cXyz max; @@ -1156,7 +1153,7 @@ void dBgW::DrawBox() const { points[7].y = min.y; points[7].z = max.z; - dDbVw_drawCube8pXlu(points, (GXColor){0, 0xFF, 0, 0x64}); + dDbVw_drawCube8pXlu(points, COMPOUND_LITERAL(GXColor){0, 0xFF, 0, 0x64}); } void dBgW::DebugDraw() const { @@ -1218,7 +1215,6 @@ void dBgW::DrawPoly(const cBgS_PolyInfo& polyinfo, const GXColor& color) const { dDbVw_drawTriangleXlu(points, color, TRUE); } -#endif dBgW::dBgW() { m_crr_func = NULL; diff --git a/src/d/d_bg_w_kcol.cpp b/src/d/d_bg_w_kcol.cpp index f3cb095271..66cef40332 100644 --- a/src/d/d_bg_w_kcol.cpp +++ b/src/d/d_bg_w_kcol.cpp @@ -937,8 +937,8 @@ void dBgWKCol::CaptPoly(dBgS_CaptPoly& i_captpoly) { int sp34; int sp30; if (sp4C < sp48) { - u16* sp2C = NULL; - u16* sp28 = NULL; + BE(u16)* sp2C = NULL; + BE(u16)* sp28 = NULL; int sp24 = sp4C; do { @@ -951,21 +951,21 @@ void dBgWKCol::CaptPoly(dBgS_CaptPoly& i_captpoly) { int sp1C = sp5C; do { - u16* sp18 = (u16*)m_pkc_head->m_block_data; + BE(u16)* sp18 = (BE(u16)*)m_pkc_head->m_block_data; int r29 = m_pkc_head->m_block_width_shift; int sp14 = 4 * (((u32)sp24 >> r29) << m_pkc_head->m_area_xy_blocks_shift | ((u32)sp20 >> r29) << m_pkc_head->m_area_x_blocks_shift | (u32)sp1C >> r29); - while ((sp14 = (*(int*)((intptr_t)sp18 + sp14))) >= 0) { - sp18 = (u16*)((intptr_t)sp18 + sp14); + while ((sp14 = (*(BE(u32)*)((intptr_t)sp18 + sp14))) >= 0) { + sp18 = (BE(u16)*)((intptr_t)sp18 + sp14); r29--; sp14 = (((u32)sp24 >> r29 & 1) << 2 | ((u32)sp20 >> r29 & 1) << 1 | ((u32)sp1C >> r29 & 1) << 0) << 2; } - u16* r28 = (u16*)((intptr_t)sp18 + (sp14 & 0x7FFFFFFF)); + BE(u16)* r28 = (BE(u16)*)((intptr_t)sp18 + (sp14 & 0x7FFFFFFF)); r29 = 1 << r29; int sp10 = r29 - 1; diff --git a/src/d/d_s_play.cpp b/src/d/d_s_play.cpp index 0e1b0e4693..3ef8ea7eb2 100644 --- a/src/d/d_s_play.cpp +++ b/src/d/d_s_play.cpp @@ -669,8 +669,9 @@ static int dScnPly_Draw(dScnPly_c* i_this) { #endif dComIfG_Ccsp()->Draw(); - #if DEBUG dComIfG_Bgsp().Draw(); + + #if DEBUG dPath_Draw(); #endif diff --git a/src/dusk/imgui/ImGuiConsole.hpp b/src/dusk/imgui/ImGuiConsole.hpp index bfc7c4043d..bc44f2ed1b 100644 --- a/src/dusk/imgui/ImGuiConsole.hpp +++ b/src/dusk/imgui/ImGuiConsole.hpp @@ -13,7 +13,9 @@ namespace dusk { public: ImGuiConsole(); void draw(); + bool isBloomEnabled() { return m_menuGame.isBloomEnabled(); } + bool isCollisionView() { return m_menuTools.isCollisionView(); } static bool CheckMenuViewToggle(ImGuiKey key, bool& active); diff --git a/src/dusk/imgui/ImGuiMenuTools.cpp b/src/dusk/imgui/ImGuiMenuTools.cpp index 9df65e1c2c..691900f1b3 100644 --- a/src/dusk/imgui/ImGuiMenuTools.cpp +++ b/src/dusk/imgui/ImGuiMenuTools.cpp @@ -6,6 +6,7 @@ #include "ImGuiMenuTools.hpp" #include "m_Do/m_Do_main.h" +#include "d/d_com_inf_game.h" namespace dusk { ImGuiMenuTools::ImGuiMenuTools() {} @@ -17,6 +18,7 @@ namespace dusk { if (ImGui::Checkbox("Development Mode", &m_isDevelopmentMode)) { isToggleDevelopmentMode = true; } + ImGui::Checkbox("Enable Collision View", &m_enableCollisionView); ImGui::Separator(); ImGui::MenuItem("Process Management", "F2", &m_showProcessManagement); diff --git a/src/dusk/imgui/ImGuiMenuTools.hpp b/src/dusk/imgui/ImGuiMenuTools.hpp index 885c948f82..800b7e506e 100644 --- a/src/dusk/imgui/ImGuiMenuTools.hpp +++ b/src/dusk/imgui/ImGuiMenuTools.hpp @@ -19,6 +19,8 @@ namespace dusk { void ShowStubLog(); void ShowMapLoader(); + bool isCollisionView() { return m_enableCollisionView; } + private: bool m_showDebugOverlay = false; int m_debugOverlayCorner = 0; // top-left @@ -46,6 +48,8 @@ namespace dusk { } m_mapLoaderInfo; bool m_isDevelopmentMode = false; + + bool m_enableCollisionView = false; }; } diff --git a/src/m_Do/m_Do_graphic.cpp b/src/m_Do/m_Do_graphic.cpp index 2a8c9847d4..58345ef864 100644 --- a/src/m_Do/m_Do_graphic.cpp +++ b/src/m_Do/m_Do_graphic.cpp @@ -707,9 +707,7 @@ void mDoGph_BlankingOFF() {} static void dScnPly_BeforeOfPaint() { dComIfGd_reset(); - #if DEBUG dDbVw_deleteDrawPacketList(); - #endif } int mDoGph_BeforeOfDraw() {