spatial-monorepo / wayfinding/src / stringPull
Function: stringPull()
stringPull(
cells,grid):GridCell[]
Defined in: packages/wayfinding/src/string-pull.ts:38
Collapses a dense cell-by-cell path (as returned by findGridPath) into a small number of straight, wall-respecting segments.
An independent implementation of the "shorten path eager" line-of-sight string-pulling technique described in the Wayfinding v2 plan (§3 point 4; §7 crib sheet: shorten_path_eager) — written from that description, not ported code.
From each anchor point, greedily tries the farthest remaining point first and walks backward until line-of-sight holds, then commits and repeats from there. Because hasLineOfSight samples the same grid the path was searched over, a shortcut is only taken when it provably never crosses a wall cell — this is what makes the output follow corridor bends instead of cutting through them.
Parameters
cells
GridCell[]
grid
Returns
GridCell[]
