Files
loop/src/Dodge/Zoning/Pathing.hs
T
2025-10-21 15:43:23 +01:00

73 lines
2.3 KiB
Haskell

module Dodge.Zoning.Pathing where
import qualified Data.Vector.Unboxed as UV
import Data.Foldable
--import Data.Set (Set)
--import qualified Data.Set as Set
--import Dodge.Data.World
import Dodge.Zoning.Base
--import Dodge.Zoning.Common
import Geometry
import qualified IntMapHelp as IM
import Control.Lens
--pnsNearPoint :: Point2 -> World -> [(Int, Point2)]
--pnsNearPoint = nearPoint pnZoneSize _pnZoning
--pnsNearSeg :: Point2 -> Point2 -> World -> [(Int, Point2)]
--pnsNearSeg = nearSeg pnZoneSize _pnZoning
--pnsNearRect :: Point2 -> Point2 -> World -> [(Int, Point2)]
--pnsNearRect = nearRect pnZoneSize _pnZoning
--pnsNearCirc :: Point2 -> Float -> World -> [(Int, Point2)]
--pnsNearCirc p r = pnsNearRect (p +.+ V2 r r) (p -.- V2 r r)
pnZoneSize :: Float
pnZoneSize = 50
zoneOfPn :: (Int, Point2) -> Int2
zoneOfPn = zoneOfPoint pnZoneSize . snd
zonePn :: (Int, Point2) -> IM.IntMap (IM.IntMap [(Int, Point2)]) -> IM.IntMap (IM.IntMap [(Int, Point2)])
zonePn pn = zoneMonoid (zoneOfPn pn) [pn]
--pesNearPoint :: Point2 -> World -> Set PathEdgeNodes
--pesNearPoint = nearPoint peZoneSize _peZoning
--pesNearPoint p w = zoneExtract (zoneOfPoint peZoneSize p) (w ^. cWorld . lWorld . peZoning)
--pesNearSeg :: Point2 -> Point2 -> World -> Set PathEdgeNodes
--pesNearSeg = nearSeg peZoneSize _peZoning
--pesNearRect :: Point2 -> Point2 -> World -> Set PathEdgeNodes
--pesNearRect = nearRect peZoneSize _peZoning
--pesNearCirc :: Point2 -> Float -> World -> Set PathEdgeNodes
--pesNearCirc p r = pesNearRect (p +.+ V2 r r) (p -.- V2 r r)
peZoneSize :: Float
peZoneSize = 50
zoneOfIncPe :: UV.Vector Point2 -> (Int,Int) -> [Int2]
zoneOfIncPe m (i,j) = zoneOfSeg peZoneSize (m ^?! ix i) (m ^?! ix j)
--zoneOfPe :: PathEdgeNodes -> [Int2]
--zoneOfPe (PathEdgeNodes _ _ pe) = zoneOfSeg peZoneSize (_peStart pe) (_peEnd pe)
--zonePe ::
-- PathEdgeNodes ->
-- IM.IntMap (IM.IntMap (Set PathEdgeNodes)) ->
-- IM.IntMap (IM.IntMap (Set PathEdgeNodes))
--zonePe pe im = foldl' f im (zoneOfPe pe)
-- where
-- f im' i2 = zoneMonoid i2 (Set.singleton pe) im'
zoneIncPe :: UV.Vector Point2 ->
(Int,Int) ->
IM.IntMap (IM.IntMap [(Int,Int)]) ->
IM.IntMap (IM.IntMap [(Int,Int)])
zoneIncPe v pe im = foldl' f im (zoneOfIncPe v pe)
where
f im' i2 = zoneMonoid i2 [pe] im'