herkulesbug found. sticky walls

This commit is contained in:
nek0 2018-05-14 17:54:55 +02:00
parent 165baa179c
commit 4226265030

View file

@ -231,8 +231,8 @@ updateMap dt = do
concatMap concatMap
(\(dr, dc) -> (\(dr, dc) ->
let bs = fromMaybe [] (imgObstacle <$> (M.safeGet let bs = fromMaybe [] (imgObstacle <$> (M.safeGet
(fromIntegral $ floor nr + dr) (fromIntegral $ floor pr + dr)
(fromIntegral $ floor nc + dc) (fromIntegral $ floor pc + dc)
(imgMat (stateData ud)))) (imgMat (stateData ud))))
in Prelude.map (\(Boundaries (minr, minc) (maxr, maxc))-> in Prelude.map (\(Boundaries (minr, minc) (maxr, maxc))->
Boundaries Boundaries
@ -373,19 +373,19 @@ 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 < 0 && colltc < 0) || (inrow && incol) = A.log A.Debug ("both " ++ show (colltr, colltc)) (V2 0 0) | colltr < dt && colltc < dt = A.log A.Debug ("both " ++ show (colltr, colltc)) (V2 0 0)
| colltr < 0 && incol = (A.log A.Debug ("row fixed " ++ show (colltr, colltc))(V2 0 1)) * acc | colltr < dt && incol = (A.log A.Debug ("row fixed " ++ show (colltr, colltc))(V2 0 1)) * acc
| colltc < 0 && inrow = (A.log A.Debug ("col fixed " ++ show (colltr, colltc))(V2 1 0)) * acc | colltc < dt && inrow = (A.log A.Debug ("col fixed " ++ show (colltr, colltc))(V2 1 0)) * acc
| otherwise = acc | otherwise = acc
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 - 0.15) - nr) / vr | vr > 0 = (((fromIntegral (floor pr :: Int)) + minr - 0.15) - pr) / vr
| vr < 0 = (((fromIntegral (floor nr :: Int)) + maxr + 0.15) - nr) / vr | vr < 0 = (((fromIntegral (floor pr :: Int)) + maxr + 0.15) - pr) / vr
| otherwise = 0 | otherwise = dt
colltc colltc
| vc > 0 = (((fromIntegral (floor nc :: Int)) + minc - 0.15) - nc) / vc | vc > 0 = (((fromIntegral (floor pc :: Int)) + minc - 0.15) - pc) / vc
| vc < 0 = (((fromIntegral (floor nc :: Int)) + maxc + 0.15) - nc) / vc | vc < 0 = (((fromIntegral (floor pc :: Int)) + maxc + 0.15) - pc) / vc
| otherwise = 0 | otherwise = dt
inrow = pr > minr && pr < maxr inrow = pr > minr && pr < maxr
incol = pc > minc && pc < maxc incol = pc > minc && pc < maxc