Vulkan Schnee 0.0.1
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)
 ~SceneManager ()
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 T>
std::vector< T * > getAllComponentsOfClassFromActors ()
 Gets a list of all components over all actors (EXPENSIVE!)
Components::MeshregisterGameObject (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
const Components::MeshgetGameObject (const scene_object_id id) const
const Vulkan::BuffergetMeshletToObjectBuffer () 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.
Entities::ScenegetActiveScene () const
void setActiveScene (Entities::Scene *scene)
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

AssetManagerassetManager_ = nullptr
std::vector< Components::Mesh * > gameObjects = {}
std::vector< uint32_t > gameObjectToMeshletMap {}
std::optional< Vulkan::BuffermeshletToObjectMapBuffer {}
ApplicationContextcontext = nullptr
Entities::SceneactiveScene = 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 20 of file SceneManager.h.

Constructor & Destructor Documentation

◆ SceneManager()

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

References context.

◆ ~SceneManager()

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

Member Function Documentation

◆ cleanup()

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

◆ 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 ( )

◆ executePendingSceneLoading()

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

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

◆ getActiveScene()

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

Definition at line 109 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 137 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

◆ getGameObject()

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

◆ getGameObjectCount()

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

returns the amount of objects present in the current scene

Definition at line 57 of file SceneManager.h.

References gameObjects.

◆ getGameObjects()

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

◆ getMeshletToObjectBuffer()

const Vulkan::Buffer & Engine::Core::SceneManager::getMeshletToObjectBuffer ( ) const
nodiscard

◆ 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()

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 155 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().

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)

◆ 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

Definition at line 130 of file SceneManager.h.

Referenced by getActiveScene(), getAllComponentsOfClassFromActors(), and loadScene().

◆ assetManager_

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

Definition at line 119 of file SceneManager.h.

Referenced by loadScene().

◆ context

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

Definition at line 128 of file SceneManager.h.

Referenced by createMeshletToObjectMapBuffer(), and SceneManager().

◆ gameObjects

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

Definition at line 120 of file SceneManager.h.

Referenced by getGameObjectCount().

◆ gameObjectToMeshletMap

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

Definition at line 122 of file SceneManager.h.

◆ meshletToObjectMapBuffer

std::optional<Vulkan::Buffer> Engine::Core::SceneManager::meshletToObjectMapBuffer {}
private

Definition at line 124 of file SceneManager.h.

◆ pendingSceneLoad

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

Definition at line 131 of file SceneManager.h.

Referenced by loadScene().


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