Improve creature wall collisions
This commit is contained in:
@@ -36,13 +36,14 @@ colCrWall w c
|
|||||||
where
|
where
|
||||||
-- c'' = c' & crPos %~ pushOutFromWalls rad ls
|
-- c'' = c' & crPos %~ pushOutFromWalls rad ls
|
||||||
--c' = c & crPos %~ pushOutFromWalls' rad (reverse ls)
|
--c' = c & crPos %~ pushOutFromWalls' rad (reverse ls)
|
||||||
c' = c & crPos %~ pushOutFromCorners rad ls
|
c' = c & crPos %~ pushOutFromCorners rad ls'
|
||||||
. pushOutFromWalls rad ls
|
. pushOutFromWalls rad ls'
|
||||||
. flip (collidePointWalls p1) wls -- check push throughs
|
. flip (collidePointWalls p1) wls -- check push throughs
|
||||||
rad = _crRad c + wallBuffer
|
rad = _crRad c + wallBuffer
|
||||||
p1 = _crOldPos c
|
p1 = _crOldPos c
|
||||||
p2 = _crPos c
|
p2 = _crPos c
|
||||||
ls = IM.elems $ _wlLine <$> wls
|
ls = IM.elems $ _wlLine <$> wls
|
||||||
|
ls' = filter (uncurry $ isLHS p1) ls
|
||||||
wls = IM.filter (not . _wlWalkable) $ wallsNearPoint p2 w
|
wls = IM.filter (not . _wlWalkable) $ wallsNearPoint p2 w
|
||||||
--wallPoints = map fst ls
|
--wallPoints = map fst ls
|
||||||
|
|
||||||
@@ -59,7 +60,8 @@ pushCreatureOutFromWalls ls cr = cr & crPos %~ pushOutFromWalls (_crRad cr) ls
|
|||||||
pushOutFromWalls :: Float -> [(Point2,Point2)] -> Point2 -> Point2
|
pushOutFromWalls :: Float -> [(Point2,Point2)] -> Point2 -> Point2
|
||||||
pushOutFromWalls rad wls p1 = case (getFirst . foldMap (First . pushOutFromWall rad p1)) wls of
|
pushOutFromWalls rad wls p1 = case (getFirst . foldMap (First . pushOutFromWall rad p1)) wls of
|
||||||
Nothing -> p1
|
Nothing -> p1
|
||||||
Just p2 -> fromMaybe p2 $ (getLast . foldMap (Last . pushOutFromWall rad p2)) wls
|
--Just p2 -> fromMaybe p2 $ (getLast . foldMap (Last . pushOutFromWall rad p2)) wls
|
||||||
|
Just p2 -> pushOutFromWalls rad (tail wls) p2
|
||||||
-- possible improvement: choose between the closer of p2 and "p3" to p1
|
-- possible improvement: choose between the closer of p2 and "p3" to p1
|
||||||
|
|
||||||
--pushOutFromWalls' :: Float -> [(Point2,Point2)] -> Point2 -> Point2
|
--pushOutFromWalls' :: Float -> [(Point2,Point2)] -> Point2 -> Point2
|
||||||
|
|||||||
Reference in New Issue
Block a user