aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Sunet <jeannekamikaze@gmail.com>2012-09-02 11:07:33 +0200
committerMarc Sunet <jeannekamikaze@gmail.com>2012-09-02 11:07:33 +0200
commit12decd1a4783dfb35853d20a375b9a16e4e48801 (patch)
tree95eb05e0f06273e0d35e48c00f6bc1e7a928eadb
parent74f1b41d45994eadb90b0f227b3a5682f43cb8c8 (diff)
Fixed and simplified AABB collision
-rw-r--r--Spear/Collision.hs8
1 files 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
40instance Collisionable AABB where 40instance Collisionable AABB where
41 41
42 collideBox box1@(AABB min1 max1) box2@(AABB min2 max2) 42 collideBox box1@(AABB min1 max1) box2@(AABB min2 max2)
43 | min1 > max2 = NoCollision
44 | max1 < min2 = NoCollision
45 | box1 `aabbpt` min2 && box1 `aabbpt` max2 = FullyContains
46 | box2 `aabbpt` min1 && box2 `aabbpt` max1 = FullyContainedBy
47 | (x max1) < (x min2) = NoCollision 43 | (x max1) < (x min2) = NoCollision
48 | (x min1) > (x max2) = NoCollision 44 | (x min1) > (x max2) = NoCollision
49 | (y max1) < (y min2) = NoCollision 45 | (y max1) < (y min2) = NoCollision
50 | (y min1) > (y max2) = NoCollision 46 | (y min1) > (y max2) = NoCollision
51 | otherwise = Collision 47 | box1 `aabbpt` min2 && box1 `aabbpt` max2 = FullyContains
48 | box2 `aabbpt` min1 && box2 `aabbpt` max1 = FullyContainedBy
49 | otherwise = Collision
52 50
53 collideCircle sphere@(Circle c r) aabb@(AABB min max) 51 collideCircle sphere@(Circle c r) aabb@(AABB min max)
54 | test == FullyContains || test == FullyContainedBy = test 52 | test == FullyContains || test == FullyContainedBy = test