17#ifndef FOOLSENGINE_SPATIALQUERYSYSTEM_H
18#define FOOLSENGINE_SPATIALQUERYSYSTEM_H
40 class SpatialQuerySystem:
public System<SpatialQuerySystem, std::tuple<Transform, ObjectBounds>, std::tuple<SceneHierarchyData, AxisAlignedBounds>> {
42 explicit SpatialQuerySystem(std::weak_ptr<ECSWorld> world):
58 class StaticModelBoundsComputeSystem:
public System<StaticModelBoundsComputeSystem, std::tuple<std::shared_ptr<StaticModel>>, std::tuple<ObjectBounds>> {
60 explicit StaticModelBoundsComputeSystem(std::weak_ptr<ECSWorld> world):
69 static std::string
getSystemTypeName() {
return "SpatialQuerySystem::StaticModelBoundsComputeSystem"; }
100 class LightBoundsComputeSystem:
public System<LightBoundsComputeSystem, std::tuple<LightEmissionData>, std::tuple<ObjectBounds>> {
102 explicit LightBoundsComputeSystem(std::weak_ptr<ECSWorld> world):
110 static std::string
getSystemTypeName() {
return "SpatialQuerySystem::LightBoundsComputeSystem"; }
244 (void)axisAlignedBoxBounds;
245 assert(
false &&
"Cannot update a scene node's WorldBounds component");
250 assert(
false &&
"Cannot update a scene node's ObjectBounds component");
254 assert(
false &&
"Cannot remove a scene node's AABBTreeNode component");
258 assert(
false &&
"Cannot remove a scene node's ObjectBounds component");
An object containing a coarse simplified representation, AABB, of spatially queryable objects.
Definition spatial_query_math.hpp:317
void updateComponent(const TComponent &component)
Updates the value of a component of this node (to what it should be at the start of the next simulati...
Definition scene_system.hpp:1897
void setEnabled(bool state)
Sets whether or not a given system should be able to influence this scene object.
Definition scene_system.hpp:1921
void removeComponent()
Removes a component present on this node.
Definition scene_system.hpp:1911
void onEntityUpdated(EntityID entityID) override
Updates a light entity's bounds when its position or emissive properties were updated.
Definition spatial_query_system.cpp:121
void onEntityEnabled(EntityID entityID) override
Updates a light entity's bounds when it has just been made active.
Definition spatial_query_system.cpp:117
void recomputeObjectBounds(EntityID entityID)
The method responsible for actually recomputing the light entity's object bounds.
Definition spatial_query_system.cpp:125
static std::string getSystemTypeName()
Gets the system type string associated with this class.
Definition spatial_query_system.hpp:110
void onEntityEnabled(EntityID entityID) override
Computes object bounds for an entity as soon as its enabled for this system.
Definition spatial_query_system.cpp:51
void onEntityUpdated(EntityID entityID) override
Computes object bounds for an entity when it has moved or been scaled.
Definition spatial_query_system.cpp:55
static std::string getSystemTypeName()
The system type string for this class.
Definition spatial_query_system.hpp:69
void recomputeObjectBounds(EntityID entityID)
The method responsible for actually recomputing an entity's object bounds.
Definition spatial_query_system.cpp:59
std::set< EntityID > mComputeQueue
A list of entities whose AABBs should be recomputed at the next simulation step.
Definition spatial_query_system.hpp:224
std::vector< std::pair< EntityID, AxisAlignedBounds > > findEntitiesOverlapping(const AxisAlignedBounds &searchBounds) const
Returns a list of entities (by their IDs) overlapping a search AABB.
Definition spatial_query_system.cpp:35
static std::string getSystemTypeName()
Gets the system type string associated with this class.
Definition spatial_query_system.hpp:52
void rebuildOctree()
Triggers the destruction of any presently existing octree and replaces it with a new one.
Definition spatial_query_system.cpp:154
void onSimulationStep(uint32_t timestepMillis) override
Initializes the tree if necessary, and recomputes octree position for entities whose ObjectBounds wer...
Definition spatial_query_system.cpp:197
void onSimulationActivated() override
Marks this system as requiring initialization on the nearest update.
Definition spatial_query_system.cpp:193
void updateBounds(EntityID entity)
Updates the axis aligned bounds of an entity, based on its ObjectBounds.
Definition spatial_query_system.cpp:140
void onEntityEnabled(EntityID entityID) override
Marks this entity as requiring an octree update on the nearest simulation step.
Definition spatial_query_system.cpp:180
bool mRequiresInitialization
Whether a fresh Octree should be built for this system as soon as possible.
Definition spatial_query_system.hpp:230
void onEntityUpdated(EntityID entityID) override
Marks this entity as requiring an octree update on the nearest simulation step.
Definition spatial_query_system.cpp:189
std::vector< std::shared_ptr< SceneNodeCore > > findNodesOverlapping(const Ray &searchRay)
Gets a list of nodes (by their base class pointers) intersecting a search ray.
Definition spatial_query_system.cpp:8
void onEntityDisabled(EntityID entityID) override
Removes this entity from the Octree.
Definition spatial_query_system.cpp:184
std::unique_ptr< Octree > mOctree
Pointer to the octree, the data structure responsible for spatially indexing scene objects.
Definition spatial_query_system.hpp:218
A system template that disables systems with this form of declaration.
Definition ecs_world.hpp:1062
ToyMaker Engine's implementation of an ECS system.
Classes, constructors for this engine's representation of 3D models.
std::uint64_t EntityID
A single unsigned integer used as a name for an entity managed by an ECS system.
Definition ecs_world.hpp:68
A file that contains definitions for different types of lights, as components to entities,...
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition camera_system.hpp:20
System classes relating to the SceneSystem, which in some ways lies at the heart of the engine.
Data structures, functions, and methods relating to the hierarchical organization and representation ...
A component defining the true bounds of a spatially queryable object situated somewhere in the world.
Definition spatial_query_math.hpp:130
A set of numbers describing a ray with its source at some finite point in the world,...
Definition spatial_query_basic_types.hpp:374