|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
Manages game objects within a scene, handling registration, ID allocation, and GPU buffer synchronization for meshlet-to-object mappings. More...
#include <SceneManager.h>
Public Member Functions | |
| SceneManager (ApplicationContext *context) | |
| ~SceneManager () | |
| std::vector< Actor * > | getAllActors () |
| Gets a list of pointers to all actors in the scene. | |
| std::vector< Entity * > | getAllEntities () |
| Gets a list of pointers to all entities in the current scene. | |
| template<typename T> | |
| std::vector< T * > | getAllComponentsOfClassFromActors () |
| Gets a list of all components over all actors (EXPENSIVE!) | |
| MeshComponent * | registerGameObject (MeshComponent *gameObject) |
| registers a game object to the active scene | |
| void | unregisterGameObject (const MeshComponent *gameObject) |
| unregisters a game object from the active scene | |
| uint32_t | getGameObjectCount () const |
| returns the amount of objects present in the current scene | |
| const std::vector< MeshComponent * > & | getGameObjects () const |
| const MeshComponent * | getGameObject (const scene_object_id id) const |
| const VulkanBuffer & | getMeshletToObjectBuffer () const |
| void | cleanup () |
| void | uploadGameObjectToMeshletMap () |
| Uploads the changed data to the buffer on the gpu. Is only one buffer. | |
| void | destroyMeshletToObjectMapBuffer () |
| template<typename T> | |
| void | loadScene () |
| Triggers the load of a new scene. Will be executed once the current frame has finished processing. | |
| bool | isSceneChangePending () const |
| Checks if a scene change has been requested. | |
| void | executePendingSceneLoading () |
| Executes the pending scene load. Should be called between frames. | |
| void | unloadScene () |
| Unloads the current scene. | |
| void | clear () |
| Clears all game objects and resets the manager state for a new scene. | |
| Scene * | getActiveScene () const |
| void | setActiveScene (Scene *scene) |
| void | setAssetManager (AssetManager *manager) |
| Sets the asset manager that will be injected into scenes. | |
Private Member Functions | |
| void | addMeshToMap (const MeshComponent *gameObject) |
| void | addMeshesToMap (const std::vector< MeshComponent * > &gameObjects) |
| void | rebuildMeshMap () |
| void | createMeshletToObjectMapBuffer (ApplicationContext *context) |
| void | loadSceneContent () const |
Private Attributes | |
| AssetManager * | assetManager_ = nullptr |
| std::vector< MeshComponent * > | gameObjects = {} |
| std::vector< uint32_t > | gameObjectToMeshletMap {} |
| std::optional< VulkanBuffer > | meshletToObjectMapBuffer {} |
| ApplicationContext * | context = nullptr |
| Scene * | activeScene = nullptr |
| std::function< void()> | pendingSceneLoad |
Manages game objects within a scene, handling registration, ID allocation, and GPU buffer synchronization for meshlet-to-object mappings.
Definition at line 22 of file SceneManager.h.
|
explicit |
Definition at line 13 of file SceneManager.cpp.
References context, and createMeshletToObjectMapBuffer().
| EngineCore::SceneManager::~SceneManager | ( | ) |
Definition at line 17 of file SceneManager.cpp.
|
private |
Definition at line 144 of file SceneManager.cpp.
References gameObjects.
|
private |
Definition at line 140 of file SceneManager.cpp.
| void EngineCore::SceneManager::cleanup | ( | ) |
Definition at line 74 of file SceneManager.cpp.
References destroyMeshletToObjectMapBuffer(), and unloadScene().
| void EngineCore::SceneManager::clear | ( | ) |
Clears all game objects and resets the manager state for a new scene.
Definition at line 104 of file SceneManager.cpp.
References gameObjects, and gameObjectToMeshletMap.
Referenced by unloadScene().
|
private |
Definition at line 152 of file SceneManager.cpp.
References context, MAX_MESHLETS_PER_BIN, and meshletToObjectMapBuffer.
Referenced by SceneManager().
| void EngineCore::SceneManager::destroyMeshletToObjectMapBuffer | ( | ) |
Definition at line 164 of file SceneManager.cpp.
References meshletToObjectMapBuffer.
Referenced by cleanup().
| void EngineCore::SceneManager::executePendingSceneLoading | ( | ) |
Executes the pending scene load. Should be called between frames.
Definition at line 84 of file SceneManager.cpp.
References activeScene, pendingSceneLoad, TRACY_ZONE_SCOPED_NAMED, and unloadScene().
|
inlinenodiscard |
Definition at line 111 of file SceneManager.h.
References activeScene.
| std::vector< Actor * > EngineCore::SceneManager::getAllActors | ( | ) |
Gets a list of pointers to all actors in the scene.
Definition at line 20 of file SceneManager.cpp.
References activeScene, and TRACY_ZONE_SCOPED_NAMED.
Referenced by EngineCore::RenderingDataManager::collectMaterialsFromScene().
| std::vector< T * > EngineCore::SceneManager::getAllComponentsOfClassFromActors | ( | ) |
Gets a list of all components over all actors (EXPENSIVE!)
| T | Type of the component. Has to be a subclass of EngineCore::LogicComponent |
Definition at line 143 of file SceneManager.h.
References activeScene.
| std::vector< Entity * > EngineCore::SceneManager::getAllEntities | ( | ) |
Gets a list of pointers to all entities in the current scene.
Definition at line 33 of file SceneManager.cpp.
References activeScene.
|
nodiscard |
Definition at line 63 of file SceneManager.cpp.
References gameObjects.
|
inlinenodiscard |
returns the amount of objects present in the current scene
Definition at line 59 of file SceneManager.h.
References gameObjects.
|
nodiscard |
Definition at line 59 of file SceneManager.cpp.
References gameObjects.
|
nodiscard |
Definition at line 70 of file SceneManager.cpp.
References meshletToObjectMapBuffer.
|
nodiscard |
Checks if a scene change has been requested.
Definition at line 80 of file SceneManager.cpp.
References pendingSceneLoad.
| void EngineCore::SceneManager::loadScene | ( | ) |
Triggers the load of a new scene. Will be executed once the current frame has finished processing.
| T | Type of the scene to load. Has to be child of EngineCore::Scene |
Definition at line 161 of file SceneManager.h.
References activeScene, assetManager_, loadSceneContent(), and pendingSceneLoad.
|
private |
Definition at line 127 of file SceneManager.cpp.
References activeScene.
Referenced by loadScene(), and setActiveScene().
|
private |
Definition at line 148 of file SceneManager.cpp.
| MeshComponent * EngineCore::SceneManager::registerGameObject | ( | MeshComponent * | gameObject | ) |
registers a game object to the active scene
Definition at line 39 of file SceneManager.cpp.
References gameObjects.
| void EngineCore::SceneManager::setActiveScene | ( | Scene * | scene | ) |
Definition at line 109 of file SceneManager.cpp.
References activeScene, assetManager_, loadSceneContent(), and unloadScene().
| void EngineCore::SceneManager::setAssetManager | ( | AssetManager * | manager | ) |
Sets the asset manager that will be injected into scenes.
| manager | Pointer to the AssetManager |
Definition at line 123 of file SceneManager.cpp.
References assetManager_.
| void EngineCore::SceneManager::unloadScene | ( | ) |
Unloads the current scene.
Definition at line 93 of file SceneManager.cpp.
References activeScene, clear(), and TRACY_ZONE_SCOPED_NAMED.
Referenced by cleanup(), executePendingSceneLoading(), and setActiveScene().
| void EngineCore::SceneManager::unregisterGameObject | ( | const MeshComponent * | gameObject | ) |
unregisters a game object from the active scene
Definition at line 45 of file SceneManager.cpp.
References gameObjects.
| void EngineCore::SceneManager::uploadGameObjectToMeshletMap | ( | ) |
Uploads the changed data to the buffer on the gpu. Is only one buffer.
Definition at line 136 of file SceneManager.cpp.
References gameObjectToMeshletMap, and meshletToObjectMapBuffer.
|
private |
Definition at line 136 of file SceneManager.h.
Referenced by executePendingSceneLoading(), getActiveScene(), getAllActors(), getAllComponentsOfClassFromActors(), getAllEntities(), loadScene(), loadSceneContent(), setActiveScene(), and unloadScene().
|
private |
Definition at line 121 of file SceneManager.h.
Referenced by loadScene(), setActiveScene(), and setAssetManager().
|
private |
Definition at line 134 of file SceneManager.h.
Referenced by createMeshletToObjectMapBuffer(), and SceneManager().
|
private |
Definition at line 122 of file SceneManager.h.
Referenced by addMeshesToMap(), clear(), getGameObject(), getGameObjectCount(), getGameObjects(), registerGameObject(), and unregisterGameObject().
|
private |
Definition at line 124 of file SceneManager.h.
Referenced by clear(), and uploadGameObjectToMeshletMap().
|
private |
Definition at line 130 of file SceneManager.h.
Referenced by createMeshletToObjectMapBuffer(), destroyMeshletToObjectMapBuffer(), getMeshletToObjectBuffer(), and uploadGameObjectToMeshletMap().
|
private |
Definition at line 137 of file SceneManager.h.
Referenced by executePendingSceneLoading(), isSceneChangePending(), and loadScene().