fix rectangle test touching

pull/17/head
cosmonaut 2022-03-22 10:53:16 -07:00
parent 8f6334b9fb
commit 1e3b5bfa77
1 changed files with 3 additions and 3 deletions

View File

@ -38,7 +38,7 @@ namespace MoonWorks.Collision
var firstAABB = rectangleA.TransformedAABB(transformA); var firstAABB = rectangleA.TransformedAABB(transformA);
var secondAABB = rectangleB.TransformedAABB(transformB); 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) public static bool TestPointRectangleOverlap(Point point, Transform2D pointTransform, Rectangle rectangle, Transform2D rectangleTransform)
@ -46,7 +46,7 @@ namespace MoonWorks.Collision
var transformedPoint = pointTransform.Position; var transformedPoint = pointTransform.Position;
var AABB = rectangle.TransformedAABB(rectangleTransform); 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) 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 distanceSquared = (centerA - centerB).LengthSquared();
var radiusSumSquared = (radiusA + radiusB) * (radiusA + radiusB); 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) public static (bool, Simplex2D) FindCollisionSimplex(IShape2D shapeA, Transform2D transformA, IShape2D shapeB, Transform2D transformB)