|
Vulkan Schnee 0.0.1 (22840dc8)
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) | |
| Creates a scene manager and its meshlet-to-object map buffer. | |
| ~SceneManager () | |
| Destroys the scene manager object. | |
| std::vector< Entities::Actor * > | getAllActors () |
| Gets a list of pointers to all actors in the scene. | |
| std::vector< Entities::Entity * > | getAllEntities () |
| Gets a list of pointers to all entities in the current scene. | |
| template<typename Func> | |
| void | forEachActor (Func &&func) const |
| Calls a function for each actor in the active scene. | |
| template<typename T> | |
| std::vector< T * > | getAllComponentsOfClassFromActors () |
| Gets a list of all components over all actors (EXPENSIVE!) | |
| Components::Mesh * | registerGameObject (Components::Mesh *gameObject) |
| registers a game object to the active scene | |
| void | unregisterGameObject (const Components::Mesh *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< Components::Mesh * > & | getGameObjects () const |
| Returns the registered mesh components for the active scene. | |
| const Components::Mesh * | getGameObject (const scene_object_id id) const |
| Returns a registered mesh component by scene object ID, or nullptr when out of range. | |
| void | cleanup () |
| Unloads the active scene and destroys scene-manager GPU buffers. | |
| void | uploadGameObjectToMeshletMap () |
| Uploads the changed data to the buffer on the gpu. Is only one buffer. | |
| void | destroyMeshletToObjectMapBuffer () |
| Destroys and invalidates the meshlet-to-object map buffer. | |
| template<typename T> | |
| void | loadScene () |
| Triggers the load of a new scene. Will be executed once the current frame has finished processing. | |
| void | loadScene (std::function< Entities::Scene *()> createScene) |
| Queues a scene load using a factory function executed between frames. | |
| 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. | |
| Entities::Scene * | getActiveScene () const |
| Returns the currently active scene, or nullptr when no scene is loaded. | |
| Entities::SceneLightingSettings | getEffectiveLightingSettings () const |
| Returns active-scene lighting overrides or the global lighting defaults. | |
| void | setActiveScene (Entities::Scene *scene) |
| Replaces the active scene and loads its content immediately. | |
| void | setAssetManager (AssetManager *manager) |
| Sets the asset manager that will be injected into scenes. | |
Private Member Functions | |
| void | createMeshletToObjectMapBuffer (ApplicationContext *context) |
| void | loadSceneContent () const |
Private Attributes | |
| AssetManager * | assetManager_ = nullptr |
| std::vector< Components::Mesh * > | gameObjects = {} |
| std::vector< uint32_t > | gameObjectToMeshletMap {} |
| std::unique_ptr< Vulkan::Buffer > | meshletToObjectMapBuffer |
| ApplicationContext * | context = nullptr |
| Entities::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 26 of file SceneManager.h.
|
explicit |
Creates a scene manager and its meshlet-to-object map buffer.
References context.
| Engine::Core::SceneManager::~SceneManager | ( | ) |
Destroys the scene manager object.
| void Engine::Core::SceneManager::cleanup | ( | ) |
Unloads the active scene and destroys scene-manager GPU buffers.
| void Engine::Core::SceneManager::clear | ( | ) |
Clears all game objects and resets the manager state for a new scene.
|
private |
References context.
| void Engine::Core::SceneManager::destroyMeshletToObjectMapBuffer | ( | ) |
Destroys and invalidates the meshlet-to-object map buffer.
| void Engine::Core::SceneManager::executePendingSceneLoading | ( | ) |
Executes the pending scene load. Should be called between frames.
| void Engine::Core::SceneManager::forEachActor | ( | Func && | func | ) | const |
Calls a function for each actor in the active scene.
Definition at line 204 of file SceneManager.h.
References activeScene.
|
inlinenodiscard |
Returns the currently active scene, or nullptr when no scene is loaded.
Definition at line 149 of file SceneManager.h.
References activeScene.
| std::vector< Entities::Actor * > Engine::Core::SceneManager::getAllActors | ( | ) |
Gets a list of pointers to all actors in the scene.
| std::vector< T * > Engine::Core::SceneManager::getAllComponentsOfClassFromActors | ( | ) |
Gets a list of all components over all actors (EXPENSIVE!)
| T | Type of the component. Has to be a subclass of Engine::Core::LogicComponent |
Definition at line 186 of file SceneManager.h.
References activeScene.
| std::vector< Entities::Entity * > Engine::Core::SceneManager::getAllEntities | ( | ) |
Gets a list of pointers to all entities in the current scene.
|
nodiscard |
Returns active-scene lighting overrides or the global lighting defaults.
|
nodiscard |
Returns a registered mesh component by scene object ID, or nullptr when out of range.
|
inlinenodiscard |
returns the amount of objects present in the current scene
Definition at line 76 of file SceneManager.h.
References gameObjects.
|
nodiscard |
Returns the registered mesh components for the active scene.
|
nodiscard |
Checks if a scene change has been requested.
| void Engine::Core::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 215 of file SceneManager.h.
References activeScene, assetManager_, loadSceneContent(), and pendingSceneLoad.
|
inline |
Queues a scene load using a factory function executed between frames.
Definition at line 226 of file SceneManager.h.
References activeScene, assetManager_, loadSceneContent(), and pendingSceneLoad.
|
private |
| Components::Mesh * Engine::Core::SceneManager::registerGameObject | ( | Components::Mesh * | gameObject | ) |
registers a game object to the active scene
| void Engine::Core::SceneManager::setActiveScene | ( | Entities::Scene * | scene | ) |
Replaces the active scene and loads its content immediately.
| void Engine::Core::SceneManager::setAssetManager | ( | AssetManager * | manager | ) |
Sets the asset manager that will be injected into scenes.
| manager | Pointer to the AssetManager |
| void Engine::Core::SceneManager::unloadScene | ( | ) |
Unloads the current scene.
| void Engine::Core::SceneManager::unregisterGameObject | ( | const Components::Mesh * | gameObject | ) |
unregisters a game object from the active scene
| void Engine::Core::SceneManager::uploadGameObjectToMeshletMap | ( | ) |
Uploads the changed data to the buffer on the gpu. Is only one buffer.
|
private |
Definition at line 179 of file SceneManager.h.
Referenced by forEachActor(), getActiveScene(), getAllComponentsOfClassFromActors(), loadScene(), and loadScene().
|
private |
Definition at line 168 of file SceneManager.h.
Referenced by loadScene(), and loadScene().
|
private |
Definition at line 177 of file SceneManager.h.
Referenced by createMeshletToObjectMapBuffer(), and SceneManager().
|
private |
Definition at line 169 of file SceneManager.h.
Referenced by getGameObjectCount().
|
private |
Definition at line 171 of file SceneManager.h.
|
private |
Definition at line 173 of file SceneManager.h.
|
private |
Definition at line 180 of file SceneManager.h.
Referenced by loadScene(), and loadScene().