Merge branch 'honzapatCZ-patch-8'

This commit is contained in:
2021-07-16 12:34:33 +02:00
+11
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).