Split Actor.Bounds into RenderBounds and SelectableBounds
Additionally, internally renamed VisualBounds to SelectionOverlayBounds to avoid confusion with RenderBounds. This step was necessary to prevent actors with selectable area smaller than their graphics to be removed too early from ScreenMap even though part of the graphics should still be visible. RA cruisers were a prime example, but to a lesser extent several other actors were affected as well. This separation also serves as preparation to determine the final RenderBounds from multiple source bounds later, to fix the remaining ScreenMap issues (building 'bibs', aircraft shadows).
This commit is contained in:
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
readonly Color color;
|
||||
|
||||
public SelectionBoxRenderable(Actor actor, Color color)
|
||||
: this(actor.CenterPosition, actor.VisualBounds, color) { }
|
||||
: this(actor.CenterPosition, actor.SelectionOverlayBounds, color) { }
|
||||
|
||||
public SelectionBoxRenderable(WPos pos, Rectangle visualBounds, Color color)
|
||||
{
|
||||
|
||||
@@ -314,7 +314,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.World.ActorMap.AddInfluence(self, this);
|
||||
self.World.ActorMap.AddPosition(self, this);
|
||||
|
||||
if (!self.Bounds.Size.IsEmpty)
|
||||
if (!self.RenderBounds.Size.IsEmpty)
|
||||
self.World.ScreenMap.Add(self);
|
||||
|
||||
influence.AddInfluence(self, Info.Tiles(self.Location));
|
||||
@@ -325,7 +325,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.World.ActorMap.RemoveInfluence(self, this);
|
||||
self.World.ActorMap.RemovePosition(self, this);
|
||||
|
||||
if (!self.Bounds.Size.IsEmpty)
|
||||
if (!self.RenderBounds.Size.IsEmpty)
|
||||
self.World.ScreenMap.Remove(self);
|
||||
|
||||
influence.RemoveInfluence(self, Info.Tiles(self.Location));
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.World.ActorMap.AddInfluence(self, this);
|
||||
self.World.ActorMap.AddPosition(self, this);
|
||||
|
||||
if (!self.Bounds.Size.IsEmpty)
|
||||
if (!self.RenderBounds.Size.IsEmpty)
|
||||
self.World.ScreenMap.Add(self);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.World.ActorMap.RemoveInfluence(self, this);
|
||||
self.World.ActorMap.RemovePosition(self, this);
|
||||
|
||||
if (!self.Bounds.Size.IsEmpty)
|
||||
if (!self.RenderBounds.Size.IsEmpty)
|
||||
self.World.ScreenMap.Remove(self);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
public IEnumerable<IRenderable> Render(Actor self, WorldRenderer wr)
|
||||
{
|
||||
var pos = wr.ScreenPxPosition(self.CenterPosition);
|
||||
var bounds = self.Bounds;
|
||||
var bounds = self.SelectableBounds;
|
||||
bounds.Offset(pos.X, pos.Y);
|
||||
var spaceBuffer = (int)(10 / wr.Viewport.Zoom);
|
||||
var effectPos = wr.ProjectedPosition(new int2(pos.X, bounds.Y - spaceBuffer));
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
[PaletteReference] public readonly string Palette = "chrome";
|
||||
|
||||
[Desc("Visual bounds for selection box. If null, it uses AutoSelectionSize.",
|
||||
[Desc("Bounds for visual selection box. If null, it uses AutoSelectionSize.",
|
||||
"The first two values define the bounds' size, the optional third and fourth",
|
||||
"values specify the position relative to the actors' center. Defaults to selectable bounds.")]
|
||||
public readonly int[] VisualBounds = null;
|
||||
@@ -128,7 +128,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
if (pipSources.Length == 0)
|
||||
return Enumerable.Empty<IRenderable>();
|
||||
|
||||
var b = self.VisualBounds;
|
||||
var b = self.SelectionOverlayBounds;
|
||||
var pos = wr.ScreenPxPosition(self.CenterPosition);
|
||||
var bl = wr.Viewport.WorldToViewPx(pos + new int2(b.Left, b.Bottom));
|
||||
var pal = wr.Palette(Info.Palette);
|
||||
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
var pipSize = pipImages.Image.Size.XY.ToInt2();
|
||||
var pipxyBase = basePosition + new int2(1 - pipSize.X / 2, -(3 + pipSize.Y / 2));
|
||||
var pipxyOffset = new int2(0, 0);
|
||||
var width = self.VisualBounds.Width;
|
||||
var width = self.SelectionOverlayBounds.Width;
|
||||
|
||||
foreach (var pips in pipSources)
|
||||
{
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
if (!ShouldRender(self) || self.World.FogObscures(self))
|
||||
return Enumerable.Empty<IRenderable>();
|
||||
|
||||
var bounds = self.VisualBounds;
|
||||
var bounds = self.SelectionOverlayBounds;
|
||||
var halfSize = (0.5f * Anim.Image.Size.XY).ToInt2();
|
||||
|
||||
var boundsOffset = new int2(bounds.Left + bounds.Right, bounds.Top + bounds.Bottom) / 2;
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
pipImages.PlayFetchIndex(Info.GroupSequence, () => (int)group);
|
||||
|
||||
var bounds = self.VisualBounds;
|
||||
var bounds = self.SelectionOverlayBounds;
|
||||
var boundsOffset = 0.5f * new float2(bounds.Left + bounds.Right, bounds.Top + bounds.Bottom);
|
||||
if (Info.ReferencePoint.HasFlag(ReferencePoints.Top))
|
||||
boundsOffset -= new float2(0, 0.5f * bounds.Height);
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
if (group == null)
|
||||
yield break;
|
||||
|
||||
var bounds = self.VisualBounds;
|
||||
var bounds = self.SelectionOverlayBounds;
|
||||
var number = group.Value.ToString();
|
||||
var halfSize = font.Measure(number) / 2;
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
if (!ShouldRender(self) || self.World.FogObscures(self))
|
||||
return Enumerable.Empty<IRenderable>();
|
||||
|
||||
var bounds = self.VisualBounds;
|
||||
var bounds = self.SelectionOverlayBounds;
|
||||
var halfSize = font.Measure(Info.Text) / 2;
|
||||
|
||||
var boundsOffset = new int2(bounds.Left + bounds.Right, bounds.Top + bounds.Bottom) / 2;
|
||||
|
||||
Reference in New Issue
Block a user