Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Entities::Scene Class Reference

A scene is the overarching structure which can spawn, contain and destroy actors or entities. More...

#include <Scene.h>

Inheritance diagram for Engine::Entities::Scene:
Collaboration diagram for Engine::Entities::Scene:

Public Member Functions

 Scene ()
 ~Scene () override
template<typename T, typename... Args>
T * spawnActor (const Ecs::Transform &spawnTransform, Args &&... args)
 Spawns an actor from a specific class in somewhere into the scene.
void destroyActor (Entities::Actor *actor)
void destroyActorImmediate (Entities::Actor *actor)
void flushPendingActorDestruction ()
virtual void loadContent ()
virtual void unloadContent ()
std::vector< Entities::Entity * > getEntities () const
void reserveActorCapacity (size_t additionalActors)
 Reserves storage for a known number of upcoming actor spawns.
void cleanup ()
Core::SceneManagergetSceneManager () const
Core::AssetManagergetAssetManager () const
 Gets the asset manager for this scene.
Core::AssetRegistrygetAssetRegistry () const
void setAssetManager (Core::AssetManager *manager)
 Sets the asset manager for this scene (used for dependency injection in tests)
void setAssetRegistry (Core::AssetRegistry *registry)
EngineKerngetEngine () const
 Gets the engine instance for this scene.
SceneGraphgetSceneGraph () const
Public Member Functions inherited from Engine::Core::ITickable
virtual ~ITickable ()=default
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 all meshes from a GLTF file into the scene.
template<typename ActorT = StaticMeshActor>
static std::vector< ActorT * > spawnAll (Scene *scene, Assets::GltfHandle gltf)

Protected Attributes

EngineKernengine_ = nullptr
Core::AssetManagerassetManager = nullptr
Core::AssetRegistryassetRegistry = nullptr

Private Attributes

std::unique_ptr< SceneGraphsceneGraph
std::vector< Entity * > entities
std::vector< Actor * > pendingDestroyActors_

Detailed Description

A scene is the overarching structure which can spawn, contain and destroy actors or entities.

Definition at line 62 of file Scene.h.

Constructor & Destructor Documentation

◆ Scene()

Engine::Entities::Scene::Scene ( )

Referenced by spawnAll(), and spawnAll().

Here is the caller graph for this function:

◆ ~Scene()

Engine::Entities::Scene::~Scene ( )
override

Member Function Documentation

◆ cleanup()

void Engine::Entities::Scene::cleanup ( )

◆ destroyActor()

void Engine::Entities::Scene::destroyActor ( Entities::Actor * actor)

◆ destroyActorImmediate()

void Engine::Entities::Scene::destroyActorImmediate ( Entities::Actor * actor)

◆ flushPendingActorDestruction()

void Engine::Entities::Scene::flushPendingActorDestruction ( )

◆ getAssetManager()

Core::AssetManager * Engine::Entities::Scene::getAssetManager ( ) const
nodiscard

Gets the asset manager for this scene.

Returns
Pointer to the AssetManager, or nullptr if not set

◆ getAssetRegistry()

Core::AssetRegistry * Engine::Entities::Scene::getAssetRegistry ( ) const
nodiscard

Referenced by spawnAll().

Here is the caller graph for this function:

◆ getEngine()

EngineKern * Engine::Entities::Scene::getEngine ( ) const
inlinenodiscard

Gets the engine instance for this scene.

Returns
Pointer to the Engine, or nullptr if not set

Definition at line 221 of file Scene.h.

References engine_.

◆ getEntities()

std::vector< Entities::Entity * > Engine::Entities::Scene::getEntities ( ) const
nodiscard

◆ getSceneGraph()

SceneGraph * Engine::Entities::Scene::getSceneGraph ( ) const
inlinenodiscard

Definition at line 222 of file Scene.h.

References sceneGraph.

◆ getSceneManager()

Core::SceneManager * Engine::Entities::Scene::getSceneManager ( ) const
nodiscard

◆ loadContent()

virtual void Engine::Entities::Scene::loadContent ( )
virtual

◆ reserveActorCapacity()

void Engine::Entities::Scene::reserveActorCapacity ( size_t additionalActors)

Reserves storage for a known number of upcoming actor spawns.

◆ setAssetManager()

void Engine::Entities::Scene::setAssetManager ( Core::AssetManager * manager)

Sets the asset manager for this scene (used for dependency injection in tests)

Parameters
managerPointer to the AssetManager

◆ setAssetRegistry()

void Engine::Entities::Scene::setAssetRegistry ( Core::AssetRegistry * registry)

◆ spawnActor()

template<typename T, typename... Args>
T * Engine::Entities::Scene::spawnActor ( const Ecs::Transform & spawnTransform,
Args &&... args )
inline

Spawns an actor from a specific class in somewhere into the scene.

Parameters
spawnTransformwhere the actor should be placed into the world
argsArguments
Returns
The spawned actor in the provided class
Template Parameters
ArgsArguments

Definition at line 78 of file Scene.h.

References entities, sceneGraph, and TRACY_ZONE_SCOPED_NAMED.

Referenced by spawnAll(), and spawnAll().

Here is the caller graph for this function:

◆ spawnAll() [1/2]

template<typename ActorT = StaticMeshActor>
std::vector< ActorT * > Engine::Entities::Scene::spawnAll ( Scene * scene,
Assets::GltfHandle gltf )
inlinestatic

◆ spawnAll() [2/2]

template<typename ActorT = StaticMeshActor>
std::vector< ActorT * > Engine::Entities::Scene::spawnAll ( Scene * scene,
const std::filesystem::path & gltfPath )
inlinestatic

Spawns all meshes from a GLTF file into the scene.

Each mesh in the GLTF file becomes a separate actor of type ActorT, positioned using the transform from the GLTF file.

Template Parameters
ActorTActor type to spawn (default: StaticMeshActor)
Parameters
sceneThe scene to spawn actors into
gltfPathPath to the GLTF/GLB file
Returns
Vector of spawned actor pointers

Definition at line 118 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().

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

◆ unloadContent()

virtual void Engine::Entities::Scene::unloadContent ( )
virtual

Member Data Documentation

◆ assetManager

Core::AssetManager* Engine::Entities::Scene::assetManager = nullptr
protected

Definition at line 226 of file Scene.h.

◆ assetRegistry

Core::AssetRegistry* Engine::Entities::Scene::assetRegistry = nullptr
protected

Definition at line 227 of file Scene.h.

◆ engine_

EngineKern* Engine::Entities::Scene::engine_ = nullptr
protected

Definition at line 225 of file Scene.h.

Referenced by getEngine().

◆ entities

std::vector<Entity*> Engine::Entities::Scene::entities
private

Definition at line 232 of file Scene.h.

Referenced by spawnActor().

◆ pendingDestroyActors_

std::vector<Actor*> Engine::Entities::Scene::pendingDestroyActors_
private

Definition at line 233 of file Scene.h.

◆ sceneGraph

std::unique_ptr<SceneGraph> Engine::Entities::Scene::sceneGraph
private

Definition at line 230 of file Scene.h.

Referenced by getSceneGraph(), and spawnActor().


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