Add check for render view to prevent drawing stars outside of it.

Remove garbage star interp calculation.
This commit is contained in:
Malkierian 2024-12-09 10:16:14 -07:00 committed by Alejandro Asenjo Nitti
parent 493d0b2e8c
commit 7a333a68c2

View File

@ -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;