1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 07:43:01 +01:00

Fix edges of some RLE sprites not drawing when minified

This commit is contained in:
Michael Bernardi
2024-09-22 22:24:36 +10:00
parent cea971790f
commit c9144494ea

View File

@@ -103,20 +103,38 @@ static void PaintSessionAddPSToQuadrant(PaintSession& session, PaintStruct* ps)
static constexpr bool ImageWithinDPI(const ScreenCoordsXY& imagePos, const G1Element& g1, const DrawPixelInfo& dpi)
{
int32_t left = dpi.zoom_level.ApplyInversedTo(imagePos.x + g1.x_offset);
int32_t bottom = dpi.zoom_level.ApplyInversedTo(imagePos.y + g1.y_offset);
int32_t left = imagePos.x + g1.x_offset;
int32_t bottom = imagePos.y + g1.y_offset;
int32_t right = dpi.zoom_level.ApplyInversedTo(imagePos.x + g1.x_offset + g1.width);
int32_t top = dpi.zoom_level.ApplyInversedTo(imagePos.y + g1.y_offset + g1.height);
int32_t right = left + g1.width;
int32_t top = bottom + g1.height;
if (right <= dpi.ScreenX())
return false;
if (top <= dpi.ScreenY())
return false;
if (left >= dpi.ScreenX() + dpi.ScreenWidth())
return false;
if (bottom >= dpi.ScreenY() + dpi.ScreenHeight())
return false;
// mber: It is possible to use only the bottom else block here if you change <= and >= to simply < and >.
// However, since this is used to cull paint structs, I'd prefer to keep the condition strict and calculate
// the culling differently for minifying and magnifying.
auto zoom = dpi.zoom_level;
if (zoom > ZoomLevel{ 0 })
{
if (right <= dpi.WorldX())
return false;
if (top <= dpi.WorldY())
return false;
if (left >= dpi.WorldX() + dpi.WorldWidth())
return false;
if (bottom >= dpi.WorldY() + dpi.WorldHeight())
return false;
}
else
{
if (zoom.ApplyInversedTo(right) <= dpi.ScreenX())
return false;
if (zoom.ApplyInversedTo(top) <= dpi.ScreenY())
return false;
if (zoom.ApplyInversedTo(left) >= dpi.ScreenX() + dpi.ScreenWidth())
return false;
if (zoom.ApplyInversedTo(bottom) >= dpi.ScreenY() + dpi.ScreenHeight())
return false;
}
return true;
}