Fix error in circle wall collision detection

The wall zoning did not take into account the radius of the circle
This commit is contained in:
2024-12-25 00:10:26 +00:00
parent 18b569ac89
commit 04a83ed031
10 changed files with 571 additions and 488 deletions
+35 -3
View File
@@ -108,6 +108,27 @@ drawCollisionTest w = concat $ do
setLayer DebugLayer (color orange $ line [a, b])
<> foldMap (drawCrossCol red . fst) (thingHit a b w)
drawCircCollisionTest :: World -> Picture
drawCircCollisionTest w = concat $ do
a <- w ^. input . heldWorldPos . at ButtonLeft
b <- w ^. input . heldWorldPos . at ButtonRight
let col | (anythingHitCirc 2 a b w) = red
| otherwise = green
return $
setLayer DebugLayer (color col $ line [a, b])
<> drawCoord a w <> drawCoord b w
drawWallsNearSegment :: World -> Picture
drawWallsNearSegment w = concat $ do
a <- w ^. input . heldWorldPos . at ButtonLeft
b <- w ^. input . heldWorldPos . at ButtonRight
return . foldMap f $ wlsNearSeg a b w
where
f wl = setLayer DebugLayer (color rose $ thickLine 3 [a, b])
<> drawCoord a w <> drawCoord b w
where
(a, b) = _wlLine wl
-- <> foldMap (drawCross . _crPos) (crsNearSeg a b w)
-- <> foldMap (drawZoneCol green crZoneSize . zoneOfPoint crZoneSize) (xIntercepts crZoneSize a b)
-- <> foldMap (drawZoneCol yellow crZoneSize . zoneOfPoint crZoneSize) (yIntercepts' crZoneSize a b)
@@ -147,7 +168,8 @@ debugDraw' cfig w bl = case bl of
Show_wall_search_rays -> drawWallSearchRays w
Show_dda_test -> drawDDATest w
Show_far_wall_detect -> drawFarWallDetect w
Show_walls_near_point_cursor -> drawWallsNearCursor w
Show_walls_near_point_cursor -> mempty
Show_walls_near_segment -> mempty
Show_walls_near_point_you -> drawWallsNearYou w
Show_zone_near_point_cursor -> drawZoneNearPointCursor w
Inspect_wall -> drawInspectWalls w
@@ -160,6 +182,7 @@ debugDraw' cfig w bl = case bl of
Show_nodes_near_select -> undefined --drawNodesNearSelect w
Show_path_between -> drawPathBetween w
Collision_test -> mempty
Circ_collision_test -> mempty
Select_creature -> mempty
drawCreatureDisplayTexts :: World -> Picture
@@ -188,9 +211,10 @@ drawWallsNearYou w = concat $ do
drawWallsNearCursor :: World -> Picture
drawWallsNearCursor w =
setLayer DebugLayer $ foldMap f $ wlsNearPoint (mouseWorldPos (_input w) (_wCam w)) w
foldMap f $ wlsNearPoint (mouseWorldPos (_input w) (_wCam w)) w
where
f wl = color rose $ thickLine 3 [a, b]
f wl = setLayer DebugLayer (color rose $ thickLine 3 [a, b])
<> drawCoord a w <> drawCoord b w
where
(a, b) = _wlLine wl
@@ -326,6 +350,14 @@ drawMousePosition w =
where
mwp = mouseWorldPos (w ^. input) (w ^. wCam)
drawCoord :: Point2 -> World -> Picture
drawCoord p w =
setLayer FixedCoordLayer
. uncurryV translate (worldPosToScreen (w ^. wCam) p)
. scale 0.1 0.1
. text
$ shortPoint2 p
drawWlIDs :: World -> Picture
drawWlIDs w = setLayer FixedCoordLayer $ foldMap f (w ^. cWorld . lWorld . walls)
where