AABB transform optimization
parent
d8f9f53dac
commit
8f6334b9fb
|
@ -68,13 +68,10 @@ namespace MoonWorks.Collision
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static AABB2D Transformed(AABB2D aabb, Transform2D transform)
|
public static AABB2D Transformed(AABB2D aabb, Transform2D transform)
|
||||||
{
|
{
|
||||||
var center = (aabb.Min + aabb.Max) / 2f;
|
return new AABB2D(
|
||||||
var extent = (aabb.Max - aabb.Min) / 2f;
|
Vector2.Transform(aabb.Min, transform.TransformMatrix),
|
||||||
|
Vector2.Transform(aabb.Max, transform.TransformMatrix)
|
||||||
var newCenter = Vector2.Transform(center, transform.TransformMatrix);
|
);
|
||||||
var newExtent = Vector2.TransformNormal(extent, AbsoluteMatrix(transform.TransformMatrix));
|
|
||||||
|
|
||||||
return new AABB2D(newCenter - newExtent, newCenter + newExtent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue