From b7a607b765eae47b638180cbbd2ea5310bec312b Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Mon, 11 Nov 2024 22:43:03 -0600 Subject: [PATCH] Fix some issues caused by the extended scene geometry enhancement by patching DLs (#830) --- mm/2s2h/BenGui/BenMenuBar.cpp | 12 +++-- mm/2s2h/BenGui/SearchableMenuItems.h | 7 ++- .../GfxPatcher/AuthenticGfxPatches.cpp | 49 +++++++++++++++++++ .../GfxPatcher/AuthenticGfxPatches.h | 1 + 4 files changed, 62 insertions(+), 7 deletions(-) diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index 58b7f6f39..76f5a125f 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -651,11 +651,13 @@ void DrawEnhancementsMenu() { ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(255, 255, 0, 255)); ImGui::SeparatorText("Unstable"); ImGui::PopStyleColor(); - UIWidgets::CVarCheckbox( - "Disable Scene Geometry Distance Check", "gEnhancements.Graphics.DisableSceneGeometryDistanceCheck", - { .tooltip = - "Disables the distance check for scene geometry, allowing it to be drawn no matter how far " - "away it is from the player. This may have unintended side effects." }); + if (UIWidgets::CVarCheckbox( + "Disable Scene Geometry Distance Check", "gEnhancements.Graphics.DisableSceneGeometryDistanceCheck", + { .tooltip = + "Disables the distance check for scene geometry, allowing it to be drawn no matter how far " + "away it is from the player. This may have unintended side effects." })) { + GfxPatcher_ApplyGeometryIssuePatches(); + } UIWidgets::CVarCheckbox("Widescreen Actor Culling", "gEnhancements.Graphics.ActorCullingAccountsForWidescreen", { .tooltip = "Adjusts the culling planes to account for widescreen resolutions. " diff --git a/mm/2s2h/BenGui/SearchableMenuItems.h b/mm/2s2h/BenGui/SearchableMenuItems.h index 10dec9a98..71cbfa14c 100644 --- a/mm/2s2h/BenGui/SearchableMenuItems.h +++ b/mm/2s2h/BenGui/SearchableMenuItems.h @@ -1244,10 +1244,13 @@ void AddEnhancements() { { .widgetName = "Unstable", .widgetType = WIDGET_SEPARATOR_TEXT, .widgetOptions = { .color = UIWidgets::Colors::Yellow } }, - { "Disable Scene Geometry Distance Check", "gEnhancements.Graphics.DisableSceneGeometryDistanceCheck", + { "Disable Scene Geometry Distance Check", + "gEnhancements.Graphics.DisableSceneGeometryDistanceCheck", "Disables the distance check for scene geometry, allowing it to be drawn no matter how far " "away it is from the player. This may have unintended side effects.", - WIDGET_CVAR_CHECKBOX }, + WIDGET_CVAR_CHECKBOX, + {}, + [](widgetInfo& info) { GfxPatcher_ApplyGeometryIssuePatches(); } }, { "Widescreen Actor Culling", "gEnhancements.Graphics.ActorCullingAccountsForWidescreen", "Adjusts the culling planes to account for widescreen resolutions. " "This may have unintended side effects.", diff --git a/mm/2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.cpp b/mm/2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.cpp index eb3d86397..875f8d634 100644 --- a/mm/2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.cpp +++ b/mm/2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.cpp @@ -265,9 +265,58 @@ void PatchMiniGameCrossAndCircleSymbols() { } } +void PatchKnifeChamberRoomGeometry() { + if (CVarGetInteger("gEnhancements.Graphics.DisableSceneGeometryDistanceCheck", 0)) { + ResourceMgr_PatchGfxByName("scenes/nonmq/Z2_YADOYA/Z2_YADOYA_room_00DL_012280", "disableDistanceCheck1", 5, + gsSPNoOp()); + ResourceMgr_PatchGfxByName("scenes/nonmq/Z2_YADOYA/Z2_YADOYA_room_00DL_012280", "disableDistanceCheck2", 6, + gsSPNoOp()); + } else { + ResourceMgr_UnpatchGfxByName("scenes/nonmq/Z2_YADOYA/Z2_YADOYA_room_00DL_012280", "disableDistanceCheck1"); + ResourceMgr_UnpatchGfxByName("scenes/nonmq/Z2_YADOYA/Z2_YADOYA_room_00DL_012280", "disableDistanceCheck2"); + } +} + +void PatchClockTownBuildingGeometry() { + if (CVarGetInteger("gEnhancements.Graphics.DisableSceneGeometryDistanceCheck", 0)) { + ResourceMgr_PatchGfxByName("scenes/nonmq/Z2_00KEIKOKU/Z2_00KEIKOKU_room_00DL_00D490", "disableDistanceCheck1", + 5, gsSPNoOp()); + ResourceMgr_PatchGfxByName("scenes/nonmq/Z2_00KEIKOKU/Z2_00KEIKOKU_room_00DL_00D490", "disableDistanceCheck2", + 6, gsSPNoOp()); + ResourceMgr_PatchGfxByName("scenes/nonmq/Z2_00KEIKOKU/Z2_00KEIKOKU_room_00DL_00CD70", "disableDistanceCheck1", + 5, gsSPNoOp()); + ResourceMgr_PatchGfxByName("scenes/nonmq/Z2_00KEIKOKU/Z2_00KEIKOKU_room_00DL_00CD70", "disableDistanceCheck2", + 6, gsSPNoOp()); + ResourceMgr_PatchGfxByName("scenes/nonmq/Z2_00KEIKOKU/Z2_00KEIKOKU_room_00DL_00D9C8", "disableDistanceCheck1", + 5, gsSPNoOp()); + ResourceMgr_PatchGfxByName("scenes/nonmq/Z2_00KEIKOKU/Z2_00KEIKOKU_room_00DL_00D9C8", "disableDistanceCheck2", + 6, gsSPNoOp()); + } else { + ResourceMgr_UnpatchGfxByName("scenes/nonmq/Z2_00KEIKOKU/Z2_00KEIKOKU_room_00DL_00D490", + "disableDistanceCheck1"); + ResourceMgr_UnpatchGfxByName("scenes/nonmq/Z2_00KEIKOKU/Z2_00KEIKOKU_room_00DL_00D490", + "disableDistanceCheck2"); + ResourceMgr_UnpatchGfxByName("scenes/nonmq/Z2_00KEIKOKU/Z2_00KEIKOKU_room_00DL_00CD70", + "disableDistanceCheck1"); + ResourceMgr_UnpatchGfxByName("scenes/nonmq/Z2_00KEIKOKU/Z2_00KEIKOKU_room_00DL_00CD70", + "disableDistanceCheck2"); + ResourceMgr_UnpatchGfxByName("scenes/nonmq/Z2_00KEIKOKU/Z2_00KEIKOKU_room_00DL_00D9C8", + "disableDistanceCheck1"); + ResourceMgr_UnpatchGfxByName("scenes/nonmq/Z2_00KEIKOKU/Z2_00KEIKOKU_room_00DL_00D9C8", + "disableDistanceCheck2"); + } +} + +void GfxPatcher_ApplyGeometryIssuePatches() { + PatchKnifeChamberRoomGeometry(); + PatchClockTownBuildingGeometry(); +} + // Applies required patches for authentic bugs to allow the game to play and render properly void GfxPatcher_ApplyNecessaryAuthenticPatches() { PatchMiniGameCrossAndCircleSymbols(); GfxPatcher_ApplyOverflowTexturePatches(); + + GfxPatcher_ApplyGeometryIssuePatches(); } diff --git a/mm/2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.h b/mm/2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.h index 68eec242d..a4b30bab9 100644 --- a/mm/2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.h +++ b/mm/2s2h/Enhancements/GfxPatcher/AuthenticGfxPatches.h @@ -3,5 +3,6 @@ void GfxPatcher_ApplyNecessaryAuthenticPatches(); void GfxPatcher_ApplyOverflowTexturePatches(); +void GfxPatcher_ApplyGeometryIssuePatches(); #endif // AUTHENTIC_GFX_PATCHES_H