Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
EngineCore::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 EngineCore::SceneManager:

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!)
MeshComponentregisterGameObject (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 MeshComponentgetGameObject (const scene_object_id id) const
const VulkanBuffergetMeshletToObjectBuffer () 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.
ScenegetActiveScene () 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

AssetManagerassetManager_ = nullptr
std::vector< MeshComponent * > gameObjects = {}
std::vector< uint32_t > gameObjectToMeshletMap {}
std::optional< VulkanBuffermeshletToObjectMapBuffer {}
ApplicationContextcontext = nullptr
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 22 of file SceneManager.h.

Constructor & Destructor Documentation

◆ SceneManager()

EngineCore::SceneManager::SceneManager ( ApplicationContext * context)
explicit

Definition at line 13 of file SceneManager.cpp.

References context, and createMeshletToObjectMapBuffer().

Here is the call graph for this function:

◆ ~SceneManager()

EngineCore::SceneManager::~SceneManager ( )

Definition at line 17 of file SceneManager.cpp.

Member Function Documentation

◆ addMeshesToMap()

void EngineCore::SceneManager::addMeshesToMap ( const std::vector< MeshComponent * > & gameObjects)
private

Definition at line 144 of file SceneManager.cpp.

References gameObjects.

◆ addMeshToMap()

void EngineCore::SceneManager::addMeshToMap ( const MeshComponent * gameObject)
private

Definition at line 140 of file SceneManager.cpp.

◆ cleanup()

void EngineCore::SceneManager::cleanup ( )

Definition at line 74 of file SceneManager.cpp.

References destroyMeshletToObjectMapBuffer(), and unloadScene().

Here is the call graph for this function:

◆ clear()

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

Here is the caller graph for this function:

◆ createMeshletToObjectMapBuffer()

void EngineCore::SceneManager::createMeshletToObjectMapBuffer ( ApplicationContext * context)
private

Definition at line 152 of file SceneManager.cpp.

References context, MAX_MESHLETS_PER_BIN, and meshletToObjectMapBuffer.

Referenced by SceneManager().

Here is the caller graph for this function:

◆ destroyMeshletToObjectMapBuffer()

void EngineCore::SceneManager::destroyMeshletToObjectMapBuffer ( )

Definition at line 164 of file SceneManager.cpp.

References meshletToObjectMapBuffer.

Referenced by cleanup().

Here is the caller graph for this function:

◆ executePendingSceneLoading()

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

Here is the call graph for this function:

◆ getActiveScene()

Scene * EngineCore::SceneManager::getActiveScene ( ) const
inlinenodiscard

Definition at line 111 of file SceneManager.h.

References activeScene.

◆ getAllActors()

std::vector< Actor * > EngineCore::SceneManager::getAllActors ( )

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

Returns
List of pointers to all actors

Definition at line 20 of file SceneManager.cpp.

References activeScene, and TRACY_ZONE_SCOPED_NAMED.

Referenced by EngineCore::RenderingDataManager::collectMaterialsFromScene().

Here is the caller graph for this function:

◆ getAllComponentsOfClassFromActors()

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

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

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

Definition at line 143 of file SceneManager.h.

References activeScene.

◆ getAllEntities()

std::vector< Entity * > EngineCore::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

Definition at line 33 of file SceneManager.cpp.

References activeScene.

◆ getGameObject()

const MeshComponent * EngineCore::SceneManager::getGameObject ( const scene_object_id id) const
nodiscard

Definition at line 63 of file SceneManager.cpp.

References gameObjects.

◆ getGameObjectCount()

uint32_t EngineCore::SceneManager::getGameObjectCount ( ) const
inlinenodiscard

returns the amount of objects present in the current scene

Definition at line 59 of file SceneManager.h.

References gameObjects.

◆ getGameObjects()

const std::vector< MeshComponent * > & EngineCore::SceneManager::getGameObjects ( ) const
nodiscard

Definition at line 59 of file SceneManager.cpp.

References gameObjects.

◆ getMeshletToObjectBuffer()

const VulkanBuffer & EngineCore::SceneManager::getMeshletToObjectBuffer ( ) const
nodiscard

Definition at line 70 of file SceneManager.cpp.

References meshletToObjectMapBuffer.

◆ isSceneChangePending()

bool EngineCore::SceneManager::isSceneChangePending ( ) const
nodiscard

Checks if a scene change has been requested.

Returns
true if a scene change is pending

Definition at line 80 of file SceneManager.cpp.

References pendingSceneLoad.

◆ loadScene()

template<typename T>
void EngineCore::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 161 of file SceneManager.h.

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

Here is the call graph for this function:

◆ loadSceneContent()

void EngineCore::SceneManager::loadSceneContent ( ) const
private

Definition at line 127 of file SceneManager.cpp.

References activeScene.

Referenced by loadScene(), and setActiveScene().

Here is the caller graph for this function:

◆ rebuildMeshMap()

void EngineCore::SceneManager::rebuildMeshMap ( )
private

Definition at line 148 of file SceneManager.cpp.

◆ registerGameObject()

MeshComponent * EngineCore::SceneManager::registerGameObject ( MeshComponent * gameObject)

registers a game object to the active scene

Definition at line 39 of file SceneManager.cpp.

References gameObjects.

◆ setActiveScene()

void EngineCore::SceneManager::setActiveScene ( Scene * scene)

Definition at line 109 of file SceneManager.cpp.

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

Here is the call graph for this function:

◆ setAssetManager()

void EngineCore::SceneManager::setAssetManager ( AssetManager * manager)

Sets the asset manager that will be injected into scenes.

Parameters
managerPointer to the AssetManager

Definition at line 123 of file SceneManager.cpp.

References assetManager_.

◆ unloadScene()

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unregisterGameObject()

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.

◆ uploadGameObjectToMeshletMap()

void EngineCore::SceneManager::uploadGameObjectToMeshletMap ( )

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

Date
2025-07-02
Author
Konstantin Passig

Definition at line 136 of file SceneManager.cpp.

References gameObjectToMeshletMap, and meshletToObjectMapBuffer.

Member Data Documentation

◆ activeScene

◆ assetManager_

AssetManager* EngineCore::SceneManager::assetManager_ = nullptr
private

Definition at line 121 of file SceneManager.h.

Referenced by loadScene(), setActiveScene(), and setAssetManager().

◆ context

ApplicationContext* EngineCore::SceneManager::context = nullptr
private

Definition at line 134 of file SceneManager.h.

Referenced by createMeshletToObjectMapBuffer(), and SceneManager().

◆ gameObjects

std::vector<MeshComponent *> EngineCore::SceneManager::gameObjects = {}
private

◆ gameObjectToMeshletMap

std::vector<uint32_t> EngineCore::SceneManager::gameObjectToMeshletMap {}
private

Definition at line 124 of file SceneManager.h.

Referenced by clear(), and uploadGameObjectToMeshletMap().

◆ meshletToObjectMapBuffer

std::optional<VulkanBuffer> EngineCore::SceneManager::meshletToObjectMapBuffer {}
private

◆ pendingSceneLoad

std::function<void()> EngineCore::SceneManager::pendingSceneLoad
private

Definition at line 137 of file SceneManager.h.

Referenced by executePendingSceneLoading(), isSceneChangePending(), and loadScene().


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