Skip to content

Step 3: stop re-uploading GPU buffers while dragging a session's gizmo - #553

Merged
JanuszBedkowski merged 3 commits into
MapsHD:mainfrom
michalpelka:mp/step3-fix-gizmo-drag-gpu-churn
Oct 7, 2026
Merged

JanuszBedkowski merged 3 commits into
MapsHD:mainfrom
michalpelka:mp/step3-fix-gizmo-drag-gpu-churn

Conversation

@michalpelka

Copy link
Copy Markdown
Contributor

Summary

  • Dragging a session's gizmo in step 3 mutated every scan's m_pose every frame, which forced ScanRenderer::syncPoses() to tear down and re-upload each scan's full GPU point buffer every single frame for as long as the drag lasted (visible as a stream of VAO: [ID ...] Unloaded... log lines while dragging). Merely selecting a gizmo (not even dragging) triggered the same rebuild, because a double -> float -> double round trip through the gizmo matrix was enough float noise to look like a pose change every frame.
  • While ImGuizmo::IsUsing() is true, the candidate pose chain is now stashed in session_drag_preview_poses instead of being written into the session; the render loop draws it via ScanRenderer::drawCachedWithTransform() (pose folded into the MVP, no GPU re-upload) until the drag ends, at which point the pose is committed for real — the only frame that triggers an actual rebuild.
  • drawCachedWithTransform() only supported a flat/intensity bool, so the drag preview rendered flat-colored instead of matching the scene's live per-point shading (View > Points color, elevation/distance bounds). It now takes the real ScanColorMode plus the elevation/distance bounds those modes need, defaulting to Flat so the existing loop-closure edge preview callers (step 2 and step 3) keep their current look; the drag preview opts in via renderScanAtPose()'s new useSceneColorMode flag.
  • Removed ~200 lines of dead, commented-out pre-raylib-port code in multi_session_registration.cpp's display() (referenced a session variable and GLUT/legacy-GL calls no longer present in this file).

Test plan

  • multi_session_registration_step_3 and multi_view_tls_registration_step_2 both build cleanly (RelWithDebInfo, clang-18).
  • Manually verified in step 3 against a real multi-session project: dragging a session's gizmo no longer prints VAO: [ID ...] Unloaded... per frame, and the dragged session now shades the same way as the rest of the scene instead of going flat.
  • Would be good for a second person to sanity-check gizmo_all_sessions (move-everything) on a multi-session project before merging.

🤖 Generated with Claude Code

@michalpelka
michalpelka marked this pull request as draft October 5, 2026 15:12
@michalpelka
michalpelka force-pushed the mp/step3-fix-gizmo-drag-gpu-churn branch 3 times, most recently from 77faf95 to 87e7c67 Compare October 6, 2026 10:54
michalpelka and others added 2 commits October 6, 2026 13:46
- GPU churn fix (headline): gizmo drag no longer rewrites every scan's pose each frame — candidate poses are stashed and drawn via a transform-only path until the drag ends, so point buffers aren't torn down/re-uploaded every frame. Drag preview also now
  respects the real color mode (not flat-only).
- Loop-closure edge UI: added sliders for active edge / source / target indices (fixes MapsHD#549), aligned on one line with their InputInts.
- Intersections (xz/yz/xy slicing): ported step 2's View > Intersections menu to step 3 (global toggles instead of per-session), added grid overlays and per-session export, and wired it into the loop-closure/drag preview rendering too.
- save_intersection() dedup: moved the per-session slab-export code into shared Core/export_laz.h; fixed a latent array-desync bug (timestamps array could end up shorter than intensity/pointcloud) found while moving it; removed the now-ambiguous legacy
  duplicate that broke MSVC/Windows CI.
- ICP ground-truth bug: fixed source being built from the edge's raw (un-reordered) index instead of the swapped local, which silently aligned the ground-truth scan against a filtered copy of itself when ground truth was on the edge's "to" side.
- Edge-activation crash hardening: fixed inverted bounds check + wrong index type in canEdgeBeActivated(), stale-session bug in setActiveEdge(), a visibility-set collapse bug in settings_gui(), and a session-index mismatch in display()'s active-edge
  rendering (indexing one session's data with another session's bounds). Also fixed loop-closure open/close lifecycle not firing on title-bar close, and a disabled "Set Active" button that didn't actually disable.
- Safety net: removed a blanket top-level catch(...) that was silently swallowing exceptions (including the above bugs) and returning 0; added HDMAPPING_ASSERT (survives NDEBUG, aborts in debug, logs in release unless HDMAPPING_ASSERT_ALWAYS_ABORT).
- Cleanup: removed ~200 lines of dead pre-raylib/GLUT code from multi_session_registration.cpp.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@michalpelka
michalpelka force-pushed the mp/step3-fix-gizmo-drag-gpu-churn branch from 87e7c67 to 0f41456 Compare October 6, 2026 11:50
Each "Export xz/yz/xy intersection" item passed all three
xz_intersection/yz_intersection/xy_intersection flags to
save_intersection()/export_intersection_all_sessions() instead of just
its own plane, so enabling more than one plane made every export button
dump the same union of slabs. Fixed in step 3, step 2, and the legacy
step 2 app.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@michalpelka
michalpelka marked this pull request as ready for review October 7, 2026 02:45
@JanuszBedkowski
JanuszBedkowski merged commit 0045ac5 into MapsHD:main Oct 7, 2026
8 of 14 checks passed
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