slightly better collision detection
This commit is contained in:
parent
d4d6e5bd83
commit
38218fa50c
1 changed files with 7 additions and 7 deletions
14
src/Test.hs
14
src/Test.hs
|
@ -359,17 +359,17 @@ checkBoundsCollision2
|
||||||
-> V2 Double
|
-> V2 Double
|
||||||
checkBoundsCollision2
|
checkBoundsCollision2
|
||||||
pre@(V2 pr pc) next@(V2 nr nc) dt acc (Boundaries (minr, minc) (maxr, maxc))
|
pre@(V2 pr pc) next@(V2 nr nc) dt acc (Boundaries (minr, minc) (maxr, maxc))
|
||||||
| colltr > dt && colltc > dt = acc
|
| (colltr >= dt || abs colltr > 0.1) && (colltc >= dt || abs colltc > 0.1) = acc
|
||||||
| colltr > dt = (V2 0 1) * acc
|
| (colltr >= dt || abs colltr > 0.1) = (V2 1 0) * acc
|
||||||
| colltc > dt = (V2 1 0) * acc
|
| (colltc >= dt || abs colltc > 0.1) = (V2 0 1) * acc
|
||||||
| otherwise = V2 0 0
|
| otherwise = V2 0 0
|
||||||
where
|
where
|
||||||
vel@(V2 vr vc) = fmap (/ dt) (next - pre)
|
vel@(V2 vr vc) = fmap (/ dt) (next - pre)
|
||||||
colltr
|
colltr
|
||||||
| vr > 0 = (((fromIntegral (floor nr :: Int)) + minr) - nr) / vr
|
| vr > 0 = (((fromIntegral (floor nr :: Int)) + minr - 0.15) - nr) / vr
|
||||||
| vr < 0 = (((fromIntegral (floor nr :: Int)) + maxr) - nr) / vr
|
| vr < 0 = (((fromIntegral (floor nr :: Int)) + maxr + 0.15) - nr) / vr
|
||||||
| otherwise = dt
|
| otherwise = dt
|
||||||
colltc
|
colltc
|
||||||
| vc > 0 = (((fromIntegral (floor nc :: Int)) + minc) - nc) / vc
|
| vc > 0 = (((fromIntegral (floor nc :: Int)) + minc - 0.15) - nc) / vc
|
||||||
| vc < 0 = (((fromIntegral (floor nc :: Int)) + maxc) - nc) / vc
|
| vc < 0 = (((fromIntegral (floor nc :: Int)) + maxc + 0.15) - nc) / vc
|
||||||
| otherwise = dt
|
| otherwise = dt
|
||||||
|
|
Loading…
Reference in a new issue