Readd wall corner collisions
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
module Dodge.WallCreatureCollisions
|
||||
( colCrsWalls
|
||||
, colCrWall
|
||||
, pushCreatureOutFromWalls
|
||||
) where
|
||||
import Dodge.Data
|
||||
--import Dodge.Data.DamageType
|
||||
@@ -23,11 +24,13 @@ colCrWall :: World -> Creature -> Creature
|
||||
colCrWall w c
|
||||
| noclipIsOn && _crID c == 0 = c -- for noclip
|
||||
| p1 == p2 = pushOrCrush ls c
|
||||
| _crPos c' == _crPos c'' = c'
|
||||
| otherwise = c & crPos .~ _crOldPos 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 %~ pushOutFromWalls rad ls
|
||||
--c' = c & crPos %~ pushOutFromWalls' rad (reverse ls)
|
||||
c' = c & crPos %~ pushOutFromCorners rad (reverse ls)
|
||||
. pushOutFromWalls rad ls
|
||||
. flip (collidePointWalls p1) wls -- check push throughs
|
||||
rad = _crRad c + wallBuffer
|
||||
@@ -42,6 +45,9 @@ colCrWall w c
|
||||
wallBuffer :: Float
|
||||
wallBuffer = 0
|
||||
|
||||
pushCreatureOutFromWalls :: [(Point2,Point2)] -> Creature -> Creature
|
||||
pushCreatureOutFromWalls ls cr = cr & crPos %~ pushOutFromWalls (_crRad cr) ls
|
||||
|
||||
-- the following tests whether or not a point is on a wall, and if so pushes it
|
||||
-- out from the wall
|
||||
-- this is then repeated if the point ends up on a new wall
|
||||
@@ -91,8 +97,11 @@ pushOutFromWall' rad cp2 (wp1,wp2)
|
||||
--isOnWall = circOnSegNoEndpoints wp1 wp2 cp2 rad
|
||||
isOnWall = circOnSeg wp1 wp2 cp2 rad
|
||||
|
||||
--pushOutFromCorners :: World -> Creature -> Creature
|
||||
--pushOutFromCorners w cr = cr & crPos .~ newPos
|
||||
pushOutFromCorners :: Float -> [(Point2,Point2)] -> Point2 -> Point2
|
||||
pushOutFromCorners r ls p = foldr (intersectCirclePoint r) p (map fst 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
|
||||
@@ -101,7 +110,7 @@ pushOutFromWall' rad cp2 (wp1,wp2)
|
||||
--collideCorners rad ps p2 = foldr (intersectCirclePoint rad) p2 ps
|
||||
|
||||
---- 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))
|
||||
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