From 7a333a68c2f2f372d936c1efd900c315de627848 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Mon, 9 Dec 2024 10:16:14 -0700 Subject: [PATCH] Add check for render view to prevent drawing stars outside of it. Remove garbage star interp calculation. --- src/engine/fox_bg.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/engine/fox_bg.c b/src/engine/fox_bg.c index 9a4ce815..870a9699 100644 --- a/src/engine/fox_bg.c +++ b/src/engine/fox_bg.c @@ -258,21 +258,15 @@ void Background_DrawStarfield(void) { vx = (zCos * bx) + (zSin * by) + currentScreenWidth / 2.0f; vy = (-zSin * bx) + (zCos * by) + currentScreenHeight / 2.0f; + float thirdWidth = currentScreenWidth / 3; + float thirdHeight = currentScreenHeight / 3; + // Check if the star is within the visible screen area with margin - if ((vx >= STAR_MARGIN) && (vx < currentScreenWidth - STAR_MARGIN) && (vy >= STAR_MARGIN) && - (vy < currentScreenHeight - STAR_MARGIN)) { + if (vx >= (thirdWidth - STAR_MARGIN) && vx <= ((thirdWidth * 2) + STAR_MARGIN) && + vy >= (thirdHeight - STAR_MARGIN) && vy <= ((thirdHeight * 2) + STAR_MARGIN)) { - // @port: Some garbage stars can be seen while scrolling faster, because of this - // we should skip interpolation when the stars warp from left to right. - u8 skipStarsInterpolation = (fabsf(vx - gStarPrevX[i]) > starfieldWidth / 2.0f) || - (fabsf(vy - gStarPrevY[i]) > starfieldHeight / 2.0f); - - if (skipStarsInterpolation) { - FrameInterpolation_ShouldInterpolateFrame(false); - } else { - FrameInterpolation_RecordOpenChild("Starfield", i); - FrameInterpolation_RecordMarker(__FILE__, __LINE__); - } + FrameInterpolation_RecordOpenChild("Starfield", i); + FrameInterpolation_RecordMarker(__FILE__, __LINE__); // Translate to (vx, vy) in ortho coordinates Matrix_Push(&gGfxMatrix); @@ -295,12 +289,7 @@ void Background_DrawStarfield(void) { gSPDisplayList(gMasterDisp++, starDL); Matrix_Pop(&gGfxMatrix); - if (skipStarsInterpolation) { - FrameInterpolation_ShouldInterpolateFrame(true); - } else { - // Pop the transform id - FrameInterpolation_RecordCloseChild(); - } + FrameInterpolation_RecordCloseChild(); gStarPrevX[i] = vx; gStarPrevY[i] = vy;