Eliminate walkable/transparent duplication between GridData and TCODMap #333
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Depends on
Reference
john/McRogueFace#333
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From the 2026-07-02 memory-model review. Depends on the GridData SoA refactor (#332).
Current behavior
walkable/transparent live in both the
UIGridPointcells and libtcod'sTCOD_map_t(new TCODMapinGridData::initStorage,src/GridData.cpp:76-77). Sync is one-directional and eager:syncTCODMapCell(src/GridData.cpp:133-140viasrc/UIGridPoint.cpp:90)syncTCODMaploop (src/GridData.cpp:120-131)src/UIGridPathfinding.cpp:575-611)Proposal
After SoA planes exist, make the TCOD map a derived, lazily-rebuilt cache: rebuild (or incrementally patch) only when FOV/Dijkstra/A* is requested and
transparency_generation(src/GridData.h:93) is newer than the map's generation. Per-write sync disappears; bulk writes (including future numpy ingest) cost one rebuild at next query instead of N syncs.Alternative considered: making TCOD the primary store -- rejected; TCOD_map packs its own struct and would put libtcod's ABI in the middle of every cell read.
Longer term this is also where the libtcod-path work (integer-native, N-dim, header-only) could replace TCODMap entirely, taking the planes as direct input.
Unblocked now that #332 (SoA planes) has landed, but deferring after a closer read of the current cost.
The per-write sync this issue targets is already O(1) per cell —
syncTCODMapCelldoes a singletcod_map->setProperties(...), not a full-grid rebuild — and the bulk writers (apply_threshold/apply_rangesheightmap paths) already sync once after their loop, not per cell. So there is no current hot bottleneck to remove; the win is architectural (decouple the TCOD map from the write path so a future numpy bulk-ingest ofwalkable/transparentwrites planes directly and rebuilds once).Against that modest, forward-looking benefit, the change carries real FOV + pathfinding correctness risk: the lazy rebuild must interleave correctly with the pathfinding collision-label temporary mutate/restore (
UIGridPathfinding.cppmarkCollisionLabel/restoreCollisionLabel), and every FOV/Dijkstra/A* entry point must gain anensureTCODMapCurrent()guard. Worth doing deliberately with a dedicated FOV/path regression pass, not bundled into the current sprint.Note:
transparency_generation(bumped on every walkable/transparent change) is already the right dirty signal for the lazy rebuild when someone picks this up — add atcod_map_generationand rebuild when it lags.