Remove wall corner collision test for creatures
This commit is contained in:
@@ -5,6 +5,7 @@ import Dodge.Data.DamageType
|
||||
import Dodge.Creature.State.Data
|
||||
import Dodge.Debug.Flag.Data
|
||||
import Dodge.Zone
|
||||
import Dodge.Base
|
||||
import Geometry
|
||||
|
||||
import Data.List
|
||||
@@ -21,15 +22,16 @@ colCrWall w c
|
||||
| noclipIsOn && _crID c == 0 = c -- for noclip
|
||||
| p1 == p2 = pushOrCrush ls c
|
||||
| otherwise = c & crPos %~
|
||||
collideCorners rad wallPoints
|
||||
. collideWalls rad p1 ls
|
||||
. checkPushThroughs p1 ls
|
||||
-- collideCorners rad wallPoints
|
||||
collideWalls rad p1 ls
|
||||
. flip (collidePointWalls p1) wls -- check push throughs
|
||||
where
|
||||
rad = _crRad c + wallBuffer
|
||||
p1 = _crOldPos c
|
||||
p2 = _crPos c
|
||||
ls = IM.elems $ _wlLine <$> wallsNearPoint p2 w
|
||||
wallPoints = nub $ concatMap (\(x,y) -> [x,y]) ls
|
||||
wls = wallsNearPoint p2 w
|
||||
--wallPoints = map fst ls
|
||||
noclipIsOn = _noClip $ _debugFlags w
|
||||
|
||||
-- the amount to push creatures out from walls, extra to their radius
|
||||
@@ -40,11 +42,12 @@ wallBuffer = 0
|
||||
-- out from the wall
|
||||
-- this is then repeated if the point ends up on a new wall
|
||||
collideWalls :: Float -> Point2 -> [(Point2,Point2)] -> Point2 -> Point2
|
||||
collideWalls rad cp1 wls cp2 = case (listToMaybe.mapMaybe (pushOutFromWall rad cp2)) wls of
|
||||
collideWalls rad cp1 wls cp2 = case (listToMaybe . mapMaybe (pushOutFromWall rad cp2)) wls of
|
||||
Nothing -> cp2
|
||||
Just cp3 -> case (listToMaybe.reverse.mapMaybe (pushOutFromWall rad cp3)) wls of
|
||||
Just cp3 -> case (listToMaybe . reverse . mapMaybe (pushOutFromWall rad cp3)) wls of
|
||||
Nothing -> cp3
|
||||
Just cp4 -> 0.5 *.* (cp4 +.+ cp1)
|
||||
-- Just cp4 -> 0.5 *.* (cp4 +.+ cp1)
|
||||
Just _ -> cp1
|
||||
|
||||
-- pushes a point out from a list of walls
|
||||
-- if multiple new points occur, chooses the one closest to the orignal point
|
||||
@@ -92,13 +95,3 @@ intersectCirclePoint rad p cCen
|
||||
| dist cCen p > rad = cCen
|
||||
| otherwise = p +.+ (rad *.* errorNormalizeV 65 (cCen -.- p))
|
||||
|
||||
checkPushThroughs :: Point2 -> [(Point2,Point2)] -> Point2 -> Point2
|
||||
checkPushThroughs cp1 wls cp2
|
||||
= fromMaybe cp2 $ (listToMaybe.mapMaybe (checkPushThrough cp1 cp2)) wls
|
||||
|
||||
checkPushThrough :: Point2 -> Point2 -> (Point2,Point2) -> Maybe Point2
|
||||
checkPushThrough cp1 cp2 (wp1,wp2)
|
||||
| isPushedThrough = intersectSegSeg cp1 cp2 wp1 wp2
|
||||
| otherwise = Nothing
|
||||
where
|
||||
isPushedThrough = isRHS wp1 wp2 cp2 && isJust (intersectSegSeg cp1 cp2 wp1 wp2)
|
||||
|
||||
Reference in New Issue
Block a user