CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
ScenePartition.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-2023 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
14
15namespace CeresEngine {
16
17 class ScenePartition;
18
25 protected:
28
29 public:
31 virtual ~ScenePartition();
32
33 public:
40 [[nodiscard]] virtual SceneObject rayCast(const Ray& ray) = 0;
41
43 [[nodiscard]] SceneObject rayCast(const Vector3& origin, const Vector3& direction) { return rayCast(Ray(origin, direction)); }
44
45 protected:
47
49 virtual void rebuild() = 0;
50
52 virtual void addSceneObject(const SceneObject& sceneObject) = 0;
53
55 virtual void updateSceneObject(const SceneObject& sceneObject) = 0;
56
58 virtual void removeSceneObject(const SceneObject& sceneObject) = 0;
59 };
60
63 class ScenePartitionSystem : public System<ScenePartitionSystem, EntityObjectSet<SceneObject>> {
64 private:
67
68 public:
76
78 [[nodiscard]] SceneObject rayCast(const Vector3& origin, const Vector3& direction) { return rayCast(Ray(origin, direction)); }
79
80 private:
82 void didAdd(const SceneObject& entity) noexcept final;
83
85 void didRemove(const SceneObject& entity) noexcept final;
86
88 void didChange(const SceneObject& entity, const EntityChangeSet& changeSet) noexcept final;
89 };
90
91} // namespace CeresEngine
Partitions the scene into a highly-efficient representation that allows to quickly perform geometric ...
Definition ScenePartition.hpp:24
World & mWorld
The scene World being partitioned by the partition.
Definition ScenePartition.hpp:27
virtual void rebuild()=0
Rebuilds the scene partition after changes were done.
virtual void updateSceneObject(const SceneObject &sceneObject)=0
Updates an existing scene object on the scene partition structure.
SceneObject rayCast(const Vector3 &origin, const Vector3 &direction)
Casts a ray on the scene to find the first SceneObject that gets hit by the ray.
Definition ScenePartition.hpp:43
virtual void addSceneObject(const SceneObject &sceneObject)=0
Adds a new scene object to the scene partition structure.
virtual void removeSceneObject(const SceneObject &sceneObject)=0
Removes an existing scene object from the scene partition structure.
virtual SceneObject rayCast(const Ray &ray)=0
Casts a ray on the scene to find the first SceneObject that gets hit by the ray.
A system that connects the ECS-system with the scene partition implementation.
Definition ScenePartition.hpp:63
UPtr< ScenePartition > mScenePartition
The scene partition to be managed by the system.
Definition ScenePartition.hpp:66
void didChange(const SceneObject &entity, const EntityChangeSet &changeSet) noexcept final
SceneObject rayCast(const Ray &ray)
Casts a ray on the scene to find the first SceneObject that gets hit by the ray.
void didRemove(const SceneObject &entity) noexcept final
SceneObject rayCast(const Vector3 &origin, const Vector3 &direction)
Casts a ray on the scene to find the first SceneObject that gets hit by the ray.
Definition ScenePartition.hpp:78
void didAdd(const SceneObject &entity) noexcept final
A system is a special kind of service that is managed internally by the SystemManager.
Definition System.hpp:168
Definition World.hpp:18
Definition Application.hpp:19
std::unique_ptr< T, Deleter > UPtr
UPtr is a smart pointer that owns and manages another object through a pointer and disposes of that o...
Definition SmartPtr.hpp:28
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Entity.hpp:452