-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Improve Camera naming and make bevy_ui respect cameras #16249
Copy link
Copy link
Open
Labels
A-PickingPointing at and selecting objects of all sortsPointing at and selecting objects of all sortsA-RenderingDrawing game state to the screenDrawing game state to the screenA-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Metadata
Metadata
Assignees
Labels
A-PickingPointing at and selecting objects of all sortsPointing at and selecting objects of all sortsA-RenderingDrawing game state to the screenDrawing game state to the screenA-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Consider renaming
Camerato something likeRenderSurface. There isn't anything camera-like about ourCameracomponent, and I think calling it aRenderSurfaceis more apt:ordered with other render surfaces that have the same target.This is why
bevy_pickingrelies onCamera- because theCameracomponent really describes the 2d area thatCamera2dandCamera3drender to.Following that first thought, there is a natural one-to-one cardinality between a UI tree and it's
RenderSurface(Camera). You can't really show a UI tree on multiple render surfaces, because the size of the UI is dependent on the size of the render surface it is given to lay out into.This is why, when this came up last time, I suggested that UI trees should be children of a
RenderSurface(Camera). It would also, IMO solve some of the DX issues. You aren't spawning a freestanding UI camera, a freestanding UI tree, then linking them with aTargetCamera, it would make way more sense to me if the UI tree used our existing relationship for this: parenting.If you want to have multiple UI trees on the same image, well, you would have a unique
RenderSurface(Camera) at the root of each of these trees. This is nice because theorderof these UI's sharing the same render target is explicit.You can also see how the UI/3d/2d can share the same abstractions for viewports, camera order, render targets.
For example, rendering the UIs to the second window, with a particular order, using a different sub viewport:
comands .spawn((RenderSurface { order: 0, viewport: Some(viewport_1), target: window_2 }, Node)) .with_children(|parent| parent.spawn(Node)); comands .spawn((RenderSurface { order: 1, viewport: Some(viewport_2, target: window_2 }, Node)) .with_children(|parent| parent.spawn(Node));Some relevant comments: