Fix scissoring in the editor.
This commit is contained in:
@@ -207,14 +207,13 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
// Rectangle (in viewport coords) that contains things to be drawn
|
// Rectangle (in viewport coords) that contains things to be drawn
|
||||||
static readonly Rectangle ScreenClip = Rectangle.FromLTRB(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height);
|
static readonly Rectangle ScreenClip = Rectangle.FromLTRB(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height);
|
||||||
public Rectangle ScissorBounds
|
public Rectangle GetScissorBounds(bool insideBounds)
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
{
|
||||||
// Visible rectangle in world coordinates (expanded to the corners of the cells)
|
// Visible rectangle in world coordinates (expanded to the corners of the cells)
|
||||||
|
var bounds = insideBounds ? VisibleCellsInsideBounds : AllVisibleCells;
|
||||||
var map = worldRenderer.World.Map;
|
var map = worldRenderer.World.Map;
|
||||||
var ctl = map.CenterOfCell(VisibleCellsInsideBounds.TopLeft) - new WVec(512, 512, 0);
|
var ctl = map.CenterOfCell(bounds.TopLeft) - new WVec(512, 512, 0);
|
||||||
var cbr = map.CenterOfCell(VisibleCellsInsideBounds.BottomRight) + new WVec(512, 512, 0);
|
var cbr = map.CenterOfCell(bounds.BottomRight) + new WVec(512, 512, 0);
|
||||||
|
|
||||||
// Convert to screen coordinates
|
// Convert to screen coordinates
|
||||||
var tl = WorldToViewPx(worldRenderer.ScreenPxPosition(ctl - new WVec(0, 0, ctl.Z))).Clamp(ScreenClip);
|
var tl = WorldToViewPx(worldRenderer.ScreenPxPosition(ctl - new WVec(0, 0, ctl.Z))).Clamp(ScreenClip);
|
||||||
@@ -224,7 +223,6 @@ namespace OpenRA.Graphics
|
|||||||
return Rectangle.FromLTRB(tl.X - tileSize.Width, tl.Y - tileSize.Height,
|
return Rectangle.FromLTRB(tl.X - tileSize.Width, tl.Y - tileSize.Height,
|
||||||
br.X + tileSize.Width, br.Y + tileSize.Height);
|
br.X + tileSize.Width, br.Y + tileSize.Height);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
CellRegion CalculateVisibleCells(bool insideBounds)
|
CellRegion CalculateVisibleCells(bool insideBounds)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ namespace OpenRA.Graphics
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var renderables = GenerateRenderables();
|
var renderables = GenerateRenderables();
|
||||||
var bounds = Viewport.ScissorBounds;
|
var bounds = Viewport.GetScissorBounds(World.Type != WorldType.Editor);
|
||||||
Game.Renderer.EnableScissor(bounds);
|
Game.Renderer.EnableScissor(bounds);
|
||||||
|
|
||||||
terrainRenderer.Draw(this, Viewport);
|
terrainRenderer.Draw(this, Viewport);
|
||||||
|
|||||||
Reference in New Issue
Block a user