Skip to content

cvcGL: CameraController Map mode holds the map pose across update() - #584

Merged
transfix merged 1 commit into
masterfrom
fix/cvcgl-map-mode-pose
Oct 8, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/cvcgl-map-mode-pose

Conversation

@transfix

@transfix transfix commented Oct 8, 2026

Copy link
Copy Markdown
Owner

The bug

In Map mode, update() re-applied the orbit pose. After frameMap(100, 200, ...) the camera sat at (100, 200, 1000). One update() later it was at the default orbit eye, (4.33, -7.5, 5.0), still in parallel projection.

getPose() had no Map branch, so applyToCamera() fell through to the orbit pose. update() runs applyToCamera() whenever the pose, the camera or the scene moves, and on every frame when there's no scene. Map pan and zoom wrote the vtkCamera directly, so the next apply undid them too. As a result, the 2-D map in the nav demos (navdemo::set_ortho_topdown, demo3's "2-D map" toggle in cvcdbg) never held. Found on perf/cvcgl-frame-costs (#521), which kept this behaviour as it was.

The contract, and the fix

The contract comes from the header, the commit that added Map mode, and its callers: a 2-D map with a parallel projection looking straight down, north up. Drag pans with the grabbed point staying under the pointer, the wheel zooms the parallel scale, and rotation is unreachable (Tab can't leave Map).

  • Map has its own pose, like orbit and fly: map.center.{x,y} plus map.scale (the parallel scale). Both live in the state tree and in the pose mirror. getPose() returns this pose: the eye straight above the centre, view-up +y. applyToCamera() applies it along with ParallelProjectionOn and the scale.
  • frameMap(), drag-pan, wheel/pinch zoom (including dolly()) and the resize re-fit now move the map pose instead of the camera. That means cvcGL: frame-cost fixes (idle camera, caster-aware bakes, partial texture uploads, metadata mirror, bounds walk) + reship cvc.15 #521's pose/version change detection in update() covers Map unchanged. The only addition is a scale comparison in applyNeeded(), so idle Map frames still cost nothing.
  • Mode switches keep each mode's pose. setMode() no longer seeds Orbit or Fly from a straight-down map camera, which has no heading to carry over. So Orbit → Map → Orbit returns to the same orbit view, and Map → Orbit → Map to the same map. Fly works the same way.
  • Leaving Map turns off the parallel projection that Map turned on. demo3's setMode(Orbit); // ensure perspective (ParallelProjectionOff) already assumed this; before this PR it wasn't true. A host's own parallel camera in Orbit is left alone.
  • Entering Track from Map eases in from the orbit view. Starting straight down would put the line of sight parallel to the chase view's world-up view-up.

Also fixed on the way

  • readAllFromState() read mode = 3 back as Orbit. Any outside state write while in Map (for example a Camera-menu slider writing settings.*) dropped the view out of the map. "mode" = 3 from state now enters Map, which is what the UI-DSL roadmap's camera: { mode: map } needs.
  • Vertical pan sign. The Map drag negated only x. mouseLook() takes VTK display deltas, where y grows upward; TouchGestures flips DOM y to match, and the orbit pan negates both axes. So a vertical drag moved the map with the pointer instead of keeping the grabbed point under it. Nobody could see this, because update() snapped the camera back every frame.
  • frameBounds() in Map re-applied the orbit pose. It now also seeds the map pose with the box's x/y footprint, fitted like frameMap() with a width. This also gives Map a sensible pose before the first frameMap().

Tests

  • cvcgl_camera_map (new, headless) covers:
    • Repro: frameMap followed by update() keeps the map pose over many frames.
    • Pan and zoom: pan math on both axes, the middle-drag pan, no pan without a button, wheel and dolly zoom, and the map.* mirror.
    • Mode switches: Orbit → Map → Orbit and Map → Orbit → Map keep each pose, perspective comes back on exit, Fly works the same way, Tab can't leave Map, and Track eases in from the orbit view.
    • State tree: an outside write stays in Map, mode 3/0 enter and leave it, map.* moves it, and frameBounds() frames the footprint while in Map.
    • Idle path with a scene: idle frames cause no clipping-range reset and no mirror writes, pan and zoom each apply once, and an outside camera change is put back.
    • Resize re-fit: the width fit follows a resize until the user zooms. This section is skipped if the renderer reports no size.
  • test_pycvc_gl_camera.py section H: the same contract through pycvc_gl (frameMap, Mode_Map, get_pose(), state_set of mode and settings.*), headless.

Verification

The dev box has no VTK, Boost, gtest or GPU, so CI is the build and test gate for this PR. Locally I compiled the real CameraController.cpp and the real test sources against small stand-in VTK, cvc::state and scene headers (written for this check, not committed):

  • cvcgl_camera_map: 0/54 failures with the fix, 40 failures on master. The first master failure is the reported got (4.330, -7.500, 5.000).
  • The existing cvcgl_camera (43 checks) and cvcgl_track_parity give identical, all-passing results on master and on this branch.
  • The Python section's expectations pass when ported to C++ against the same build. pycvc itself was not built here.
  • cvcgl_camera_idle was not run locally (too much of the scene graph to stub); CI runs it.
  • clang-format 18.1.8 (CI installs clang-format 18 on ubuntu-24.04) reports all changed C++ files clean.

Not changed

  • Map still looks down -z with +y up and doesn't follow setUpAxis(). The header now says so instead of "down the up axis". Making Map follow the up axis would be a separate change.
  • The map eye stays at z = 1000, as before (now kMapEyeHeight). Content above that height is clipped, same as today.
  • VolRover3 (transfix/volrover) has its own volrover3::CameraController and doesn't use cvcGL's Map mode. The only callers are the nav demos here and in cvcdbg. Their existing calls (frameMap, setMode(Orbit) followed by frameBounds) need no changes.

getPose() had no Map branch, so applyToCamera() -- which update() runs whenever
the pose, the camera or the scene moved, and every frame without a scene --
pushed the ORBIT pose onto the map camera. frameMap(100, 200, ...) put the eye
at (100, 200, 1000); one update() later it sat at the default orbit eye,
(4.33, -7.5, 5.0), still in parallel projection. Pans and zooms wrote the
vtkCamera directly and were undone the same way, so the 2-D map in the nav
demos (navdemo::set_ortho_topdown, demo3's 2-D toggle) never held.

Map now has its own pose, like orbit and fly: map.center.{x,y} and map.scale
(the parallel scale), in the state tree and the pose mirror. getPose() returns
it (eye straight above the centre, north up), applyToCamera() applies it with
the parallel projection and scale, and frameMap(), drag-pan, wheel/pinch zoom
and the resize re-fit all move that pose rather than the camera, so update()'s
pose/version change detection from #521 covers Map unchanged (plus the scale).

Mode switches keep each mode's pose: setMode() no longer seeds Orbit/Fly from
a straight-down map camera, so Orbit -> Map -> Orbit returns to the same orbit
and Map -> Orbit -> Map to the same map; leaving Map turns the parallel
projection Map turned on back off (what demo3's setMode(Orbit) "ensure
perspective" assumed); Track entered from Map eases in from the orbit view.

Also fixed on the way:
  * readAllFromState() read mode 3 back as Orbit, so any outside state write
    while in Map -- a Camera-menu slider -- dropped out of the map;
  * the Map drag panned the view WITH the pointer vertically (only x was
    negated; VTK display y grows upward), so the grabbed point did not stay
    under it as documented;
  * frameBounds() in Map re-applied the orbit pose; it now also seeds the map
    pose with the box's x/y footprint.

Tests: cvcgl_camera_map (new) pins frameMap + update(), pan/zoom, the
Orbit/Fly/Track <-> Map switches, the state round-trip, the Map idle path with
a scene, and the resize re-fit (skipped when the renderer reports no size).
test_pycvc_gl_camera gains a headless Map section.
@transfix
transfix merged commit 995ba39 into master Oct 8, 2026
14 checks passed
transfix added a commit that referenced this pull request Oct 9, 2026
Patch release carrying the fixes since 3.5.0: the cvcGL M_PI build fix
(#582), CameraController Map mode holding its pose (#584), the tag-release /
publish workflow fixes (#585, #586), macro-safe public headers after
<signal.h> / <sys/param.h> (#588), and the X11 `None` renames (#589:
ariadne::BorderShow::None -> Off, gl::Switch::None -> Off). Bumps
project(VERSION) 3.5.0 -> 3.5.1 and every cvcpkg recipe's upstream_version to
match (cvc_revision stays 1, per the recipe-version gate).
@transfix
transfix deleted the fix/cvcgl-map-mode-pose branch October 10, 2026 03:37
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.

1 participant