2#include "../Component/MeshComponent.h"
3#include "Engine/Core/Settings.h"
4#include "Engine/Entity/Scene.h"
10using scene_object_id = uint32_t;
20 class ApplicationContext;
53 template<
typename Func>
84 [[nodiscard]]
const std::vector<Components::Mesh *> &
getGameObjects()
const;
117 template <
typename T>
185 template <
typename T>
189 std::vector<T*> outComponents;
190 for (
const auto entity :
activeScene->getEntities()) {
192 if (actor->hasComponent<T>())
194 std::vector<T*> components = actor->getComponents<T>();
195 outComponents.insert(outComponents.end(), components.begin(), components.end());
199 return outComponents;
203 template<
typename Func>
214 template <
typename T>
229 activeScene = createScene ? createScene() :
nullptr;
A component which can be attached as many times to an actor as one wants. It makes it possible to ren...
The application context is the core class which stores the basic openxr and vulkan objects.
Coordinates engine asset loading pipelines and runtime texture descriptor ownership.
ApplicationContext * context
void cleanup()
Unloads the active scene and destroys scene-manager GPU buffers.
Entities::Scene * activeScene
void clear()
Clears all game objects and resets the manager state for a new scene.
void destroyMeshletToObjectMapBuffer()
Destroys and invalidates the meshlet-to-object map buffer.
uint32_t getGameObjectCount() const
returns the amount of objects present in the current scene
void unloadScene()
Unloads the current scene.
bool isSceneChangePending() const
Checks if a scene change has been requested.
Components::Mesh * registerGameObject(Components::Mesh *gameObject)
registers a game object to the active scene
Entities::Scene * getActiveScene() const
Returns the currently active scene, or nullptr when no scene is loaded.
std::vector< Entities::Entity * > getAllEntities()
Gets a list of pointers to all entities in the current scene.
void unregisterGameObject(const Components::Mesh *gameObject)
unregisters a game object from the active scene
std::unique_ptr< Vulkan::Buffer > meshletToObjectMapBuffer
~SceneManager()
Destroys the scene manager object.
AssetManager * assetManager_
std::vector< Components::Mesh * > gameObjects
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.
Entities::SceneLightingSettings getEffectiveLightingSettings() const
Returns active-scene lighting overrides or the global lighting defaults.
std::function< void()> pendingSceneLoad
void executePendingSceneLoading()
Executes the pending scene load. Should be called between frames.
std::vector< Entities::Actor * > getAllActors()
Gets a list of pointers to all actors in the scene.
void loadSceneContent() const
void forEachActor(Func &&func) const
Calls a function for each actor in the active scene.
void loadScene()
Triggers the load of a new scene. Will be executed once the current frame has finished processing.
SceneManager(ApplicationContext *context)
Creates a scene manager and its meshlet-to-object map buffer.
std::vector< uint32_t > gameObjectToMeshletMap
std::vector< T * > getAllComponentsOfClassFromActors()
Gets a list of all components over all actors (EXPENSIVE!)
void setActiveScene(Entities::Scene *scene)
Replaces the active scene and loads its content immediately.
void createMeshletToObjectMapBuffer(ApplicationContext *context)
void uploadGameObjectToMeshletMap()
Uploads the changed data to the buffer on the gpu. Is only one buffer.
void setAssetManager(AssetManager *manager)
Sets the asset manager that will be injected into scenes.
An Actor is similar to an Engine::Entities::Entity. An actor is an Entity with a transform.
The entity class is the base class of everything which is attached to a scene. If it is part of a sce...
Owns scene entities, actor lifetime, and the scene graph root.
Scene-specific multipliers for direct and baked environment lighting.