mirror of
https://github.com/HarbourMasters/Starship.git
synced 2025-02-02 16:23:57 +03:00
stars interpolation fix
This commit is contained in:
parent
6b0d495567
commit
5c40875817
@ -157,6 +157,10 @@ static Gfx starSetupDL[] = {
|
|||||||
gsSPEndDisplayList(),
|
gsSPEndDisplayList(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// New global variables for storing the previoous positions
|
||||||
|
f32 gStarPrevX[3000];
|
||||||
|
f32 gStarPrevY[3000];
|
||||||
|
|
||||||
// @port: Starfield drawn with triangles, re-engineered by @Tharo & @TheBoy181
|
// @port: Starfield drawn with triangles, re-engineered by @Tharo & @TheBoy181
|
||||||
void Background_DrawStarfield(void) {
|
void Background_DrawStarfield(void) {
|
||||||
f32 by;
|
f32 by;
|
||||||
@ -257,8 +261,18 @@ void Background_DrawStarfield(void) {
|
|||||||
// Check if the star is within the visible screen area with margin
|
// Check if the star is within the visible screen area with margin
|
||||||
if ((vx >= STAR_MARGIN) && (vx < currentScreenWidth - STAR_MARGIN) && (vy >= STAR_MARGIN) &&
|
if ((vx >= STAR_MARGIN) && (vx < currentScreenWidth - STAR_MARGIN) && (vy >= STAR_MARGIN) &&
|
||||||
(vy < currentScreenHeight - STAR_MARGIN)) {
|
(vy < currentScreenHeight - STAR_MARGIN)) {
|
||||||
FrameInterpolation_RecordOpenChild("Starfield", i);
|
|
||||||
FrameInterpolation_RecordMarker(__FILE__, __LINE__);
|
// @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__);
|
||||||
|
}
|
||||||
|
|
||||||
// Translate to (vx, vy) in ortho coordinates
|
// Translate to (vx, vy) in ortho coordinates
|
||||||
Matrix_Push(&gGfxMatrix);
|
Matrix_Push(&gGfxMatrix);
|
||||||
@ -280,8 +294,16 @@ void Background_DrawStarfield(void) {
|
|||||||
// Draw the star using the predefined display list
|
// Draw the star using the predefined display list
|
||||||
gSPDisplayList(gMasterDisp++, starDL);
|
gSPDisplayList(gMasterDisp++, starDL);
|
||||||
Matrix_Pop(&gGfxMatrix);
|
Matrix_Pop(&gGfxMatrix);
|
||||||
// Pop the transform id
|
|
||||||
FrameInterpolation_RecordCloseChild();
|
if (skipStarsInterpolation) {
|
||||||
|
FrameInterpolation_ShouldInterpolateFrame(true);
|
||||||
|
} else {
|
||||||
|
// Pop the transform id
|
||||||
|
FrameInterpolation_RecordCloseChild();
|
||||||
|
}
|
||||||
|
|
||||||
|
gStarPrevX[i] = vx;
|
||||||
|
gStarPrevY[i] = vy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,6 +628,9 @@ void Play_GenerateStarfield(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
extern f32 gStarPrevX[3000];
|
||||||
|
extern f32 gStarPrevY[3000];
|
||||||
|
|
||||||
void Play_GenerateStarfield(void) {
|
void Play_GenerateStarfield(void) {
|
||||||
u32 i;
|
u32 i;
|
||||||
float currentScreenWidth = gCurrentScreenWidth;
|
float currentScreenWidth = gCurrentScreenWidth;
|
||||||
@ -645,6 +648,8 @@ void Play_GenerateStarfield(void) {
|
|||||||
gStarOffsetsX[i] = RAND_FLOAT_SEEDED(starfieldWidth);
|
gStarOffsetsX[i] = RAND_FLOAT_SEEDED(starfieldWidth);
|
||||||
gStarOffsetsY[i] = RAND_FLOAT_SEEDED(starfieldHeight);
|
gStarOffsetsY[i] = RAND_FLOAT_SEEDED(starfieldHeight);
|
||||||
gStarFillColors[i] = FILL_COLOR(gStarColors[i % ARRAY_COUNT(gStarColors)]);
|
gStarFillColors[i] = FILL_COLOR(gStarColors[i % ARRAY_COUNT(gStarColors)]);
|
||||||
|
gStarPrevX[i] = 0.0f;
|
||||||
|
gStarPrevY[i] = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user