CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Scene.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "SceneObject.hpp"
11
14
17
22
23namespace CeresEngine {
24
25 class Light;
26 class Camera;
27 class Renderable;
28
69
74
75 public: // Reflection
78 template<typename Processor> static constexpr void reflect(Processor&& RTTI) { CE_REFL_DATA(shadowSettings); }
79 };
80
83 class Scene : public TResource<Scene> {
85 friend class SceneManager;
87
88 private:
91
94 World mWorld{*this};
95
98
102
103 public:
104 using super::super;
106
107 public:
110 void update(const double dt) {
113 }
114
115 public:
117 [[nodiscard]] const SceneSettings& getSettings() const { return mSettings; }
118
121
124
126 void setRendererSettings(const RendererSceneSettings& rendererSettings);
127
129 template<CInvocable<RendererSceneSettings&> Func> decltype(auto) updateRendererSettings(Func&& func) noexcept {
132 return func(settings);
133 }
134
135 public: // Scene Objects
138
143
152 template<typename E, typename... Args> [[nodiscard]] inline E create(Args&&... args);
153
170 template<typename E, typename Block, typename... Args> inline E createWith(Block&& block, Args&&... args);
171
176
181
186
190
191 public: // Spawning
197
198 public:
201
203 [[nodiscard]] const World& getWorld() const noexcept { return mWorld; }
204
205 public:
210 [[nodiscard]] static Scene* find(const SceneObject& sceneObject);
211
212 public: // Reflection
215 template<typename Processor> static constexpr void reflect(Processor&& RTTI) {
218 }
219 };
220
221 template<typename E, typename... Args> [[nodiscard]] inline E Scene::create(Args&&... args) {
222 return mWorld.entities.create<E>(std::forward<Args>(args)...);
223 }
224
225 template<typename E, typename Block, typename... Args> inline E Scene::createWith(Block&& block, Args&&... args) {
226 return mWorld.entities.createWith<E>(std::forward<Block>(block), std::forward<Args>(args)...);
227 }
228
231 friend class Scene;
232
233 private:
236
237 public:
239 void add(const HScene& scene) { add(scene.get()); }
240
242 void add(const ScenePtr& scene) { add(scene.get()); }
243
245 void add(Scene* const scene);
246
248 void remove(const HScene& scene) { remove(scene.get()); }
249
251 void remove(const ScenePtr& scene) { remove(scene.get()); }
252
254 void remove(Scene* const scene);
255
258 void simulate(double dt);
259 };
260
261} // namespace CeresEngine
262
265
268
#define CE_ENTITY_OBJECT_HASH(T)
Definition Entity.hpp:784
#define CE_REFLECT_HASH(T)
Definition Hash.hpp:89
#define CE_REFL_DATA_GETSET(N, G, S)
Definition Macros.hpp:549
#define CE_REFL_DATA(N)
Definition Macros.hpp:541
#define CE_META_CLASS_FRIEND(T)
Definition Forward.hpp:48
Definition Camera.hpp:247
The base entity class.
Definition Entity.hpp:41
E createWith(Block &&block, Args &&... args)
Creates a new entity object with type E.
Entity create(const Entity &parent=nullEntity, String name={})
Creates a new entity.
void update()
A method that must be called every frame by the engine to trigger runtime events.
A generator represents a coroutine type that produces a sequence of values of type T,...
Definition Generator.hpp:50
A scene light.
Definition Light.hpp:275
Definition Renderable.hpp:109
T * get() const noexcept
Definition ResourceHandle.hpp:231
A resource that stores scene information.
Definition Scene.hpp:83
static Scene * find(const SceneObject &sceneObject)
Finds the scene that a scene object is attached to.
Renderable createRenderable()
Creates a new renderable on the scene.
const RendererSceneSettings & getRendererSettings() const
Definition Scene.hpp:123
World & getWorld() noexcept
The Entity-Component system world.
Definition Scene.hpp:200
static constexpr void reflect(Processor &&RTTI)
Executes the given processor for every field of the struct.
Definition Scene.hpp:215
Entity copyObjects(Scene &otherScene, const Entity &parent=nullptr)
Copies the objects from another scene.
World mWorld
The Entity-Component system world.
Definition Scene.hpp:94
void setSettings(const SceneSettings &settings)
RendererSceneSettings mRendererSettings
A set of settings that should be used by renderer when rendering the scene.
Definition Scene.hpp:101
Light createLight()
Creates a new light on the scene.
Vector< SceneObject > create(UInt32 n)
Creates n empty SceneObjects.
Camera createCamera()
Creates a new camera on the scene.
SceneSettings mSettings
A structure that contains settings for the scene.
Definition Scene.hpp:97
~Scene() noexcept override
const SceneSettings & getSettings() const
Definition Scene.hpp:117
E createWith(Block &&block, Args &&... args)
Creates a new SceneObject with type E.
Definition Scene.hpp:225
Generator< SceneObject > enumerateChildren() const
Enumerates all children scene objects.
void update(const double dt)
Runs a single simulation step on the world.
Definition Scene.hpp:110
decltype(auto) updateRendererSettings(Func &&func) noexcept
Definition Scene.hpp:129
SceneObject create()
Creates a new empty SceneObject.
const World & getWorld() const noexcept
The Entity-Component system world.
Definition Scene.hpp:203
void setRendererSettings(const RendererSceneSettings &rendererSettings)
SceneManager * mSceneManager
The scene manager this scene is registered to, if registered.
Definition Scene.hpp:90
A manager that references and manages mutliple scenes.
Definition Scene.hpp:230
void remove(Scene *const scene)
Removes a scene from the manager.
void remove(const ScenePtr &scene)
Adds a new scene to the manager.
Definition Scene.hpp:251
void remove(const HScene &scene)
Removes a scene from the manager.
Definition Scene.hpp:248
Vector< Scene * > mScenes
A vector of all registered scenes.
Definition Scene.hpp:235
void add(const ScenePtr &scene)
Adds a new scene to the manager.
Definition Scene.hpp:242
void add(Scene *const scene)
Adds a new scene to the manager.
void simulate(double dt)
Simulates all scenes registered.
void add(const HScene &scene)
Adds a new scene to the manager.
Definition Scene.hpp:239
void update(double time)
Updates all systems.
Utility template class that can be extended by Resources to automatically implement methods that are ...
Definition Resource.hpp:272
Definition World.hpp:18
SystemManager systems
The world system manager.
Definition World.hpp:34
EntityManager entities
The world entity manager.
Definition World.hpp:30
Definition Application.hpp:19
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
auto parent(const Entity &parent)
Sets the entity parent.
Definition Helpers.hpp:52
SPtr< Scene > ScenePtr
Definition Forward.hpp:16
std::uint32_t UInt32
Definition DataTypes.hpp:23
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
A structure that holds renderer-specific settings for a Scene.
Definition RendererSceneSettings.hpp:15
A structure that contains settings for the scene.
Definition Scene.hpp:71
static constexpr void reflect(Processor &&RTTI)
Executes the given processor for every field of the struct.
Definition Scene.hpp:78
ShadowSettings shadowSettings
Various options that control shadow rendering for a specific view.
Definition Scene.hpp:73
Definition ScopeExit.hpp:15
Various options that control shadow rendering for a specific view.
Definition Scene.hpp:30
static constexpr void reflect(Processor &&RTTI)
Executes the given processor for every field of the struct.
Definition Scene.hpp:62
double cascadeDistributionExponent
Allows you to control how are directional shadow cascades distributed.
Definition Scene.hpp:52
UInt32 shadowFilteringQuality
Determines the number of samples used for percentage closer shadow map filtering.
Definition Scene.hpp:57
double directionalShadowDistance
Maximum distance that directional light shadows are allowed to render at.
Definition Scene.hpp:35
UInt32 numberOfCascades
Number of cascades to use for directional shadows.
Definition Scene.hpp:42