From 12decd1a4783dfb35853d20a375b9a16e4e48801 Mon Sep 17 00:00:00 2001 From: Marc Sunet Date: Sun, 2 Sep 2012 11:07:33 +0200 Subject: Fixed and simplified AABB collision --- Spear/Collision.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Spear/Collision.hs b/Spear/Collision.hs index 9c538ae..fb8f11e 100644 --- a/Spear/Collision.hs +++ b/Spear/Collision.hs @@ -40,15 +40,13 @@ class Collisionable a where instance Collisionable AABB where collideBox box1@(AABB min1 max1) box2@(AABB min2 max2) - | min1 > max2 = NoCollision - | max1 < min2 = NoCollision - | box1 `aabbpt` min2 && box1 `aabbpt` max2 = FullyContains - | box2 `aabbpt` min1 && box2 `aabbpt` max1 = FullyContainedBy | (x max1) < (x min2) = NoCollision | (x min1) > (x max2) = NoCollision | (y max1) < (y min2) = NoCollision | (y min1) > (y max2) = NoCollision - | otherwise = Collision + | box1 `aabbpt` min2 && box1 `aabbpt` max2 = FullyContains + | box2 `aabbpt` min1 && box2 `aabbpt` max1 = FullyContainedBy + | otherwise = Collision collideCircle sphere@(Circle c r) aabb@(AABB min max) | test == FullyContains || test == FullyContainedBy = test -- cgit v1.2.3