From 4226265030ff6d54e07a4f2ef00f4149db370341 Mon Sep 17 00:00:00 2001 From: nek0 Date: Mon, 14 May 2018 17:54:55 +0200 Subject: [PATCH] herkulesbug found. sticky walls --- src/Test.hs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Test.hs b/src/Test.hs index 2f4b890..c990472 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -231,8 +231,8 @@ updateMap dt = do concatMap (\(dr, dc) -> let bs = fromMaybe [] (imgObstacle <$> (M.safeGet - (fromIntegral $ floor nr + dr) - (fromIntegral $ floor nc + dc) + (fromIntegral $ floor pr + dr) + (fromIntegral $ floor pc + dc) (imgMat (stateData ud)))) in Prelude.map (\(Boundaries (minr, minc) (maxr, maxc))-> Boundaries @@ -373,19 +373,19 @@ checkBoundsCollision2 -> V2 Double checkBoundsCollision2 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 < 0 && 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 + | colltr < dt && colltc < dt = A.log A.Debug ("both " ++ show (colltr, colltc)) (V2 0 0) + | colltr < dt && incol = (A.log A.Debug ("row fixed " ++ show (colltr, colltc))(V2 0 1)) * acc + | colltc < dt && inrow = (A.log A.Debug ("col fixed " ++ show (colltr, colltc))(V2 1 0)) * acc | otherwise = acc where vel@(V2 vr vc) = fmap (/ dt) (next - pre) colltr - | vr > 0 = (((fromIntegral (floor nr :: Int)) + minr - 0.15) - nr) / vr - | vr < 0 = (((fromIntegral (floor nr :: Int)) + maxr + 0.15) - nr) / vr - | otherwise = 0 + | vr > 0 = (((fromIntegral (floor pr :: Int)) + minr - 0.15) - pr) / vr + | vr < 0 = (((fromIntegral (floor pr :: Int)) + maxr + 0.15) - pr) / vr + | otherwise = dt colltc - | vc > 0 = (((fromIntegral (floor nc :: Int)) + minc - 0.15) - nc) / vc - | vc < 0 = (((fromIntegral (floor nc :: Int)) + maxc + 0.15) - nc) / vc - | otherwise = 0 + | vc > 0 = (((fromIntegral (floor pc :: Int)) + minc - 0.15) - pc) / vc + | vc < 0 = (((fromIntegral (floor pc :: Int)) + maxc + 0.15) - pc) / vc + | otherwise = dt inrow = pr > minr && pr < maxr incol = pc > minc && pc < maxc