Fix a subtle bug with flying units in spatialbins. Fixes #489.

This commit is contained in:
Paul Chote
2011-02-01 22:06:09 +13:00
parent 467c2a969d
commit 2daeb45bfe
6 changed files with 17 additions and 11 deletions

View File

@@ -88,7 +88,11 @@ namespace OpenRA
var sprites = TraitsImplementing<IRender>().SelectMany(x => x.Render(this));
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)
{
var size = Size.Value;
@@ -98,12 +102,14 @@ namespace OpenRA
if (si != null && si.Bounds != null && si.Bounds.Length > 2)
loc += new float2(si.Bounds[2], si.Bounds[3]);
if (useAltitude)
{
var move = TraitOrDefault<IMove>();
if (move != null) loc -= new float2(0, move.Altitude);
var move = TraitOrDefault<IMove>();
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);
}