collision detection still not working

This commit is contained in:
nek0 2021-03-22 07:01:02 +01:00
parent 7654888f6f
commit d9a0128958

View file

@ -112,8 +112,8 @@ class (Show c, Mass c) => Collidible c where
in
if d2x - d1x == 0 then dt else (p1x - p2x) / (d2x - d1x)
ty =
let p1y = (\(V2 _ y) -> y) (if d1y < 0 then m1p4 else m1p1)
p2y = (\(V2 _ y) -> y) (if d1y < 0 then m2p1 else m2p4)
let p1y = (\(V2 _ y) -> y) (if d1y < 0 then m1p1 else m1p4)
p2y = (\(V2 _ y) -> y) (if d1y < 0 then m2p4 else m2p1)
in
if d2y - d1y == 0 then dt else (p1y - p2y) / (d2y - d1y)
in
@ -126,8 +126,8 @@ class (Show c, Mass c) => Collidible c where
if d1x <= 0
then
let (V2 _ g1s) = m1p1 + ((tx *) <$> d1)
(V2 _ g1e) = m1p4 + ((tx *) <$> d1)
(V2 _ g2s) = m2p2 + ((tx *) <$> d2)
(V2 _ g1e) = m1p2 + ((tx *) <$> d1)
(V2 _ g2s) = m2p4 + ((tx *) <$> d2)
(V2 _ g2e) = m2p3 + ((tx *) <$> d2)
s11 = (g1s - g2s) / (g2e - g2s)
s12 = (g1e - g2s) / (g2e - g2s)
@ -138,10 +138,10 @@ class (Show c, Mass c) => Collidible c where
then Collision tx (V2 (floor $ signum d1x) 0)
else NoCollision
else
let (V2 _ g1s) = m1p2 + ((tx *) <$> d1)
let (V2 _ g1s) = m1p4 + ((tx *) <$> d1)
(V2 _ g1e) = m1p3 + ((tx *) <$> d1)
(V2 _ g2s) = m2p1 + ((tx *) <$> d2)
(V2 _ g2e) = m2p4 + ((tx *) <$> d2)
(V2 _ g2e) = m2p2 + ((tx *) <$> d2)
s11 = (g1s - g2s) / (g2e - g2s)
s12 = (g1e - g2s) / (g2e - g2s)
s21 = (g2s - g1s) / (g1e - g1s)
@ -158,8 +158,8 @@ class (Show c, Mass c) => Collidible c where
if d1y <= 0
then
let (V2 g1s _) = m1p1 + ((ty *) <$> d1)
(V2 g1e _) = m1p2 + ((ty *) <$> d1)
(V2 g2s _) = m2p4 + ((ty *) <$> d2)
(V2 g1e _) = m1p4 + ((ty *) <$> d1)
(V2 g2s _) = m2p2 + ((ty *) <$> d2)
(V2 g2e _) = m2p3 + ((ty *) <$> d2)
s11 = (g1s - g2s) / (g2e - g2s)
s12 = (g1e - g2s) / (g2e - g2s)
@ -170,10 +170,10 @@ class (Show c, Mass c) => Collidible c where
then Collision ty (V2 0 (floor $ signum d1y))
else NoCollision
else
let (V2 g1s _) = m1p4 + ((ty *) <$> d1)
let (V2 g1s _) = m1p2 + ((ty *) <$> d1)
(V2 g1e _) = m1p3 + ((ty *) <$> d1)
(V2 g2s _) = m2p1 + ((ty *) <$> d2)
(V2 g2e _) = m2p2 + ((ty *) <$> d2)
(V2 g2e _) = m2p4 + ((ty *) <$> d2)
s11 = (g1s - g2s) / (g2e - g2s)
s12 = (g1e - g2s) / (g2e - g2s)
s21 = (g2s - g1s) / (g1e - g1s)