Deduplicate redundant FOV computation #292
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.
Dependencies
No dependencies set.
Reference
john/McRogueFace#292
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?
Problem
FOV is computed 2-3x per visibility update cycle:
apply_perspective()→drawFOV()callsgrid->computeFOV()entity.update_visibility()callsgrid->computeFOV()againupdatePerspective()→drawFOV()triggers a third computationThis is pure redundant work — entity position hasn't changed between these calls.
Discovered during
7DRL 2026 jam — observable as unnecessary CPU cost on grids with large FOV radii.
Proposed fix
Add a dirty flag to the grid's FOV state. Mark dirty when the perspective entity's position changes (or when walkable/transparent data changes).
computeFOV()early-returns if not dirty. This ensures at most one FOV computation per frame regardless of how many code paths request it.Alternative: deduplicate the call sites directly so only one path triggers computation per frame. The dirty flag approach is more robust against future call site additions.
Scope
This is independent of #252 (Grid/GridView overhaul) and can be fixed incrementally on the current codebase.
Roadmap context
Part of the Grid & Entity Overhaul Roadmap (
docs/GRID_ENTITY_OVERHAUL_ROADMAP.md), Phase 1 (Foundation). Thefov_dirtyflag pattern introduced here is reused by #303 (FOV optimization for behavior triggers) in Phase 3.