Replace buggy circle seg intersection with a simpler test
This commit is contained in:
@@ -147,9 +147,13 @@ overlapCircWalls p r = mapMaybe dointersect
|
||||
f (a, b) = intersectSegSeg p (p +.+ r *.* normalizeV ((0.5 *.* (a +.+ b)) -.- p)) a b
|
||||
|
||||
circHitWall :: Point2 -> Point2 -> Float -> World -> Bool
|
||||
circHitWall sp ep r w = any (uncurry (intersectSegSegTest sp ep) . _wlLine)
|
||||
(wlsNearSeg sp ep w)
|
||||
circHitWall sp ep r w = any (uncurry (intersectSegSegTest xsp xep) . _wlLine)
|
||||
(wlsNearSeg xsp xep w)
|
||||
|| circOnSomeWall ep r w
|
||||
where
|
||||
x = r *.* normalizeV (ep - sp)
|
||||
xsp = sp - x
|
||||
xep = ep + x
|
||||
|
||||
-- | note that this does not push the circle away from the wall at all
|
||||
collideCircWalls :: Point2 -> Point2 -> Float -> [Wall] -> (Point2, Maybe Wall)
|
||||
@@ -241,7 +245,6 @@ canSeeIndirect i j w = hasLOSIndirect ipos jpos w
|
||||
jpos = w ^?! cWorld . lWorld . creatures . ix j . crPos
|
||||
|
||||
anythingHitCirc :: Float -> Point2 -> Point2 -> World -> Bool
|
||||
--anythingHitCirc rad sp ep w = hitCr || isJust (sequence hitWl)
|
||||
anythingHitCirc rad sp ep w = hitCr || circHitWall sp ep rad w
|
||||
where
|
||||
x = rad *.* normalizeV (ep - sp)
|
||||
@@ -251,7 +254,8 @@ anythingHitCirc rad sp ep w = hitCr || circHitWall sp ep rad w
|
||||
f cid bl =
|
||||
maybe
|
||||
False
|
||||
(\cr -> null $ intersectCircSeg (_crPos cr) (rad + _crRad cr) sp ep)
|
||||
--(\cr -> null $ intersectCircSeg (_crPos cr) (rad + _crRad cr) sp ep)
|
||||
(\cr -> intersectCircSegTest (_crPos cr) (rad + _crRad cr) sp ep)
|
||||
(w ^? cWorld . lWorld . creatures . ix cid)
|
||||
|| bl
|
||||
-- hitWl = collideCircWalls sp ep rad $ wlsNearSeg xsp xep w
|
||||
|
||||
Reference in New Issue
Block a user