Skip to content

cvcGL: mirror viewports — alternate cameras over a shared scene (minimap) - #385

Closed
transfix wants to merge 1 commit into
feat/cvcgl-viewport-corefrom
feat/cvcgl-viewport-mirror
Closed

transfix wants to merge 1 commit into
feat/cvcgl-viewport-corefrom
feat/cvcgl-viewport-mirror

Conversation

@transfix

@transfix transfix commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

cvcGL: mirror viewports — alternate cameras over a shared scene (minimap)

Stacked on #384 (base branch feat/cvcgl-viewport-core). Review/merge #384
first; this adds the second half of the PiP story.

Why

#384 gave us N viewports over separate scenes and made a second
setRenderer over one scene a loud error. The other half the demos want is the
minimap: a second view of the same scene from a different camera —
which addSceneViewport now (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. Each render() copies the source renderer's
    props 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, or nullptr) alongside
    isMirror(), plus a manager-only setMirrorSource().

Tests

cvcgl_viewport extended (offscreen, headless): a mirror of the primary over
the same mainScene

  • draws the shared geometry (its rect shows the scene, not just its own
    background — luma > 0.18);
  • is live — a large quad added to the source scene shows up in the mirror
    rect with the mirror camera left untouched (per-frame prop sync);
  • throws when the named source viewport does not exist.

Full cvcgl suite (28 tests) green locally on Windows/MSVC.

Not yet (still the follow-ups from #384)

Input router (FindPokedRenderer), state layout, SceneRenderer→facade,
promoting the nav-city minimap demo onto this path, and the SWIG bindings +
Python ChaseCamera shim. Lights for a mirror currently fall back to a
headlight following the mirror camera (explicit StageLighting rigs are not yet
mirrored) — fine for a minimap, noted for the demo pass.

…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.
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