|
Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
|
Owns scene entities, actor lifetime, and the scene graph root. More...
#include <Scene.h>
Public Member Functions | |
| Scene () | |
| Creates a scene with an empty scene graph. | |
| ~Scene () override | |
| Cleans up all scene-owned entities and actors. | |
| template<class T, typename... Args> | |
| T * | spawnEntity (Args &&... args) |
| Creates an entity owned by this scene. | |
| void | destroyEntity (Entity *entity) |
| Queues an entity for destruction. | |
| template<class T, typename... Args> | |
| T * | spawnActor (const Ecs::Transform &spawnTransform, Args &&... args) |
| Creates an actor at a world transform and calls beginPlay(). | |
| template<typename T, typename... Args> | |
| T * | spawnActorAttached (const Ecs::Transform &localTransform, Actor &parent, Args &&... args) |
| Creates an actor under another actor's scene node. | |
| template<typename T, typename... Args> | |
| T * | spawnActorAttached (const Ecs::Transform &localTransform, const std::shared_ptr< SceneNode > &parentNode, Args &&... args) |
| Creates an actor under a scene node. | |
| void | destroyActor (Entities::Actor *actor) |
| Queues an actor for destruction after the current tick. | |
| void | destroyActorImmediate (Entities::Actor *actor) |
| Destroys an actor now and calls endPlay() if needed. | |
| void | flushPendingActorDestruction () |
| Destroys all actors queued by destroyActor(). | |
| void | flushPendingEntityDestruction () |
| Destroys all entities queued for destruction. | |
| virtual void | loadContent () |
| Loads scene content. Override in derived scenes. | |
| virtual void | unloadContent () |
| Releases scene content. Override in derived scenes. | |
| std::vector< Entities::Entity * > | getEntities () const |
| Returns the scene-owned entities. | |
| template<typename Func> | |
| void | forEachEntity (Func &&func) const |
| Invokes a callback for each scene-owned entity. | |
| EntityContainer & | getEntityContainer () |
| Returns the mutable scene entity container. | |
| const EntityContainer & | getEntityContainer () const |
| Returns the read-only scene entity container. | |
| void | reserveActorCapacity (size_t additionalActors) |
| Reserves storage for upcoming actor spawns. | |
| void | cleanup () |
| Destroys all scene-owned entities and clears pending actor destruction. | |
| Core::SceneManager * | getSceneManager () const |
| Returns the scene manager from the active engine. | |
| Core::AssetManager * | getAssetManager () const |
| Returns the asset manager assigned to this scene. | |
| Core::AssetRegistry * | getAssetRegistry () const |
| Returns the asset registry assigned to this scene. | |
| void | setAssetManager (Core::AssetManager *manager) |
| Sets the asset manager for this scene. | |
| void | setAssetRegistry (Core::AssetRegistry *registry) |
| Sets the asset registry for this scene. | |
| SceneGraph * | getSceneGraph () const |
| Returns the scene graph owned by this scene. | |
| void | setLightingOverride (const SceneLightingSettings &settings) |
| Enables scene-specific lighting values. | |
| void | clearLightingOverride () |
| Disables scene-specific lighting and restores the global defaults. | |
| bool | hasLightingOverride () const |
| SceneLightingSettings * | getLightingOverride () |
| const SceneLightingSettings * | getLightingOverride () const |
| Public Member Functions inherited from Engine::Core::ITickable | |
| virtual | ~ITickable ()=default |
| Destroys a tickable object. | |
| virtual void | preTick () |
| Function which executes immediately before the execution of ITickable::preTick() | |
| virtual void | tick (double deltaTimeSeconds) |
| Function called each frame when a tick component has been registered with EnTT Ecs::Tick. | |
| virtual void | postTick () |
| Function which executes immediately after the execution of ITickable::postTick() | |
Static Public Member Functions | |
| template<typename ActorT = StaticMeshActor> | |
| static std::vector< ActorT * > | spawnAll (Scene *scene, const std::filesystem::path &gltfPath) |
| Spawns one actor for each mesh node in a GLTF file. | |
| template<typename ActorT = StaticMeshActor> | |
| static std::vector< ActorT * > | spawnAll (Scene *scene, Assets::GltfHandle gltf) |
| Spawns one actor for each mesh node in a loaded GLTF asset. | |
Protected Attributes | |
| Core::AssetManager * | assetManager = nullptr |
| Asset manager assigned to this scene. | |
| Core::AssetRegistry * | assetRegistry = nullptr |
| Asset registry assigned to this scene. | |
Private Attributes | |
| std::unique_ptr< SceneGraph > | sceneGraph |
| EntityContainer | entities_ |
| std::optional< SceneLightingSettings > | lightingOverride_ |
Owns scene entities, actor lifetime, and the scene graph root.
Derive from Scene for level-specific content. Override loadContent(), tick(), and unloadContent() as needed.
| Engine::Entities::Scene::Scene | ( | ) |
Creates a scene with an empty scene graph.
Referenced by spawnAll(), and spawnAll().
|
override |
Cleans up all scene-owned entities and actors.
| void Engine::Entities::Scene::cleanup | ( | ) |
Destroys all scene-owned entities and clears pending actor destruction.
|
inline |
Disables scene-specific lighting and restores the global defaults.
Definition at line 403 of file Scene.h.
References lightingOverride_.
| void Engine::Entities::Scene::destroyActor | ( | Entities::Actor * | actor | ) |
Queues an actor for destruction after the current tick.
| actor | Scene-owned actor to destroy. Null is ignored. |
| void Engine::Entities::Scene::destroyActorImmediate | ( | Entities::Actor * | actor | ) |
Destroys an actor now and calls endPlay() if needed.
| actor | Scene-owned actor to destroy. Null is ignored. |
| void Engine::Entities::Scene::destroyEntity | ( | Entity * | entity | ) |
Queues an entity for destruction.
| entity | Scene-owned entity to destroy. Null is ignored. |
| void Engine::Entities::Scene::flushPendingActorDestruction | ( | ) |
Destroys all actors queued by destroyActor().
| void Engine::Entities::Scene::flushPendingEntityDestruction | ( | ) |
Destroys all entities queued for destruction.
|
inline |
|
nodiscard |
Returns the asset manager assigned to this scene.
|
nodiscard |
Returns the asset registry assigned to this scene.
Referenced by spawnAll().
|
nodiscard |
Returns the scene-owned entities.
|
nodiscard |
Returns the mutable scene entity container.
|
nodiscard |
Returns the read-only scene entity container.
|
inlinenodiscard |
Definition at line 406 of file Scene.h.
References lightingOverride_.
|
inlinenodiscard |
Definition at line 410 of file Scene.h.
References lightingOverride_.
|
inlinenodiscard |
Returns the scene graph owned by this scene.
Definition at line 393 of file Scene.h.
References sceneGraph.
|
nodiscard |
Returns the scene manager from the active engine.
|
inlinenodiscard |
Definition at line 405 of file Scene.h.
References lightingOverride_.
|
virtual |
Loads scene content. Override in derived scenes.
| void Engine::Entities::Scene::reserveActorCapacity | ( | size_t | additionalActors | ) |
Reserves storage for upcoming actor spawns.
| additionalActors | Number of additional actors expected. |
| void Engine::Entities::Scene::setAssetManager | ( | Core::AssetManager * | manager | ) |
Sets the asset manager for this scene.
| manager | Asset manager pointer. May be null. |
| void Engine::Entities::Scene::setAssetRegistry | ( | Core::AssetRegistry * | registry | ) |
Sets the asset registry for this scene.
| registry | Asset registry pointer. May be null. |
|
inline |
Enables scene-specific lighting values.
Definition at line 398 of file Scene.h.
References lightingOverride_.
|
inline |
Creates an actor at a world transform and calls beginPlay().
| T | Actor type. Must derive from Actor and accept SpawnContext first. |
| spawnTransform | Initial world transform. |
| args | Arguments forwarded after SpawnContext. |
Definition at line 125 of file Scene.h.
References entities_, and sceneGraph.
Referenced by spawnAll(), and spawnAll().
|
inline |
Creates an actor under another actor's scene node.
| T | Actor type. Must derive from Actor and accept SpawnContext first. |
| localTransform | Initial transform relative to parent. |
| parent | Parent actor. |
| args | Arguments forwarded after SpawnContext. |
Definition at line 159 of file Scene.h.
References Engine::Entities::Actor::getSceneNode(), and spawnActorAttached().
Referenced by spawnActorAttached().
|
inline |
Creates an actor under a scene node.
| T | Actor type. Must derive from Actor and accept SpawnContext first. |
| localTransform | Initial transform relative to parentNode. |
| parentNode | Parent scene node. Must not be null. |
| args | Arguments forwarded after SpawnContext. |
Definition at line 176 of file Scene.h.
References Engine::Entities::NodeFactory::createNode(), entities_, Engine::Ecs::Transform::matrix, and sceneGraph.
|
inlinestatic |
Spawns one actor for each mesh node in a loaded GLTF asset.
| ActorT | Actor type to spawn. Defaults to StaticMeshActor. |
| scene | Scene that owns the spawned actors and provides the asset registry. |
| gltf | Loaded GLTF asset handle. |
Definition at line 251 of file Scene.h.
References Engine::Entities::detail::applyGltfNodeExtensions(), Engine::Entities::detail::GltfSpawnNode::geometryMesh, Engine::Entities::detail::GltfSpawnPlan::meshNodes, Engine::Entities::detail::GltfSpawnNode::meshPath, Engine::Entities::detail::prepareGltfSpawnPlan(), Engine::Entities::detail::GltfSpawnNode::renderable, Scene(), spawnActor(), and Engine::Entities::detail::GltfSpawnNode::transform.
|
inlinestatic |
Spawns one actor for each mesh node in a GLTF file.
Each actor receives the mesh node's world transform. GLTF light, collision, and probe extensions are applied when present.
| ActorT | Actor type to spawn. Defaults to StaticMeshActor. |
| scene | Non-null scene that owns the spawned actors. |
| gltfPath | Path to the GLTF/GLB asset. |
Definition at line 219 of file Scene.h.
References Engine::Entities::detail::applyGltfNodeExtensions(), getAssetRegistry(), Engine::Core::AssetRegistry::gltfs(), Engine::Core::GltfStore::load(), Engine::Entities::detail::GltfSpawnPlan::meshNodes, Engine::Entities::detail::GltfSpawnNode::meshPath, Engine::Entities::detail::prepareGltfSpawnPlan(), Scene(), spawnActor(), spawnAll(), and Engine::Entities::detail::GltfSpawnNode::transform.
Referenced by Engine::Entities::GltfSpawner::spawnAll(), Engine::Entities::GltfSpawner::spawnAll(), and spawnAll().
|
inline |
|
virtual |
Releases scene content. Override in derived scenes.
|
protected |
|
protected |
|
private |
Definition at line 422 of file Scene.h.
Referenced by forEachEntity(), spawnActor(), spawnActorAttached(), and spawnEntity().
|
private |
Definition at line 423 of file Scene.h.
Referenced by clearLightingOverride(), getLightingOverride(), getLightingOverride(), hasLightingOverride(), and setLightingOverride().
|
private |
Definition at line 420 of file Scene.h.
Referenced by getSceneGraph(), spawnActor(), and spawnActorAttached().