mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-30 10:15:36 +01:00
Don't invalidate map animations for tiles that are not in view
This commit is contained in:
@@ -1167,6 +1167,17 @@ namespace OpenRCT2
|
||||
return { mapCoords->ToTileStart() };
|
||||
}
|
||||
|
||||
[[nodiscard]] bool Viewport::ContainsTile(const TileCoordsXY coords) const noexcept
|
||||
{
|
||||
const auto centreCoords = coords.ToCoordsXY() + CoordsXY(16, 16);
|
||||
const auto screenPos = Translate3DTo2DWithZ(rotation, CoordsXYZ{ centreCoords, 0 });
|
||||
const auto left = screenPos.x - 32;
|
||||
const auto top = screenPos.y - (kMaxTileElementHeight * kCoordsZStep) - 16;
|
||||
const auto right = screenPos.x + 32;
|
||||
const auto bottom = screenPos.y + 16;
|
||||
return !(left > viewPos.x + ViewWidth() || top > viewPos.y + ViewHeight() || right < viewPos.x || bottom < viewPos.y);
|
||||
}
|
||||
|
||||
[[nodiscard]] ScreenCoordsXY Viewport::ScreenToViewportCoord(const ScreenCoordsXY& screenCoords) const
|
||||
{
|
||||
ScreenCoordsXY ret;
|
||||
@@ -2065,6 +2076,19 @@ namespace OpenRCT2
|
||||
gameState.savedViewRotation = viewport->rotation;
|
||||
}
|
||||
}
|
||||
|
||||
ViewportList GetVisibleViewports() noexcept
|
||||
{
|
||||
ViewportList viewports;
|
||||
for (auto& viewport : _viewports)
|
||||
{
|
||||
if (viewport.isVisible)
|
||||
{
|
||||
viewports.push_back(&viewport);
|
||||
}
|
||||
};
|
||||
return viewports;
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
|
||||
ZoomLevel ZoomLevel::min()
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <sfl/static_vector.hpp>
|
||||
#include <vector>
|
||||
|
||||
struct PaintSession;
|
||||
@@ -65,6 +66,8 @@ namespace OpenRCT2
|
||||
return (sPos.x >= pos.x && sPos.x < pos.x + width && sPos.y >= pos.y && sPos.y < pos.y + height);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool ContainsTile(const TileCoordsXY coords) const noexcept;
|
||||
|
||||
[[nodiscard]] ScreenCoordsXY ScreenToViewportCoord(const ScreenCoordsXY& screenCoord) const;
|
||||
|
||||
void Invalidate() const;
|
||||
@@ -227,4 +230,8 @@ namespace OpenRCT2
|
||||
void ViewportSetSavedView();
|
||||
|
||||
VisibilityKind GetPaintStructVisibility(const PaintStruct* ps, uint32_t viewFlags);
|
||||
|
||||
using ViewportList = sfl::static_vector<Viewport*, kMaxViewportCount>;
|
||||
|
||||
ViewportList GetVisibleViewports() noexcept;
|
||||
} // namespace OpenRCT2
|
||||
|
||||
Reference in New Issue
Block a user