Skip to content

fix(3D view): stops fast flashing of flat 2D while the camera scrolls - #213

Merged
999sian merged 1 commit into
999sian:masterfrom
Strikeborn:fix/voxel-scroll-flicker
Oct 20, 2026
Merged

999sian merged 1 commit into
999sian:masterfrom
Strikeborn:fix/voxel-scroll-flicker

Conversation

@Strikeborn

Copy link
Copy Markdown

Result: the 3D view holds steady while walking and during camera pans, instead of flashing back to the flat 2D frame a few times a second.

Files: port/port_voxel.cpp

Not in v0.9.5. It affects anyone on master using the 3D view (Windows/Linux Vulkan builds), and fixing it is a step toward making the 3D view usable day to day.

Cause

MapShownPct() takes the room position from gRoomControls.scroll_* but the BG position from the latched BGxHOFS/VOFS. While scrolling, the two can be a tile apart for a frame. The score then drops toward 0, BottomMapShown() fails, and that frame falls back to 2D. Logging confirmed every fallback was during normal gameplay (GAMEMAIN_UPDATE).

Change

  • MapShownPct() scores the camera offset and its 8 neighbours (±8 px) and keeps the best, so a one-tile lag no longer reads as "map not on screen".
  • Opt-in TMC_VOXEL_DEBUG=1: logs each 2D fallback (task/state/substate, room size, match %) and each geometry rebuild with its reason. Off by default. Happy to drop it if you'd rather not carry it.

Why this fix

  • It corrects the comparison rather than masking it. Repurposed BGs (Gyorg, map-less rooms, cutscenes) still score 0–5%, far below the 50% cut-off. Hysteresis would instead draw 3D over them for N frames.
  • Cost: 9× a tiny loop (~5k compares per call).

Tested (Windows, Vulkan, USA, TMC_VOXEL_DEBUG=1)

  • Before: a 2D fallback every 2–6 frames while scrolling. After: none during gameplay; only room transitions remain (match 0–5%).
  • Walking and the Zelda → Link pan no longer flicker. Play-tested to the Picori Festival (early game only).

Developed with assistance from Claude Code (Opus 5.5). I reviewed and tested the changes as described above.

MapShownPct compared gRoomControls.scroll against the latched BG registers, which can be a tile apart for a frame while scrolling. Score the camera tile and its 8 neighbours and keep the best. Adds opt-in TMC_VOXEL_DEBUG logging.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants