Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Core::SceneManager Class Reference

Manages game objects within a scene, handling registration, ID allocation, and GPU buffer synchronization for meshlet-to-object mappings. More...

#include <SceneManager.h>

Collaboration diagram for Engine::Core::SceneManager:

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ SceneManager()

Engine::Core::SceneManager::SceneManager ( ApplicationContext * context)
explicit

Creates a scene manager and its meshlet-to-object map buffer.

References context.

◆ ~SceneManager()

Engine::Core::SceneManager::~SceneManager ( )

Destroys the scene manager object.

Member Function Documentation

◆ cleanup()

void Engine::Core::SceneManager::cleanup ( )

Unloads the active scene and destroys scene-manager GPU buffers.

◆ clear()

void Engine::Core::SceneManager::clear ( )

Clears all game objects and resets the manager state for a new scene.

◆ createMeshletToObjectMapBuffer()

void Engine::Core::SceneManager::createMeshletToObjectMapBuffer ( ApplicationContext * context)
private

References context.

◆ destroyMeshletToObjectMapBuffer()

void Engine::Core::SceneManager::destroyMeshletToObjectMapBuffer ( )

Destroys and invalidates the meshlet-to-object map buffer.

◆ executePendingSceneLoading()

void Engine::Core::SceneManager::executePendingSceneLoading ( )

Executes the pending scene load. Should be called between frames.

◆ forEachActor()

template<typename Func>
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.

◆ getActiveScene()

Entities::Scene * Engine::Core::SceneManager::getActiveScene ( ) const
inlinenodiscard

Returns the currently active scene, or nullptr when no scene is loaded.

Definition at line 149 of file SceneManager.h.

References activeScene.

◆ getAllActors()

std::vector< Entities::Actor * > Engine::Core::SceneManager::getAllActors ( )

Gets a list of pointers to all actors in the scene.

Returns
List of pointers to all actors

◆ getAllComponentsOfClassFromActors()

template<typename T>
std::vector< T * > Engine::Core::SceneManager::getAllComponentsOfClassFromActors ( )

Gets a list of all components over all actors (EXPENSIVE!)

Template Parameters
TType of the component. Has to be a subclass of Engine::Core::LogicComponent
Returns
a list of all components of a certain class from all actors (expensive)

Definition at line 186 of file SceneManager.h.

References activeScene.

◆ getAllEntities()

std::vector< Entities::Entity * > Engine::Core::SceneManager::getAllEntities ( )

Gets a list of pointers to all entities in the current scene.

Returns
list of pointers to all entities in the current scene

◆ getEffectiveLightingSettings()

Entities::SceneLightingSettings Engine::Core::SceneManager::getEffectiveLightingSettings ( ) const
nodiscard

Returns active-scene lighting overrides or the global lighting defaults.

◆ getGameObject()

const Components::Mesh * Engine::Core::SceneManager::getGameObject ( const scene_object_id id) const
nodiscard

Returns a registered mesh component by scene object ID, or nullptr when out of range.

◆ getGameObjectCount()

uint32_t Engine::Core::SceneManager::getGameObjectCount ( ) const
inlinenodiscard

returns the amount of objects present in the current scene

Definition at line 76 of file SceneManager.h.

References gameObjects.

◆ getGameObjects()

const std::vector< Components::Mesh * > & Engine::Core::SceneManager::getGameObjects ( ) const
nodiscard

Returns the registered mesh components for the active scene.

◆ isSceneChangePending()

bool Engine::Core::SceneManager::isSceneChangePending ( ) const
nodiscard

Checks if a scene change has been requested.

Returns
true if a scene change is pending

◆ loadScene() [1/2]

template<typename T>
void Engine::Core::SceneManager::loadScene ( )

Triggers the load of a new scene. Will be executed once the current frame has finished processing.

Template Parameters
TType of the scene to load. Has to be child of EngineCore::Scene
Author
Konstantin Passig
Date
10.12.2025

Definition at line 215 of file SceneManager.h.

References activeScene, assetManager_, loadSceneContent(), and pendingSceneLoad.

Here is the call graph for this function:

◆ loadScene() [2/2]

void Engine::Core::SceneManager::loadScene ( std::function< Entities::Scene *()> createScene)
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.

Here is the call graph for this function:

◆ loadSceneContent()

void Engine::Core::SceneManager::loadSceneContent ( ) const
private

Referenced by loadScene(), and loadScene().

Here is the caller graph for this function:

◆ registerGameObject()

Components::Mesh * Engine::Core::SceneManager::registerGameObject ( Components::Mesh * gameObject)

registers a game object to the active scene

◆ setActiveScene()

void Engine::Core::SceneManager::setActiveScene ( Entities::Scene * scene)

Replaces the active scene and loads its content immediately.

◆ setAssetManager()

void Engine::Core::SceneManager::setAssetManager ( AssetManager * manager)

Sets the asset manager that will be injected into scenes.

Parameters
managerPointer to the AssetManager

◆ unloadScene()

void Engine::Core::SceneManager::unloadScene ( )

Unloads the current scene.

◆ unregisterGameObject()

void Engine::Core::SceneManager::unregisterGameObject ( const Components::Mesh * gameObject)

unregisters a game object from the active scene

◆ uploadGameObjectToMeshletMap()

void Engine::Core::SceneManager::uploadGameObjectToMeshletMap ( )

Uploads the changed data to the buffer on the gpu. Is only one buffer.

Date
2025-07-02
Author
Konstantin Passig

Member Data Documentation

◆ activeScene

Entities::Scene* Engine::Core::SceneManager::activeScene = nullptr
private

◆ assetManager_

AssetManager* Engine::Core::SceneManager::assetManager_ = nullptr
private

Definition at line 168 of file SceneManager.h.

Referenced by loadScene(), and loadScene().

◆ context

ApplicationContext* Engine::Core::SceneManager::context = nullptr
private

Definition at line 177 of file SceneManager.h.

Referenced by createMeshletToObjectMapBuffer(), and SceneManager().

◆ gameObjects

std::vector<Components::Mesh *> Engine::Core::SceneManager::gameObjects = {}
private

Definition at line 169 of file SceneManager.h.

Referenced by getGameObjectCount().

◆ gameObjectToMeshletMap

std::vector<uint32_t> Engine::Core::SceneManager::gameObjectToMeshletMap {}
private

Definition at line 171 of file SceneManager.h.

◆ meshletToObjectMapBuffer

std::unique_ptr<Vulkan::Buffer> Engine::Core::SceneManager::meshletToObjectMapBuffer
private

Definition at line 173 of file SceneManager.h.

◆ pendingSceneLoad

std::function<void()> Engine::Core::SceneManager::pendingSceneLoad
private

Definition at line 180 of file SceneManager.h.

Referenced by loadScene(), and loadScene().


The documentation for this class was generated from the following file:
  • /workspace/magerbeton/gl3-vulkan/code/Engine/include/Engine/World/SceneManager.h