Cleanup
This commit is contained in:
@@ -24,25 +24,10 @@ colCrsWalls cfig w = w & creatures %~ fmap (colCrWall cfig w)
|
||||
|
||||
colCrWall :: Configuration -> World -> Creature -> Creature
|
||||
colCrWall cfig w c
|
||||
| noclipIsOn && _crID c == 0 = c -- for noclip
|
||||
| p1 == p2 = pushOrCrush ls c
|
||||
-- | _crPos c' == _crPos c'' = c'
|
||||
-- | otherwise = c & crPos .~ _crOldPos c
|
||||
| otherwise = c'
|
||||
where
|
||||
-- c'' = c' & crPos %~ pushOutFromWalls rad ls
|
||||
--c' = c & crPos %~ pushOutFromWalls' rad (reverse ls)
|
||||
c' = c & crPos %~ pushOutFromCorners rad ls
|
||||
. pushOutFromWalls rad ls
|
||||
. flip (collidePointWalls p1) wls -- check push throughs
|
||||
rad = _crRad c + wallBuffer
|
||||
p1 = _crOldPos c
|
||||
p2 = _crPos c
|
||||
ls = IM.elems $ _wlLine <$> wls
|
||||
wls = IM.filter (not . _wlWalkable) $ wallsNearPoint p2 w
|
||||
--wallPoints = map fst ls
|
||||
noclipIsOn = _debug_noclip cfig
|
||||
| _debug_noclip cfig && _crID c == 0 = c -- for noclip
|
||||
| otherwise = colCrWall' w c
|
||||
|
||||
-- no noclip check, so no need for a configuration file
|
||||
colCrWall' :: World -> Creature -> Creature
|
||||
colCrWall' w c
|
||||
| p1 == p2 = pushOrCrush ls c
|
||||
@@ -114,44 +99,11 @@ pushOutFromWall rad cp2 (wp1,wp2)
|
||||
wp2' = wp2 +.+ rad *.* norm
|
||||
newP = errorClosestPointOnLine 5 wp1' wp2' cp2
|
||||
isOnWall = circOnSegNoEndpoints wp1 wp2 cp2 rad
|
||||
--pushOutFromWall' :: Float -> Point2 -> (Point2,Point2) -> Maybe Point2
|
||||
--pushOutFromWall' rad cp2 (wp1,wp2)
|
||||
-- | isOnWall = Just newP
|
||||
-- | otherwise = Nothing
|
||||
-- where
|
||||
-- norm = errorNormalizeV 61 $ vNormal (wp1 -.- wp2)
|
||||
-- wp1' = wp1 +.+ rad *.* norm
|
||||
-- wp2' = wp2 +.+ rad *.* norm
|
||||
-- newP = errorClosestPointOnLine 5 wp1' wp2' cp2
|
||||
-- --isOnWall = circOnSegNoEndpoints wp1 wp2 cp2 rad
|
||||
-- isOnWall = circOnSeg wp1 wp2 cp2 rad
|
||||
|
||||
|
||||
|
||||
pushOutFromCorners :: Float -> [(Point2,Point2)] -> Point2 -> Point2
|
||||
pushOutFromCorners r ls p = foldr (squashIntersectCirclePoint r . fst) p ls
|
||||
|
||||
--pushOutFromCorners' :: World -> Creature -> Creature
|
||||
--pushOutFromCorners' w cr = cr & crPos .~ newPos
|
||||
-- where
|
||||
-- newPos = foldr (intersectCirclePoint (_crRad cr)) (_crPos cr) ls
|
||||
-- ls = nub . concatMap (\(x,y) -> [x,y]) . IM.elems $ _wlLine <$> wallsNearPoint (_crPos cr) w
|
||||
|
||||
--collideCorners :: Float -> [Point2] -> Point2 -> Point2
|
||||
--collideCorners rad ps p2 = foldr (intersectCirclePoint rad) p2 ps
|
||||
|
||||
--safeIntersectCirclePoint :: Float -> Point2 -> Point2 -> Maybe Point2
|
||||
--safeIntersectCirclePoint rad p cCen
|
||||
-- | dist cCen p > rad = Just cCen
|
||||
-- | otherwise = (p +.+) <$> ((rad *.*) <$> (safeNormalizeV (cCen -.- p)))
|
||||
|
||||
squashIntersectCirclePoint :: Float -> Point2 -> Point2 -> Point2
|
||||
squashIntersectCirclePoint rad p cCen
|
||||
| dist cCen p > rad = cCen
|
||||
| otherwise = p +.+ (rad *.* squashNormalizeV (cCen -.- p))
|
||||
|
||||
---- collide circles with points (outer corners)
|
||||
--intersectCirclePoint :: Float -> Point2 -> Point2 -> Point2
|
||||
--intersectCirclePoint rad p cCen
|
||||
-- | dist cCen p > rad = cCen
|
||||
-- | otherwise = p +.+ (rad *.* errorNormalizeV 65 (cCen -.- p))
|
||||
|
||||
Reference in New Issue
Block a user