UsdLayerManager/openspec/changes/camera-wireframe-viewport/proposal.md

29 lines
2.3 KiB
Markdown

## Why
Camera prims exist in the USD scene but are invisible in the viewport — there is no visual indication of a camera's position, orientation, or field of view. Users cannot tell where cameras are in the scene, cannot click to select them, and cannot use the transform manipulator to reposition them. This is a critical gap for any scene with multiple cameras (rendering, animation, layout).
## What Changes
- Draw a 3D frustum wireframe for every `UsdGeomCamera` prim in the viewport, rendered into the FBO using the existing GL overlay infrastructure (`BindDrawTarget`/`UnbindDrawTarget`).
- Highlight the **active camera** (the one currently driving the viewport via the camera toolbar) with a distinct colour; all other cameras use the standard camera wire colour.
- Highlight the **selected camera** with the selection accent colour.
- Support **viewport click-selection** of camera prims by screen-space hit-testing mouse clicks against projected frustum segments.
- Camera prims, once selected, can be translated/rotated/scaled through the existing `TransformManipulator` (they are `Xformable`; no manipulator changes are required).
## Capabilities
### New Capabilities
- `camera-frustum-overlay`: Per-frame GL wireframe rendering of all `UsdGeomCamera` prims' frustums into the viewport FBO, with colour-coding for active vs. selected vs. inactive cameras.
- `camera-viewport-picking`: Screen-space hit-testing that maps a viewport mouse click to a camera prim when the click is within a threshold distance of any projected frustum edge; integrates with the existing prim-selection callbacks.
### Modified Capabilities
_(none — no existing spec-level requirements are changing)_
## Impact
- **Modified**: `src/core/UsdSceneRenderer.h/.cpp` — add `DrawCameraWireframes(stage, selectedPaths, activeCameraPath, viewProjMatrix)` and `PickCameraAtPoint(stage, mouseScreenPos, viewProjMatrix, imagePos, viewW, viewH, outPath)`.
- **Modified**: `src/ui/ViewportPanel.cpp` — call `DrawCameraWireframes` each frame after `DrawBoundingBoxes`; call `PickCameraAtPoint` inside the single-click pick path before the existing `PickObject` geometry pick so camera hits take priority.
- No new external dependencies. Uses existing GLSL shader program already compiled for `DrawAxis`/`DrawBoundingBoxes`.