mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-22 14:24:33 +01:00
Add a function to invalidate viewports pre-transformed position
This commit is contained in:
@@ -64,7 +64,7 @@ void EntityBase::Invalidate()
|
||||
break;
|
||||
}
|
||||
|
||||
ViewportsInvalidate(SpriteData.SpriteRect, maxZoom);
|
||||
ViewportsInvalidate(GetLocation(), SpriteData.Width, SpriteData.HeightMin, SpriteData.HeightMax, maxZoom);
|
||||
}
|
||||
|
||||
void EntityBase::Serialise(DataSerialiser& stream)
|
||||
|
||||
@@ -237,6 +237,44 @@ Viewport* ViewportGetMain()
|
||||
return mainWindow->viewport;
|
||||
}
|
||||
|
||||
void ViewportsInvalidate(int32_t x, int32_t y, int32_t z0, int32_t z1, ZoomLevel maxZoom)
|
||||
{
|
||||
for (auto& vp : _viewports)
|
||||
{
|
||||
if (maxZoom == ZoomLevel{ -1 } || vp.zoom <= ZoomLevel{ maxZoom })
|
||||
{
|
||||
int32_t x1, y1, x2, y2;
|
||||
|
||||
x += 16;
|
||||
y += 16;
|
||||
auto screenCoord = Translate3DTo2DWithZ(vp.rotation, CoordsXYZ{ x, y, 0 });
|
||||
|
||||
x1 = screenCoord.x - 32;
|
||||
y1 = screenCoord.y - 32 - z1;
|
||||
x2 = screenCoord.x + 32;
|
||||
y2 = screenCoord.y + 32 - z0;
|
||||
|
||||
ViewportInvalidate(&vp, ScreenRect{ { x1, y1 }, { x2, y2 } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewportsInvalidate(const CoordsXYZ& pos, int32_t width, int32_t minHeight, int32_t maxHeight, ZoomLevel maxZoom)
|
||||
{
|
||||
for (auto& vp : _viewports)
|
||||
{
|
||||
if (maxZoom == ZoomLevel{ -1 } || vp.zoom <= ZoomLevel{ maxZoom })
|
||||
{
|
||||
auto screenCoords = Translate3DTo2DWithZ(vp.rotation, pos);
|
||||
auto screenPos = ScreenRect(
|
||||
screenCoords - ScreenCoordsXY{ width, minHeight },
|
||||
screenCoords + ScreenCoordsXY{ width, maxHeight });
|
||||
|
||||
ViewportInvalidate(&vp, screenPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewportsInvalidate(const ScreenRect& screenRect, ZoomLevel maxZoom)
|
||||
{
|
||||
for (auto& vp : _viewports)
|
||||
|
||||
@@ -128,6 +128,8 @@ std::optional<ScreenCoordsXY> centre_2d_coordinates(const CoordsXYZ& loc, Viewpo
|
||||
void ViewportCreate(WindowBase* w, const ScreenCoordsXY& screenCoords, int32_t width, int32_t height, const Focus& focus);
|
||||
void ViewportRemove(Viewport* viewport);
|
||||
Viewport* ViewportGetMain();
|
||||
void ViewportsInvalidate(int32_t x, int32_t y, int32_t z0, int32_t z1, ZoomLevel maxZoom);
|
||||
void ViewportsInvalidate(const CoordsXYZ& pos, int32_t width, int32_t minHeight, int32_t maxHeight, ZoomLevel maxZoom);
|
||||
void ViewportsInvalidate(const ScreenRect& screenRect, ZoomLevel maxZoom = ZoomLevel{ -1 });
|
||||
void ViewportUpdatePosition(WindowBase* window);
|
||||
void ViewportUpdateFollowSprite(WindowBase* window);
|
||||
|
||||
@@ -1794,18 +1794,7 @@ static void MapInvalidateTileUnderZoom(int32_t x, int32_t y, int32_t z0, int32_t
|
||||
if (gOpenRCT2Headless)
|
||||
return;
|
||||
|
||||
int32_t x1, y1, x2, y2;
|
||||
|
||||
x += 16;
|
||||
y += 16;
|
||||
auto screenCoord = Translate3DTo2D(GetCurrentRotation(), { x, y });
|
||||
|
||||
x1 = screenCoord.x - 32;
|
||||
y1 = screenCoord.y - 32 - z1;
|
||||
x2 = screenCoord.x + 32;
|
||||
y2 = screenCoord.y + 32 - z0;
|
||||
|
||||
ViewportsInvalidate({ { x1, y1 }, { x2, y2 } }, maxZoom);
|
||||
ViewportsInvalidate(x, y, z0, z1, maxZoom);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user