Repository navigation
cvcGL: mirror viewports — alternate cameras over a shared scene (minimap) - #386
Merged
Merged
Conversation
…map) The true DBG minimap, generalised: a viewport that shows a scene ANOTHER viewport already draws, from its own camera, without re-attaching the scene (which SceneGraph::setRenderer would do — blanking the source view, the trap the previous commit made loud). ViewportManager::addMirrorViewport(name, sourceViewport, region, layer) adds a Viewport flagged mirror, pointing at the source viewport's renderer. It does NOT attach the scene a second time and is not tracked in attachedScenes; instead render() copies the source renderer's props into the mirror's renderer each frame (shared by reference — one geometry drawn twice), so the mirror always shows the live scene from its own viewpoint. A node added or re-meshed in the source scene appears in the mirror the next frame with no extra work. Viewport gains isMirror()'s companion mirrorSource() (the source renderer, or nullptr) and a manager-only setMirrorSource(). cvcgl_viewport extended: a mirror of the primary over the same mainScene draws the shared geometry (its rect shows the scene, not just its background), a large quad added to the source scene shows up in the mirror rect (live prop sync, camera untouched), and mirroring an unknown source throws. Full cvcgl suite (28 tests) green locally. Stacked on the ViewportManager core PR.
transfix
added a commit
that referenced
this pull request
Sep 21, 2026
…p analysis (#389) Concrete defects a gap-analysis pass found in the merged PiP stack (#384/#386/ #387), fixed before the minimap demo exercises them: * Mirror double-drew 2-D overlays: syncMirrorProps copied EVERY prop, so a mirror of a scene with FpsHud/ScreenTextHud drew the HUD a second time on the inset. It now skips vtkActor2D (a window-space overlay, not scene geometry) — matching the shipping wasm PiP. * Mirror rendered flat: syncMirrorProps copied view props but not lights, so a mirror of a StageLighting-rigged scene lost its lighting. It now copies the source's lights (world-space, correct from the mirror's own camera); with none, the mirror falls back to VTK's automatic headlight. * MB::Right was not the no-op the header claims: its button-down latched a drag target and called setActiveViewport, so a right-click silently stole keyboard focus and released the prior viewport's held keys. routeMouseButton now returns immediately for Right. * CameraController::viewportAspect preferred the WINDOW size over the renderer's for the Map/ortho fit, so a PiP inset in Map mode framed to the wrong aspect; it now prefers the viewport (renderer) size, matching the pan scaling, and falls back to the window before the first frame. * Fixed the stale "addMirrorViewport, a follow-up" comment (it shipped in #386). Tests: cvcgl_viewport gains a check that a 2-D actor on the source does NOT reach the mirror while a source light DOES; cvcgl_viewport_input gains a Right-button no-op check (no focus steal, no camera motion). Full cvcgl suite (29) green locally.
transfix
added a commit
that referenced
this pull request
Sep 21, 2026
…ython (#390) Closes the largest gap the PiP work left: the whole ViewportManager/Viewport/ input-router surface (cvcGL #384/#386/#387) was C++-only, so volrover3 and grl-snam — both Python — could not build multi-viewport or minimap layouts. This wraps it, so the Python API mirrors C++: vm = pycvc_gl.ViewportManager(scene, 1024, 768, False, "main") inset = vm.addSceneViewport("inset", scene2, (0.62, 0.05, 0.97, 0.42), 1) mini = vm.addMirrorViewport("mini", "main", (0.62, 0.58, 0.97, 0.95), 2) inset.camera().setMode(pycvc_gl.CameraController.Mode_Fly) # per-viewport vm.routeMouseButton(pycvc_gl.ViewportManager.MouseButton_Left, True, x, y) vp = vm.viewportAt(x, y) # None over the gutter frame = vm.frameRGB() # bytes Binding details, following the existing pycvc_gl patterns: * frameRGB() -> bytes (a scoped typemap, like SceneRenderer's — the SceneRenderer one does not apply to ViewportManager). * region as a Python 4-sequence in (addSceneViewport/addMirrorViewport) and a 4-tuple out (Viewport.region()), via in/argout typemaps. * Viewport has a private ctor -> %nodefaultctor; it is only ever handed out by the manager. renderer()/renderWindow()/mirrorSource() reuse the existing vtkRenderer*/vtkRenderWindow* -> live vtkmodules typemaps. * KEEPALIVE chain mirrors C++ ownership so a live child pins its parent: the manager keeps its scene(s); every handed-out Viewport (primary/viewport/ viewportAt/activeViewport/add*Viewport) keeps the manager; a Viewport's camera() keeps the Viewport. * MouseButton enum -> ViewportManager.MouseButton_Left/Middle/Right. New test_pycvc_gl_viewport.py exercises the surface end to end: auto primary, addSceneViewport over a second scene + addMirrorViewport, viewportAt (layer/ visibility/inputEnabled/gutter), focus-follows-click into cvc::state, the per-viewport camera (its state under the viewer tree), region tuples, and frameRGB bytes — self-skipping without a GL driver, hard-exiting past cvcGL's static-teardown race like the other pycvc_gl tests. Validated locally by SWIG generation (all 24 ViewportManager + 15 Viewport methods, the MouseButton enum, and both typemaps wrap cleanly); the compiled .pyd + this test run in the cvcpkg pycvc-gl recipe, which builds against the python-enabled VTK the module needs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cvcGL: mirror viewports — alternate cameras over a shared scene (minimap)
Second half of the picture-in-picture story, on top of the merged
ViewportManager core (#384). (Supersedes #385, which GitHub auto-closed when its
stacked base branch was deleted on merge; this is the same commit rebased onto
master.)
Why
#384 gave us N viewports over separate scenes and made a second
setRendererover one scene a loud error. The other half the demos want is aminimap: a second view of the same scene from a different camera —
which
addSceneViewportnow (correctly) refuses.What
ViewportManager::addMirrorViewport(name, sourceViewport, region, layer=2)— a viewport flagged mirror, pointed at the source viewport's renderer. It
does not attach the scene again (so the source keeps its actors) and is
not tracked in
attachedScenes. Eachrender()copies the source renderer'sprops into the mirror's renderer (shared by reference — one geometry drawn
twice), so the mirror always shows the live scene from its own camera; a
node added or re-meshed in the source scene appears in the mirror next frame
with no extra bookkeeping.
Viewport::mirrorSource()(the source renderer, ornullptr) alongsideisMirror(), plus a manager-onlysetMirrorSource().Tests
cvcgl_viewportextended (offscreen, headless): a mirror of the primary overthe same
mainScenebackground —
luma > 0.18);rect with the mirror camera left untouched (per-frame prop sync);
Full
cvcglsuite (28 tests) green locally on Windows/MSVC.Not yet (the remaining follow-ups)
Input router (
FindPokedRenderer, in progress), state layout,SceneRenderer→facade, promoting the nav-city minimap demo, and the SWIG bindings + Python
ChaseCamerashim. Lights for a mirror currently fall back to a headlightfollowing the mirror camera (explicit
StageLightingrigs are not yet mirrored)— fine for a minimap, noted for the demo pass.