Merge branch 'patch-8' of git://github.com/honzapatCZ/FlaxEngine into honzapatCZ-patch-8

This commit is contained in:
Wojtek Figat
2021-07-16 12:34:29 +02:00

View File

@@ -284,6 +284,17 @@ namespace FlaxEngine
Vector2 toExpand = Size * (scale - 1.0f) * 0.5f;
return new Rectangle(Location - toExpand * 0.5f, Size + toExpand);
}
/// <summary>
/// Computed nearest distance between 2 rectangles.
/// </summary>
/// <param name="a">Firat rectangle</param>
/// <param name="b">Second rectangle</param>
/// <returns>Resulting distance, 0 if overlapping</returns>
public static float Distance(Rectangle a, Rectangle b)
{
return Vector2.Max(Vector2.Zero, Vector2.Abs(a.Center - b.Center) - ((a.Size + b.Size) * 0.5f)).Length;
}
/// <summary>
/// Calculates a rectangle that includes the margins (inside).