From cefd7e59a153d088891c0a6db532ed40dddbe579 Mon Sep 17 00:00:00 2001 From: TakaRikka Date: Wed, 18 Mar 2026 01:25:42 -0700 Subject: [PATCH] add cc collider view (broken color) --- extern/aurora | 2 +- include/SSystem/SComponent/c_cc_s.h | 2 -- include/d/d_cc_d.h | 8 ------- src/SSystem/SComponent/c_cc_s.cpp | 2 -- src/d/d_bg_s.cpp | 30 ++++++++++++++++++++----- src/d/d_cc_d.cpp | 18 --------------- src/d/d_cc_s.cpp | 35 ++++++++++++++++++++++++++--- src/dusk/imgui/ImGuiConsole.hpp | 2 +- src/dusk/imgui/ImGuiMenuTools.cpp | 16 ++++++++++++- src/dusk/imgui/ImGuiMenuTools.hpp | 15 +++++++++++-- src/dusk/stubs.cpp | 3 --- 11 files changed, 87 insertions(+), 46 deletions(-) diff --git a/extern/aurora b/extern/aurora index 8cbbba0179..156f9a65e3 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit 8cbbba0179335474a31704acf75071c1788748d5 +Subproject commit 156f9a65e38db18a8fc93b30271703e58fa339f5 diff --git a/include/SSystem/SComponent/c_cc_s.h b/include/SSystem/SComponent/c_cc_s.h index 4bdf70efd5..62815fb3b6 100644 --- a/include/SSystem/SComponent/c_cc_s.h +++ b/include/SSystem/SComponent/c_cc_s.h @@ -22,12 +22,10 @@ public: /* 0x2802 */ u16 mObjTgCount; /* 0x2804 */ u16 mObjCoCount; /* 0x2806 */ u16 mObjCount; -#if DEBUG /* 0x280C */ u16 field_0x280c; /* 0x280E */ u16 field_0x280e; /* 0x2810 */ u16 field_0x2810; /* 0x2812 */ u16 field_0x2812; -#endif /* 0x2808 */ cCcD_DivideArea mDivideArea; /* 0x2848 vtable */ diff --git a/include/d/d_cc_d.h b/include/d/d_cc_d.h index 1d9b4b5a93..19f0430498 100644 --- a/include/d/d_cc_d.h +++ b/include/d/d_cc_d.h @@ -451,9 +451,7 @@ public: void CalcTgVec(); virtual ~dCcD_Cps() {} dCcD_Cps() {} - #if DEBUG virtual void Draw(const GXColor& color); - #endif }; // Size = 0x144 // Triangle @@ -463,9 +461,7 @@ public: cCcD_ShapeAttr* GetShapeAttr(); virtual ~dCcD_Tri() {} dCcD_Tri() {} - #if DEBUG virtual void Draw(const GXColor& color); - #endif }; // Cylinder @@ -478,9 +474,7 @@ public: void MoveCTg(cXyz&); virtual ~dCcD_Cyl() {} dCcD_Cyl() {} - #if DEBUG virtual void Draw(const GXColor& color); - #endif }; // Size = 0x13C // Sphere @@ -492,9 +486,7 @@ public: void MoveCAt(cXyz&); virtual cCcD_ShapeAttr* GetShapeAttr(); virtual ~dCcD_Sph() {} - #if DEBUG virtual void Draw(const GXColor& color); - #endif }; // Size = 0x138 dCcD_GObjInf* dCcD_GetGObjInf(cCcD_Obj* param_0); diff --git a/src/SSystem/SComponent/c_cc_s.cpp b/src/SSystem/SComponent/c_cc_s.cpp index 7660064cef..73b6993255 100644 --- a/src/SSystem/SComponent/c_cc_s.cpp +++ b/src/SSystem/SComponent/c_cc_s.cpp @@ -472,12 +472,10 @@ void cCcS::Move() { ChkCo(); MoveAfterCheck(); - #if DEBUG field_0x280c = mObjAtCount; field_0x280e = mObjTgCount; field_0x2810 = mObjCoCount; field_0x2812 = mObjCount; - #endif mObjAtCount = 0; mObjTgCount = 0; diff --git a/src/d/d_bg_s.cpp b/src/d/d_bg_s.cpp index 00a450edf5..f218424d30 100644 --- a/src/d/d_bg_s.cpp +++ b/src/d/d_bg_s.cpp @@ -618,6 +618,14 @@ static int poly_draw(dBgS_CaptPoly* capt, cBgD_Vtx_t* vtxList, int v0, int v1, i GXColor roof_color = {0, 0, 0xFF, 0xFF}; GXColor wall_color = {0, 0xFF, 0, 0xFF}; +#if TARGET_PC + dusk::ImGuiMenuTools::CollisionViewSettings collisionViewSettings = dusk::g_imguiConsole.getCollisionViewSettings(); + f32 view_opacity = 255 * (collisionViewSettings.m_terrainViewOpacity / 100.0f); + ground_color.a = view_opacity; + roof_color.a = view_opacity; + wall_color.a = view_opacity; +#endif + cXyz raise; PSVECScale(&plane->mNormal, &raise, s_InsideHio.m_raise_amount); @@ -649,11 +657,18 @@ static int poly_draw(dBgS_CaptPoly* capt, cBgD_Vtx_t* vtxList, int v0, int v1, i void dBgS::Draw() { 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 TARGET_PC + #define IMGUI_TOGGLE_HIO_FLAG(status, flag) \ + if (status) { \ + s_InsideHio.m_flags |= flag; \ + } else { \ + s_InsideHio.m_flags &= ~flag; \ + } + + dusk::ImGuiMenuTools::CollisionViewSettings collisionViewSettings = dusk::g_imguiConsole.getCollisionViewSettings(); + IMGUI_TOGGLE_HIO_FLAG(collisionViewSettings.m_enableTerrainView, dBgS_InsideHIO::FLAG_DISP_POLY_e); + IMGUI_TOGGLE_HIO_FLAG(collisionViewSettings.m_enableWireframe, dBgS_InsideHIO::FLAG_WHITE_WIRE_e); +#endif if (s_InsideHio.ChkDispPoly()) { cM3dGAab aab; @@ -664,6 +679,11 @@ void dBgS::Draw() { f32 var_f31 = fabsf(s_InsideHio.m_p0.x); +#if TARGET_PC + dusk::ImGuiMenuTools::CollisionViewSettings collisionViewSettings = dusk::g_imguiConsole.getCollisionViewSettings(); + var_f31 = collisionViewSettings.m_drawRange; +#endif + min.x = player->current.pos.x - var_f31; min.y = player->current.pos.y - var_f31; min.z = player->current.pos.z - var_f31; diff --git a/src/d/d_cc_d.cpp b/src/d/d_cc_d.cpp index 1c30502d03..6cc5ab63e3 100644 --- a/src/d/d_cc_d.cpp +++ b/src/d/d_cc_d.cpp @@ -4,9 +4,7 @@ #include "f_op/f_op_actor_mng.h" #include "f_pc/f_pc_searcher.h" -#if DEBUG #include "d/d_debug_viewer.h" -#endif void dCcD_GAtTgCoCommonBase::ClrActorInfo() { mApid = -1; @@ -354,8 +352,6 @@ void dCcD_Cps::CalcTgVec() { CalcVec(dest); } -#if DEBUG - void dCcD_Cps::Draw(const GXColor& color) { Mtx auStack_68; Mtx auStack_98; @@ -379,8 +375,6 @@ void dCcD_Cps::Draw(const GXColor& color) { dDbVw_drawSphereXlu(*GetEndP(), GetR(), color, 1); } -#endif - void dCcD_Tri::Set(dCcD_SrcTri const& src) { dCcD_GObjInf::Set(src.mObjInf); cCcD_TriAttr* attr = this; @@ -390,8 +384,6 @@ cCcD_ShapeAttr* dCcD_Tri::GetShapeAttr() { return this; } -#if DEBUG - void dCcD_Tri::Draw(const GXColor& color) { cXyz cStack_34[3]; cStack_34[0] = mA; @@ -400,8 +392,6 @@ void dCcD_Tri::Draw(const GXColor& color) { dDbVw_drawTriangleXlu(cStack_34, color, 1); } -#endif - void dCcD_Cyl::Set(dCcD_SrcCyl const& src) { dCcD_GObjInf::Set(src.mObjInf); cCcD_CylAttr::Set(src.mCylAttr); @@ -433,14 +423,10 @@ void dCcD_Cyl::MoveCTg(cXyz& pos) { SetC(pos); } -#if DEBUG - void dCcD_Cyl::Draw(const GXColor& color) { dDbVw_drawCylinderXlu(*GetCP(), GetR(), GetH(), color, 1); } -#endif - void dCcD_Sph::Set(dCcD_SrcSph const& src) { dCcD_GObjInf::Set(src.mObjInf); cCcD_SphAttr::Set(src.mSphAttr); @@ -464,10 +450,6 @@ cCcD_ShapeAttr* dCcD_Sph::GetShapeAttr() { return this; } -#if DEBUG - void dCcD_Sph::Draw(const GXColor& color) { dDbVw_drawSphereXlu(*GetCP(), GetR(), color, 1); } - -#endif diff --git a/src/d/d_cc_s.cpp b/src/d/d_cc_s.cpp index de9fa587ed..ab71f08aaa 100644 --- a/src/d/d_cc_s.cpp +++ b/src/d/d_cc_s.cpp @@ -10,6 +10,8 @@ #include "d/d_jnt_col.h" #include "f_op/f_op_actor_mng.h" +#include "dusk/imgui/ImGuiConsole.hpp" + class dCcS_HIO : public JORReflexible { public: enum flags_e { @@ -55,10 +57,11 @@ public: /* 0x8 */ s16 m_shield_range; }; -#if DEBUG + dCcS_HIO::~dCcS_HIO() {} void dCcS_HIO::genMessage(JORMContext* mctx) { +#if DEBUG mctx->genLabel("処理関係 -----", 0); mctx->genCheckBox("処理Off", &m_flags, 0x40); mctx->genCheckBox("多数ヒットチェック(草木花)Off", &m_flags, 0x80); @@ -79,16 +82,18 @@ void dCcS_HIO::genMessage(JORMContext* mctx) { mctx->genLabel("特殊-----", 0); mctx->genSlider("盾範囲(max=360度)", &m_shield_range, 0, 0x7FFF); +#endif } +#if DEBUG static OSStopwatch s_move_timer; static OSStopwatch s_mass_timer; -static dCcS_HIO s_Hio; - int g_mass_counter; #endif +static dCcS_HIO s_Hio; + void dCcS::Ct() { cCcS::Ct(); @@ -762,6 +767,23 @@ void dCcS::Draw() { OS_REPORT("Mass Counter %d\n", g_mass_counter); g_mass_counter = 0; } + #endif + +#if TARGET_PC +#define IMGUI_TOGGLE_HIO_FLAG(status, flag) \ + if (status) { \ + s_Hio.m_flags |= flag; \ + } else { \ + s_Hio.m_flags &= ~flag; \ + } + + dusk::ImGuiMenuTools::CollisionViewSettings collisionViewSettings = dusk::g_imguiConsole.getCollisionViewSettings(); + IMGUI_TOGGLE_HIO_FLAG(collisionViewSettings.m_enableAtView, dCcS_HIO::FLAG_AT_ON_e); + IMGUI_TOGGLE_HIO_FLAG(collisionViewSettings.m_enableTgView, dCcS_HIO::FLAG_TG_ON_e); + IMGUI_TOGGLE_HIO_FLAG(collisionViewSettings.m_enableCoView, dCcS_HIO::FLAG_CO_ON_e); + + f32 view_opacity = 255 * (collisionViewSettings.m_colliderViewOpacity / 100.0f); +#endif if (s_Hio.CheckAtOn()) { for (int i = 0; i < field_0x280c; i++) { @@ -769,9 +791,11 @@ void dCcS::Draw() { dCcD_GObjInf* gobj = (dCcD_GObjInf*)mpObjAt[i]->GetGObjInf(); if (gobj->ChkAtHit()) { GXColor color = {0xFF, 0, 0, 0xB4}; + color.a = view_opacity; mpObjAt[i]->Draw(color); } else { GXColor color = {0xFF, 0, 0, 0x50}; + color.a = view_opacity; mpObjAt[i]->Draw(color); } } @@ -784,9 +808,11 @@ void dCcS::Draw() { dCcD_GObjInf* gobj = (dCcD_GObjInf*)mpObjTg[i]->GetGObjInf(); if (gobj->ChkTgHit()) { GXColor color = {0, 0xFF, 0, 0xB4}; + color.a = view_opacity; mpObjTg[i]->Draw(color); } else { GXColor color = {0, 0xFF, 0, 0x50}; + color.a = view_opacity; mpObjTg[i]->Draw(color); } } @@ -799,9 +825,11 @@ void dCcS::Draw() { dCcD_GObjInf* gobj = (dCcD_GObjInf*)mpObjCo[i]->GetGObjInf(); if (gobj->ChkCoHit()) { GXColor color = {0xFF, 0xFF, 0xFF, 0xB4}; + color.a = view_opacity; mpObjCo[i]->Draw(color); } else { GXColor color = {0xFF, 0xFF, 0xFF, 0x50}; + color.a = view_opacity; mpObjCo[i]->Draw(color); } } @@ -820,6 +848,7 @@ void dCcS::Draw() { } } + #if DEBUG if (s_Hio.ChkCounter()) { OS_REPORT("At:%d,Tg:%d,Co:%d\n", field_0x280c, field_0x280e, field_0x2810); } diff --git a/src/dusk/imgui/ImGuiConsole.hpp b/src/dusk/imgui/ImGuiConsole.hpp index bc44f2ed1b..47fa435626 100644 --- a/src/dusk/imgui/ImGuiConsole.hpp +++ b/src/dusk/imgui/ImGuiConsole.hpp @@ -15,7 +15,7 @@ namespace dusk { void draw(); bool isBloomEnabled() { return m_menuGame.isBloomEnabled(); } - bool isCollisionView() { return m_menuTools.isCollisionView(); } + ImGuiMenuTools::CollisionViewSettings& getCollisionViewSettings() { return m_menuTools.getCollisionViewSettings(); } static bool CheckMenuViewToggle(ImGuiKey key, bool& active); diff --git a/src/dusk/imgui/ImGuiMenuTools.cpp b/src/dusk/imgui/ImGuiMenuTools.cpp index 691900f1b3..cf4a7b3858 100644 --- a/src/dusk/imgui/ImGuiMenuTools.cpp +++ b/src/dusk/imgui/ImGuiMenuTools.cpp @@ -18,9 +18,23 @@ namespace dusk { if (ImGui::Checkbox("Development Mode", &m_isDevelopmentMode)) { isToggleDevelopmentMode = true; } - ImGui::Checkbox("Enable Collision View", &m_enableCollisionView); + ImGui::Separator(); + if (ImGui::BeginMenu("Collision View")) { + ImGui::Checkbox("Enable Terrain view", &m_collisionViewSettings.m_enableTerrainView); + // can't use wireframe atm because aurora doesn't support GX_LINES + //ImGui::Checkbox("Enable wireframe view", &m_collisionViewSettings.m_enableWireframe); + ImGui::SliderFloat("Opacity##terrain", &m_collisionViewSettings.m_terrainViewOpacity, 0.0f, 100.0f); + ImGui::SliderFloat("Draw Range", &m_collisionViewSettings.m_drawRange, 0.0f, 1000.0f); + ImGui::Separator(); + ImGui::Checkbox("Enable Attack Collider view", &m_collisionViewSettings.m_enableAtView); + ImGui::Checkbox("Enable Target Collider view", &m_collisionViewSettings.m_enableTgView); + ImGui::Checkbox("Enable Push Collider view", &m_collisionViewSettings.m_enableCoView); + ImGui::SliderFloat("Opacity##colliders", &m_collisionViewSettings.m_colliderViewOpacity, 0.0f, 100.0f); + ImGui::EndMenu(); + } + ImGui::MenuItem("Process Management", "F2", &m_showProcessManagement); ImGui::MenuItem("Debug Overlay", "F3", &m_showDebugOverlay); ImGui::MenuItem("Heap Viewer", "F4", &m_showHeapOverlay); diff --git a/src/dusk/imgui/ImGuiMenuTools.hpp b/src/dusk/imgui/ImGuiMenuTools.hpp index 800b7e506e..8cedfd5657 100644 --- a/src/dusk/imgui/ImGuiMenuTools.hpp +++ b/src/dusk/imgui/ImGuiMenuTools.hpp @@ -9,6 +9,17 @@ namespace dusk { class ImGuiMenuTools { public: + struct CollisionViewSettings { + bool m_enableTerrainView = false; + bool m_enableWireframe = false; + bool m_enableAtView = false; + bool m_enableTgView = false; + bool m_enableCoView = false; + float m_terrainViewOpacity = 50.0f; + float m_colliderViewOpacity = 50.0f; + float m_drawRange = 100.0f; + }; + ImGuiMenuTools(); void draw(); @@ -19,7 +30,7 @@ namespace dusk { void ShowStubLog(); void ShowMapLoader(); - bool isCollisionView() { return m_enableCollisionView; } + CollisionViewSettings& getCollisionViewSettings() { return m_collisionViewSettings; } private: bool m_showDebugOverlay = false; @@ -49,7 +60,7 @@ namespace dusk { bool m_isDevelopmentMode = false; - bool m_enableCollisionView = false; + CollisionViewSettings m_collisionViewSettings; }; } diff --git a/src/dusk/stubs.cpp b/src/dusk/stubs.cpp index 03573dfeef..73f4e93d80 100644 --- a/src/dusk/stubs.cpp +++ b/src/dusk/stubs.cpp @@ -1041,9 +1041,6 @@ GXDrawSyncCallback GXSetDrawSyncCallback(GXDrawSyncCallback cb) { STUB_LOG(); return cb; } -void GXDrawCylinder(u8 numEdges) { - STUB_LOG(); -} void GXWaitDrawDone(void) { STUB_LOG(); }