Fix a subtle bug with flying units in spatialbins. Fixes #489.
This commit is contained in:
@@ -89,6 +89,10 @@ namespace OpenRA
|
|||||||
return mods.Aggregate(sprites, (m, p) => p.ModifyRender(this, m));
|
return mods.Aggregate(sprites, (m, p) => p.ModifyRender(this, m));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When useAltitude = true, the bounding box is extended
|
||||||
|
// vertically to altitude = 0 to support FindUnitsInCircle queries
|
||||||
|
// When false, the bounding box is given for the actor
|
||||||
|
// at its current altitude
|
||||||
public RectangleF GetBounds(bool useAltitude)
|
public RectangleF GetBounds(bool useAltitude)
|
||||||
{
|
{
|
||||||
var size = Size.Value;
|
var size = Size.Value;
|
||||||
@@ -98,10 +102,12 @@ namespace OpenRA
|
|||||||
if (si != null && si.Bounds != null && si.Bounds.Length > 2)
|
if (si != null && si.Bounds != null && si.Bounds.Length > 2)
|
||||||
loc += new float2(si.Bounds[2], si.Bounds[3]);
|
loc += new float2(si.Bounds[2], si.Bounds[3]);
|
||||||
|
|
||||||
if (useAltitude)
|
|
||||||
{
|
|
||||||
var move = TraitOrDefault<IMove>();
|
var move = TraitOrDefault<IMove>();
|
||||||
if (move != null) loc -= new float2(0, move.Altitude);
|
if (move != null)
|
||||||
|
{
|
||||||
|
loc -= new float2(0, move.Altitude);
|
||||||
|
if (useAltitude)
|
||||||
|
size = new float2(size.X, size.Y + move.Altitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RectangleF(loc.X, loc.Y, size.X, size.Y);
|
return new RectangleF(loc.X, loc.Y, size.X, size.Y);
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public void DrawSelectionBox(Actor selectedUnit, Color c)
|
public void DrawSelectionBox(Actor selectedUnit, Color c)
|
||||||
{
|
{
|
||||||
var bounds = selectedUnit.GetBounds(true);
|
var bounds = selectedUnit.GetBounds(false);
|
||||||
|
|
||||||
var xy = new float2(bounds.Left, bounds.Top);
|
var xy = new float2(bounds.Left, bounds.Top);
|
||||||
var Xy = new float2(bounds.Right, bounds.Top);
|
var Xy = new float2(bounds.Right, bounds.Top);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public void RenderAfterWorld (WorldRenderer wr, Actor self)
|
public void RenderAfterWorld (WorldRenderer wr, Actor self)
|
||||||
{
|
{
|
||||||
var bounds = self.GetBounds(true);
|
var bounds = self.GetBounds(false);
|
||||||
Color selectionColor = Color.White;
|
Color selectionColor = Color.White;
|
||||||
|
|
||||||
var xy = new float2(bounds.Left, bounds.Top);
|
var xy = new float2(bounds.Left, bounds.Top);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
var rect = new RectangleF(min.X, min.Y, max.X - min.X, max.Y - min.Y);
|
var rect = new RectangleF(min.X, min.Y, max.X - min.X, max.Y - min.Y);
|
||||||
|
|
||||||
var inBox = actors.Where(x => x.GetBounds(false).IntersectsWith(rect));
|
var inBox = actors.Where(x => x.GetBounds(true).IntersectsWith(rect));
|
||||||
|
|
||||||
return inBox.Where(x => (x.CenterLocation - a).LengthSquared < r * r);
|
return inBox.Where(x => (x.CenterLocation - a).LengthSquared < r * r);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (self.Owner == self.World.LocalPlayer && Level > 0)
|
if (self.Owner == self.World.LocalPlayer && Level > 0)
|
||||||
{
|
{
|
||||||
RankAnim.Tick(); // hack
|
RankAnim.Tick(); // hack
|
||||||
var bounds = self.GetBounds(true);
|
var bounds = self.GetBounds(false);
|
||||||
yield return new Renderable(RankAnim.Image,
|
yield return new Renderable(RankAnim.Image,
|
||||||
new float2(bounds.Right - 6, bounds.Bottom - 8), "effect", (int)self.CenterLocation.Y);
|
new float2(bounds.Right - 6, bounds.Bottom - 8), "effect", (int)self.CenterLocation.Y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
private void RenderStance(Actor self)
|
private void RenderStance(Actor self)
|
||||||
{
|
{
|
||||||
var bounds = self.GetBounds(true);
|
var bounds = self.GetBounds(false);
|
||||||
var loc = new float2(bounds.Left, bounds.Top) + new float2(0, 1);
|
var loc = new float2(bounds.Left, bounds.Top) + new float2(0, 1);
|
||||||
var max = Math.Max(bounds.Height, bounds.Width);
|
var max = Math.Max(bounds.Height, bounds.Width);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user