SceneToViewportMap Class
Maps scenes to their associated viewports for rendering. More...
Declaration
Public Constructors Index
| SceneToViewportMap ()=default | |
|
Default constructor. More... | |
Public Member Functions Index
| void | updateCache () const |
|
Rebuilds the internal cache if modifications were made. More... | |
| void | add (Scene *scene, Viewport *viewport) |
|
Registers a scene-viewport association. More... | |
| Scene * | scene (ViewportId viewportId) const noexcept |
|
Returns the scene associated with a viewport ID. More... | |
| std::span< Viewport * > | viewports (SceneId sceneId) const noexcept |
|
Returns all viewports associated with a scene. More... | |
| std::span< Scene * > | scenes () const noexcept |
|
Returns all registered scenes. More... | |
| bool | hasScene (const SceneId sceneId) const noexcept |
|
Checks if a scene is registered. More... | |
| Viewport * | viewport (SceneId sceneId, ViewportId viewportId) const noexcept |
|
Returns a specific viewport for a scene. More... | |
Private Member Attributes Index
| std::vector< Scene * > | scenes_ |
|
All registered scenes. More... | |
| std::vector< Viewport * > | viewports_ |
|
All registered viewports. More... | |
| std::unordered_map< SceneId, std::vector< ViewportId > > | sceneIdsToViewportIds_ |
|
Maps scene IDs to their associated viewport IDs. More... | |
| std::unordered_map< SceneId, std::vector< Viewport * > > | viewportMap_ |
|
Cached mapping from scene IDs to viewport pointers. More... | |
| bool | needsUpdate_ = false |
|
Flag indicating the cache needs rebuilding. More... | |
Description
Maps scenes to their associated viewports for rendering.
SceneToViewportMap maintains the relationship between Scene objects and Viewport objects. A scene can be rendered through multiple viewports (e.g., split-screen), and a viewport renders exactly one scene.
The map uses lazy caching: the internal lookup structures are rebuilt only when `updateCache()` is called after modifications.
## Usage
```cpp SceneToViewportMap map; map.add(&gameScene, &mainViewport); map.add(&uiScene, &hudViewport);
// Query scene for viewport auto* scene = map.scene(viewportId);
// Query viewport for scene auto* viewport = map.viewport(sceneId, viewportId); ```
- See Also
SceneRenderingSystem
- See Also
- See Also
Definition at line 55 of file SceneToViewportMap.ixx.
Public Constructors
SceneToViewportMap()
| default |
Default constructor.
Definition at line 87 of file SceneToViewportMap.ixx.
Public Member Functions
add()
| inline |
Registers a scene-viewport association.
Adds the viewport to the scene's viewport list. A scene can have multiple viewports, but each viewport can only be added once.
- Parameters
-
scene Pointer to the scene. Must not be null.
viewport Pointer to the viewport. Must not be null or already registered.
Definition at line 125 of file SceneToViewportMap.ixx.
hasScene()
| inline noexcept |
Checks if a scene is registered.
- Parameters
-
sceneId The scene identifier to check.
- Returns
True if the scene is registered, false otherwise.
Definition at line 202 of file SceneToViewportMap.ixx.
scene()
| inline noexcept |
Returns the scene associated with a viewport ID.
- Parameters
-
viewportId The viewport identifier to look up.
- Returns
Pointer to the scene, or nullptr if not found.
Definition at line 152 of file SceneToViewportMap.ixx.
References scene and updateCache.
scenes()
| inline noexcept |
Returns all registered scenes.
- Returns
Span of scene pointers.
Definition at line 191 of file SceneToViewportMap.ixx.
updateCache()
| inline |
Rebuilds the internal cache if modifications were made.
Called lazily by query methods. Rebuilds the viewportMap_ from the scene-to-viewport-ID mappings.
Definition at line 95 of file SceneToViewportMap.ixx.
Reference viewport.
viewport()
| inline noexcept |
Returns a specific viewport for a scene.
- Parameters
-
sceneId The scene identifier.
viewportId The viewport identifier.
- Returns
Pointer to the viewport, or nullptr if not found.
Definition at line 214 of file SceneToViewportMap.ixx.
References hasScene, updateCache and viewport.
Referenced by add, updateCache and viewport.
viewports()
| inline noexcept |
Returns all viewports associated with a scene.
- Parameters
-
sceneId The scene identifier to look up.
- Returns
Span of viewport pointers, or empty span if not found.
Definition at line 176 of file SceneToViewportMap.ixx.
References hasScene and updateCache.
Private Member Attributes
needsUpdate_
| mutable |
Flag indicating the cache needs rebuilding.
Definition at line 80 of file SceneToViewportMap.ixx.
sceneIdsToViewportIds_
| mutable |
Maps scene IDs to their associated viewport IDs.
Definition at line 70 of file SceneToViewportMap.ixx.
scenes_
| mutable |
All registered scenes.
Definition at line 60 of file SceneToViewportMap.ixx.
viewportMap_
| mutable |
Cached mapping from scene IDs to viewport pointers.
Definition at line 75 of file SceneToViewportMap.ixx.
viewports_
| mutable |
All registered viewports.
Definition at line 65 of file SceneToViewportMap.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.