From 783b626209c8135c91b0fa24e03749b6f7029424 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Wed, 16 Oct 2024 15:32:08 -0600 Subject: [PATCH] Added a toggle to disable interpolation --- src/engine/fox_bg.c | 7 +++++++ src/engine/fox_edisplay.c | 8 ++++++-- src/overlays/ovl_menu/fox_i_menu.c | 3 +++ src/overlays/ovl_menu/fox_map.c | 1 + src/port/interpolation/FrameInterpolation.cpp | 3 ++- src/port/ui/ImguiUI.cpp | 4 ++++ 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/engine/fox_bg.c b/src/engine/fox_bg.c index f9b79979..3371c7ef 100644 --- a/src/engine/fox_bg.c +++ b/src/engine/fox_bg.c @@ -213,6 +213,9 @@ void Background_DrawStarfield(void) { zCos = __cosf(gStarfieldRoll); zSin = __sinf(gStarfieldRoll); + if(CVarGetInteger("gDisableStarsInterpolation", 0) == 1){ + FrameInterpolation_ShouldInterpolateFrame(false); + } for (i = 0; i < starCount; i++, yStar++, xStar++, color++) { // Adjust star positions with field offsets @@ -273,6 +276,10 @@ void Background_DrawStarfield(void) { FrameInterpolation_RecordCloseChild(); } } + + if(CVarGetInteger("gDisableStarsInterpolation", 0) == 1){ + FrameInterpolation_ShouldInterpolateFrame(true); + } } // Restore original perspective after drawing stars diff --git a/src/engine/fox_edisplay.c b/src/engine/fox_edisplay.c index 0c044598..5fe2ef43 100644 --- a/src/engine/fox_edisplay.c +++ b/src/engine/fox_edisplay.c @@ -827,6 +827,7 @@ void ItemCheckpoint_Draw(ItemCheckpoint* this) { s32 i; if (((gGameFrameCount & 0x18) != 0) && (this->state == 0)) { + FrameInterpolation_RecordOpenChild(this, 0); Matrix_Push(&gGfxMatrix); RCP_SetupDL(&gMasterDisp, SETUPDL_64); gDPSetPrimColor(gMasterDisp++, 0x00, 0x00, 255, 255, 0, 255); @@ -836,7 +837,9 @@ void ItemCheckpoint_Draw(ItemCheckpoint* this) { gSPDisplayList(gMasterDisp++, D_1023C80); gDPSetTextureFilter(gMasterDisp++, G_TF_BILERP); Matrix_Pop(&gGfxMatrix); + FrameInterpolation_RecordCloseChild(); } + FrameInterpolation_RecordOpenChild(this, 1); RCP_SetupDL(&gMasterDisp, SETUPDL_29); gSPTexture(gMasterDisp++, 2000, 2000, 0, G_TX_RENDERTILE, G_ON); gSPSetGeometryMode(gMasterDisp++, G_TEXTURE_GEN); @@ -852,6 +855,7 @@ void ItemCheckpoint_Draw(ItemCheckpoint* this) { Matrix_Pop(&gGfxMatrix); } gSPClearGeometryMode(gMasterDisp++, G_TEXTURE_GEN); + FrameInterpolation_RecordCloseChild(); } void ItemSilverRing_Draw(ItemSilverRing* this) { @@ -1674,8 +1678,8 @@ void Object_DrawAll(s32 arg0) { } for (i = 0, scenery360 = gScenery360; i < 200; i++, scenery360++) { + FrameInterpolation_RecordOpenChild(scenery360, i); if ((scenery360->obj.status == OBJ_ACTIVE) && (scenery360->obj.id != OBJ_SCENERY_LEVEL_OBJECTS)) { - FrameInterpolation_RecordOpenChild(scenery360, i); if (gCurrentLevel == LEVEL_BOLSE) { spAC.x = scenery360->sfxSource[0]; spAC.y = scenery360->sfxSource[1]; @@ -1686,8 +1690,8 @@ void Object_DrawAll(s32 arg0) { Matrix_Push(&gGfxMatrix); Scenery360_Draw(scenery360); Matrix_Pop(&gGfxMatrix); - FrameInterpolation_RecordCloseChild(); } + FrameInterpolation_RecordCloseChild(); } } else { RCP_SetupDL_29(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar); diff --git a/src/overlays/ovl_menu/fox_i_menu.c b/src/overlays/ovl_menu/fox_i_menu.c index e7b30008..4e1afd69 100644 --- a/src/overlays/ovl_menu/fox_i_menu.c +++ b/src/overlays/ovl_menu/fox_i_menu.c @@ -1,5 +1,6 @@ #include "fox_title.h" #include "global.h" +#include "port/interpolation/FrameInterpolation.h" void Title_Main(void); void Title_Draw(void); @@ -30,7 +31,9 @@ void OvlMenu_CallFunction(u32 mode, void* ptr) { break; case OVLCALL_MAP_DRAW: + FrameInterpolation_RecordOpenChild("MapDraw", 0); Map_Draw(); + FrameInterpolation_RecordCloseChild(); break; case OVLCALL_OPTION_UPDATE: diff --git a/src/overlays/ovl_menu/fox_map.c b/src/overlays/ovl_menu/fox_map.c index 85c066cd..e7379711 100644 --- a/src/overlays/ovl_menu/fox_map.c +++ b/src/overlays/ovl_menu/fox_map.c @@ -15,6 +15,7 @@ #include "assets/ast_map.h" #include "assets/ast_text.h" #include "assets/ast_font_3d.h" +#include "port/interpolation/FrameInterpolation.h" // BSS STARTS HERE u8 gMapVenomCloudTex[96 * 96]; diff --git a/src/port/interpolation/FrameInterpolation.cpp b/src/port/interpolation/FrameInterpolation.cpp index cc158a88..611e6cd3 100644 --- a/src/port/interpolation/FrameInterpolation.cpp +++ b/src/port/interpolation/FrameInterpolation.cpp @@ -402,7 +402,8 @@ unordered_map FrameInterpolation_Interpolate(float step) { bool camera_interpolation = true; void FrameInterpolation_ShouldInterpolateFrame(bool shouldInterpolate) { - camera_interpolation = shouldInterpolate; + // camera_interpolation = shouldInterpolate; + is_recording = shouldInterpolate; } void FrameInterpolation_StartRecord(void) { diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index ffa50c83..f261e9b7 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -468,6 +468,10 @@ void DrawDebugMenu() { .tooltip = "Allows you to play sound effects from the game" }); + UIWidgets::CVarCheckbox("Disable stars interpolation", "gDisableStarsInterpolation", { + .tooltip = "Disable starfield interpolation for performance" + }); + UIWidgets::Spacer(0); UIWidgets::WindowButton("Stats", "gStatsEnabled", GameUI::mStatsWindow, {