From 1e3b5bfa77f4ec68670a5c952be2e07ab2697bfe Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Tue, 22 Mar 2022 10:53:16 -0700 Subject: [PATCH] fix rectangle test touching --- src/Collision/NarrowPhase.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Collision/NarrowPhase.cs b/src/Collision/NarrowPhase.cs index 06cea63..ddad6e9 100644 --- a/src/Collision/NarrowPhase.cs +++ b/src/Collision/NarrowPhase.cs @@ -38,7 +38,7 @@ namespace MoonWorks.Collision var firstAABB = rectangleA.TransformedAABB(transformA); var secondAABB = rectangleB.TransformedAABB(transformB); - return firstAABB.Left <= secondAABB.Right && firstAABB.Right >= secondAABB.Left && firstAABB.Top <= secondAABB.Bottom && firstAABB.Bottom >= secondAABB.Top; + return firstAABB.Left < secondAABB.Right && firstAABB.Right > secondAABB.Left && firstAABB.Top < secondAABB.Bottom && firstAABB.Bottom > secondAABB.Top; } public static bool TestPointRectangleOverlap(Point point, Transform2D pointTransform, Rectangle rectangle, Transform2D rectangleTransform) @@ -46,7 +46,7 @@ namespace MoonWorks.Collision var transformedPoint = pointTransform.Position; var AABB = rectangle.TransformedAABB(rectangleTransform); - return transformedPoint.X >= AABB.Left && transformedPoint.X <= AABB.Right && transformedPoint.Y <= AABB.Bottom && transformedPoint.Y >= AABB.Top; + return transformedPoint.X > AABB.Left && transformedPoint.X < AABB.Right && transformedPoint.Y < AABB.Bottom && transformedPoint.Y > AABB.Top; } public static bool TestCircleOverlap(Circle circleA, Transform2D transformA, Circle circleB, Transform2D transformB) @@ -60,7 +60,7 @@ namespace MoonWorks.Collision var distanceSquared = (centerA - centerB).LengthSquared(); var radiusSumSquared = (radiusA + radiusB) * (radiusA + radiusB); - return distanceSquared <= radiusSumSquared; + return distanceSquared < radiusSumSquared; } public static (bool, Simplex2D) FindCollisionSimplex(IShape2D shapeA, Transform2D transformA, IShape2D shapeB, Transform2D transformB)