Manages a set of simultaneously loaded Scenes. Supports Single and Additive loading, async loads via JobSystem, explicit per-scene unloading, and deferred scene transitions.
More...
#include <SceneManager.hpp>
|
| void | loadScene (const std::string &path, LoadSceneMode mode, bool discardPendingAsync=true) |
| | Queue a scene to load next frame by path.
|
| void | loadScene (int sceneId, LoadSceneMode mode, bool discardPendingAsync=true) |
| | Queue a scene to load next frame by its existing id.
|
| std::shared_ptr< AsyncOperation > | loadSceneAsync (const std::string &path, LoadSceneMode mode, bool discardPendingAsync=true) |
| | Start an async scene load. File I/O runs on a JobSystem worker; entity spawning is merged on the main thread next frame.
|
| void | unloadScene (const std::string &path) |
| | Immediately queue an unload for the scene with the given path.
|
| void | unloadScene (int sceneId) |
| | Immediately queue an unload for the scene with the given ID.
|
| void | changeScene (std::unique_ptr< Scene > nextScene) |
| | Direct scene swap (used by editor and legacy code). Unloads all current scenes and activates nextScene immediately.
|
| void | update (float dt) |
| | Called each frame. Flushes all pending loads, unloads, and async merges.
|
| void | setContext (Registry *reg, VulkanRenderer *rend) |
| | Provide registry and renderer pointers needed for scene construction.
|
| Scene * | getCurrentScene () const |
| | Returns the first loaded scene (oldest), or nullptr. Backward-compatible.
|
| std::vector< SceneInfo > | getLoadedSceneInfos () const |
| | Returns all currently loaded scene entries.
|
| SceneInfo | getSceneInfo (int id) const |
| | Returns info for a scene by id, or invalid SceneInfo (id=-1) if not found.
|
| SceneInfo | getSceneInfo (const std::string &nameOrPath) const |
| | Returns info for a scene by path/name, or invalid SceneInfo if not found.
|
| bool | hasActiveAsyncLoads () const |
| | True if any async loads are currently in flight.
|
Manages a set of simultaneously loaded Scenes. Supports Single and Additive loading, async loads via JobSystem, explicit per-scene unloading, and deferred scene transitions.
◆ cancelAllAsyncOps()
| void SceneManager::cancelAllAsyncOps |
( |
| ) |
|
|
private |
◆ changeScene()
| void SceneManager::changeScene |
( |
std::unique_ptr< Scene > | nextScene | ) |
|
Direct scene swap (used by editor and legacy code). Unloads all current scenes and activates nextScene immediately.
◆ findSceneIdByPath()
| int SceneManager::findSceneIdByPath |
( |
const std::string & | path | ) |
const |
|
private |
◆ fireSceneLoaded()
| void SceneManager::fireSceneLoaded |
( |
const SceneInfo & | info | ) |
|
|
private |
◆ fireSceneUnloaded()
| void SceneManager::fireSceneUnloaded |
( |
const SceneInfo & | info | ) |
|
|
private |
◆ flushPendingAsyncMerges()
| void SceneManager::flushPendingAsyncMerges |
( |
| ) |
|
|
private |
◆ flushPendingLoads()
| void SceneManager::flushPendingLoads |
( |
| ) |
|
|
private |
◆ flushPendingUnloads()
| void SceneManager::flushPendingUnloads |
( |
| ) |
|
|
private |
◆ getCurrentScene()
| Scene * SceneManager::getCurrentScene |
( |
| ) |
const |
Returns the first loaded scene (oldest), or nullptr. Backward-compatible.
◆ getLoadedSceneInfos()
| std::vector< SceneInfo > SceneManager::getLoadedSceneInfos |
( |
| ) |
const |
Returns all currently loaded scene entries.
◆ getSceneInfo() [1/2]
| SceneInfo SceneManager::getSceneInfo |
( |
const std::string & | nameOrPath | ) |
const |
Returns info for a scene by path/name, or invalid SceneInfo if not found.
◆ getSceneInfo() [2/2]
| SceneInfo SceneManager::getSceneInfo |
( |
int | id | ) |
const |
Returns info for a scene by id, or invalid SceneInfo (id=-1) if not found.
◆ hasActiveAsyncLoads()
| bool SceneManager::hasActiveAsyncLoads |
( |
| ) |
const |
True if any async loads are currently in flight.
◆ loadScene() [1/2]
| void SceneManager::loadScene |
( |
const std::string & | path, |
|
|
LoadSceneMode | mode, |
|
|
bool | discardPendingAsync = true ) |
Queue a scene to load next frame by path.
- Parameters
-
| path | Scene file path. |
| mode | Single or Additive. |
| discardPendingAsync | Cancel in-flight async ops when true. |
◆ loadScene() [2/2]
| void SceneManager::loadScene |
( |
int | sceneId, |
|
|
LoadSceneMode | mode, |
|
|
bool | discardPendingAsync = true ) |
Queue a scene to load next frame by its existing id.
- Parameters
-
| sceneId | Numeric scene ID (must exist in loadedScenes). |
| mode | Single or Additive. |
| discardPendingAsync | Cancel in-flight async ops when true. |
◆ loadSceneAsync()
| std::shared_ptr< AsyncOperation > SceneManager::loadSceneAsync |
( |
const std::string & | path, |
|
|
LoadSceneMode | mode, |
|
|
bool | discardPendingAsync = true ) |
Start an async scene load. File I/O runs on a JobSystem worker; entity spawning is merged on the main thread next frame.
- Parameters
-
| path | Scene file path. |
| mode | Single or Additive. |
| discardPendingAsync | Cancel in-flight async ops when true. |
- Returns
- Shared AsyncOperation handle for tracking progress.
◆ pathToName()
| std::string SceneManager::pathToName |
( |
const std::string & | path | ) |
const |
|
private |
◆ resolvePath()
| std::string SceneManager::resolvePath |
( |
const std::string & | nameOrPath | ) |
const |
|
private |
Resolves a name-or-path string to a canonical scene file path. "level1" -> "assets/scenes/level1.json" "assets/scenes/level1.json" -> "assets/scenes/level1.json".
◆ setContext()
Provide registry and renderer pointers needed for scene construction.
◆ spawnScene()
Spawns a DefaultScene from path and registers it with a new id.
◆ spawnSceneFromContent()
| SceneInfo SceneManager::spawnSceneFromContent |
( |
const std::string & | path, |
|
|
const std::string & | jsonContent, |
|
|
LoadSceneMode | mode ) |
|
private |
Spawns a scene from pre-loaded JSON string content.
◆ unloadAllScenes()
| void SceneManager::unloadAllScenes |
( |
| ) |
|
|
private |
◆ unloadScene() [1/2]
| void SceneManager::unloadScene |
( |
const std::string & | path | ) |
|
Immediately queue an unload for the scene with the given path.
◆ unloadScene() [2/2]
| void SceneManager::unloadScene |
( |
int | sceneId | ) |
|
Immediately queue an unload for the scene with the given ID.
◆ unloadSceneByPath()
| void SceneManager::unloadSceneByPath |
( |
const std::string & | path | ) |
|
|
private |
◆ update()
| void SceneManager::update |
( |
float | dt | ) |
|
Called each frame. Flushes all pending loads, unloads, and async merges.
- Parameters
-
◆ activeAsyncMutex
| std::mutex SceneManager::activeAsyncMutex |
|
mutableprivate |
◆ activeAsyncOps
| std::vector<std::shared_ptr<AsyncOperation> > SceneManager::activeAsyncOps |
|
private |
◆ asyncMergeMutex
| std::mutex SceneManager::asyncMergeMutex |
|
mutableprivate |
◆ loadedScenes
Currently active scenes. Accessed only on main thread.
◆ nextSceneId
| std::atomic<int> SceneManager::nextSceneId {0} |
|
private |
◆ onSceneLoadedCallback
| std::function<void(const SceneInfo&)> SceneManager::onSceneLoadedCallback |
◆ onSceneUnloadedCallback
| std::function<void(const SceneInfo&)> SceneManager::onSceneUnloadedCallback |
◆ pendingAsyncMerges
◆ pendingLoads
◆ pendingUnloadPaths
| std::vector<std::string> SceneManager::pendingUnloadPaths |
|
private |
◆ registry
| Registry* SceneManager::registry = nullptr |
|
private |
◆ renderer
The documentation for this class was generated from the following files: