Fix bugs in zoning
This commit is contained in:
@@ -43,9 +43,11 @@ xIntercepts' :: Float -> Point2 -> Point2 -> [Point2]
|
||||
{-# INLINE xIntercepts' #-}
|
||||
xIntercepts' s (V2 sx sy) (V2 ex ey)
|
||||
| xdx == 0 = []
|
||||
| xdx > 0 = zipWith V2 [sx', sx' + xdx * 50 .. ex] ([sy', sy' + ydx * 50 .. ey] ++ repeat ey)
|
||||
| otherwise = zipWith V2 [sx' -50, sx' + xdx * 50 -50 .. ex -50] ([sy', sy' + ydx * 50 .. ey] ++ repeat ey)
|
||||
| otherwise = zipWith V2 [halfstep + sx', halfstep + sx' + xdx * s .. ex] ([sy', sy' + ydx * s .. ey] ++ repeat ey)
|
||||
where
|
||||
halfstep
|
||||
| xdx > 0 = -s/2
|
||||
| otherwise = s/2
|
||||
xdx = signum (ex - sx)
|
||||
ydx = (ey - sy) / abs (ex - sx) -- carefull: if this is zero
|
||||
sy' = sy + ydx * abs (sx - sx')
|
||||
|
||||
@@ -15,8 +15,14 @@ crIXsNearPoint p w = zoneExtract (zoneOfPoint' crZoneSize p) (w ^. cWorld . crZo
|
||||
crsNearPoint :: Point2 -> World -> [Creature]
|
||||
crsNearPoint p w = mapMaybe (\cid -> w ^? cWorld . creatures . ix cid) . IS.toList $ crIXsNearPoint p w
|
||||
|
||||
crsNearSeg :: Point2 -> Point2 -> World -> IS.IntSet
|
||||
crsNearSeg sp ep w = zonesExtract (w ^. cWorld . crZoning) (zoneOfSeg' crZoneSize sp ep)
|
||||
crsNearSeg :: Point2 -> Point2 -> World -> [Creature]
|
||||
crsNearSeg sp ep w =
|
||||
mapMaybe (\cid -> w ^? cWorld . creatures . ix cid)
|
||||
. IS.toList
|
||||
$ crixsNearSeg sp ep w
|
||||
|
||||
crixsNearSeg :: Point2 -> Point2 -> World -> IS.IntSet
|
||||
crixsNearSeg sp ep w = zonesExtract (w ^. cWorld . crZoning) (zoneOfSeg' crZoneSize sp ep)
|
||||
|
||||
crIXsNearCirc :: Point2 -> Float -> World -> IS.IntSet
|
||||
crIXsNearCirc p r = crsNearRect (p +.+ V2 r r) (p -.- V2 r r)
|
||||
|
||||
Reference in New Issue
Block a user