From 8f6334b9fb0786fbb9dec389ca1ae343ca4621ae Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Mon, 21 Mar 2022 16:21:31 -0700 Subject: [PATCH] AABB transform optimization --- src/Collision/AABB2D.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Collision/AABB2D.cs b/src/Collision/AABB2D.cs index 8eb6b99..1822187 100644 --- a/src/Collision/AABB2D.cs +++ b/src/Collision/AABB2D.cs @@ -68,13 +68,10 @@ namespace MoonWorks.Collision /// public static AABB2D Transformed(AABB2D aabb, Transform2D transform) { - var center = (aabb.Min + aabb.Max) / 2f; - var extent = (aabb.Max - aabb.Min) / 2f; - - var newCenter = Vector2.Transform(center, transform.TransformMatrix); - var newExtent = Vector2.TransformNormal(extent, AbsoluteMatrix(transform.TransformMatrix)); - - return new AABB2D(newCenter - newExtent, newCenter + newExtent); + return new AABB2D( + Vector2.Transform(aabb.Min, transform.TransformMatrix), + Vector2.Transform(aabb.Max, transform.TransformMatrix) + ); } ///