mirror of
https://github.com/HarbourMasters/Starship.git
synced 2025-02-03 00:33:55 +03:00
Move calculations outside of the loop, as they only need to be calculated once per frame.
Bit of cleanup.
This commit is contained in:
parent
354de2f364
commit
48aa44f401
@ -229,6 +229,12 @@ void Background_DrawStarfield(void) {
|
|||||||
FrameInterpolation_ShouldInterpolateFrame(false);
|
FrameInterpolation_ShouldInterpolateFrame(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float originalWidth = currentScreenWidth / 5;
|
||||||
|
float originalAspect = originalWidth / (currentScreenHeight / 3);
|
||||||
|
float renderMaskWidth = originalWidth * (OTRGetAspectRatio() / originalAspect);
|
||||||
|
float marginX = (currentScreenWidth - renderMaskWidth) / 2;
|
||||||
|
float renderMaskHeight = currentScreenHeight / 3;
|
||||||
|
|
||||||
for (i = 0; i < starCount; i++, yStar++, xStar++, color++) {
|
for (i = 0; i < starCount; i++, yStar++, xStar++, color++) {
|
||||||
// Adjust star positions with field offsets
|
// Adjust star positions with field offsets
|
||||||
bx = *xStar + xField;
|
bx = *xStar + xField;
|
||||||
@ -258,12 +264,6 @@ void Background_DrawStarfield(void) {
|
|||||||
vx = (zCos * bx) + (zSin * by) + currentScreenWidth / 2.0f;
|
vx = (zCos * bx) + (zSin * by) + currentScreenWidth / 2.0f;
|
||||||
vy = (-zSin * bx) + (zCos * by) + currentScreenHeight / 2.0f;
|
vy = (-zSin * bx) + (zCos * by) + currentScreenHeight / 2.0f;
|
||||||
|
|
||||||
float originalWidth = currentScreenWidth / 5;
|
|
||||||
float originalAspect = originalWidth / (currentScreenHeight / 3);
|
|
||||||
float renderMaskWidth = originalWidth * (OTRGetAspectRatio() / originalAspect);
|
|
||||||
float marginX = (currentScreenWidth - renderMaskWidth) / 2;
|
|
||||||
float renderMaskHeight = currentScreenHeight / 3;
|
|
||||||
|
|
||||||
// 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 >= (marginX - STAR_MARGIN) && vx <= (marginX + renderMaskWidth + STAR_MARGIN) &&
|
if (vx >= (marginX - STAR_MARGIN) && vx <= (marginX + renderMaskWidth + STAR_MARGIN) &&
|
||||||
vy >= (renderMaskHeight - STAR_MARGIN) && vy <= ((renderMaskHeight * 2) + STAR_MARGIN)) {
|
vy >= (renderMaskHeight - STAR_MARGIN) && vy <= ((renderMaskHeight * 2) + STAR_MARGIN)) {
|
||||||
|
@ -589,11 +589,3 @@ extern "C" void* GameEngine_Malloc(size_t size) {
|
|||||||
SPDLOG_INFO("Memory pool resized from {} to {}", MemoryPool.length - chunk, MemoryPool.length);
|
SPDLOG_INFO("Memory pool resized from {} to {}", MemoryPool.length - chunk, MemoryPool.length);
|
||||||
return GameEngine_Malloc(size);
|
return GameEngine_Malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" float GetWindowWidth() {
|
|
||||||
return Ship::Context::GetInstance()->GetWindow()->GetWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" float GetWindowHeight() {
|
|
||||||
return Ship::Context::GetInstance()->GetWindow()->GetHeight();
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user