17#ifndef TOYMAKERENGINE_SPATIALQUERYSYSTEM_H
18#define TOYMAKERENGINE_SPATIALQUERYSYSTEM_H
39 class SpatialQuerySystem:
public System<SpatialQuerySystem, std::tuple<Transform, ObjectBounds>, std::tuple<AxisAlignedBounds>> {
41 explicit SpatialQuerySystem(std::weak_ptr<ECSWorld> world):
57 class StaticModelBoundsComputeSystem:
public System<StaticModelBoundsComputeSystem, std::tuple<std::shared_ptr<StaticModel>, Transform, ObjectBounds>, std::tuple<>> {
60 explicit StaticModelBoundsComputeSystem(std::weak_ptr<ECSWorld> world):
69 static std::string
getSystemTypeName() {
return "SpatialQuerySystem::StaticModelBoundsComputeSystem"; }
103 class LightBoundsComputeSystem:
public System<LightBoundsComputeSystem, std::tuple<LightEmissionData, ObjectBounds>, std::tuple<>> {
107 explicit LightBoundsComputeSystem(std::weak_ptr<ECSWorld> world):
116 static std::string
getSystemTypeName() {
return "SpatialQuerySystem::LightBoundsComputeSystem"; }
190 const glm::vec3& positionOffset,
191 const glm::quat& orientationOffset
201 const std::shared_ptr<SceneNodeCore>& sceneNode,
204 const glm::vec3& positionOffset,
205 const glm::quat& orientationOffset
207 assert(sceneNode &&
"Scene node pointer cannot be nullptr");
210 positionOffset, orientationOffset
337 (void)axisAlignedBoxBounds;
338 assert(
false &&
"Cannot update a scene node's WorldBounds component");
343 assert(
false &&
"Cannot update a scene node's ObjectBounds component");
347 assert(
false &&
"Cannot remove a scene node's AABBTreeNode component");
351 assert(
false &&
"Cannot remove a scene node's ObjectBounds component");
An object containing a coarse simplified representation, AABB, of spatially queryable objects.
Definition types.hpp:1322
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:2029
void setEnabled(bool state)
Sets whether or not a given system should be able to influence this scene object.
Definition scene_system.hpp:2053
void removeComponent()
Removes a component present on this node.
Definition scene_system.hpp:2043
void onEntityUpdated(EntityID entityID, ComponentType updatedComponent) override
Updates a light entity's bounds when its position or emissive properties were updated.
Definition system.cpp:158
void onEntityEnabled(EntityID entityID) override
Updates a light entity's bounds when it has just been made active.
Definition system.cpp:150
void recomputeObjectBounds(EntityID entityID)
The method responsible for actually recomputing the light entity's object bounds.
Definition system.cpp:174
static std::string getSystemTypeName()
Gets the system type string associated with this class.
Definition system.hpp:116
void onEntityEnabled(EntityID entityID) override
Computes object bounds for an entity as soon as its enabled for this system.
Definition system.cpp:47
static std::string getSystemTypeName()
The system type string for this class.
Definition system.hpp:69
void recomputeObjectBounds(EntityID entityID)
The method responsible for actually recomputing an entity's object bounds.
Definition system.cpp:71
void onEntityUpdated(EntityID entityID, ComponentType updatedComponent) override
Computes object bounds for an entity when it has moved or been scaled.
Definition system.cpp:55
std::set< EntityID > mUpdateQueueTransform
A list of entities whose transforms should be recomputed at the next simulation step.
Definition system.hpp:317
void onSimulationPostStep(uint32_t timestepMillis) override
Initializes the tree if necessary, and recomputes octree position for entities whose ObjectBounds wer...
Definition system.cpp:269
static std::string getSystemTypeName()
Gets the system type string associated with this class.
Definition system.hpp:51
std::vector< std::pair< EntityID, AxisAlignedBounds > > findEntitiesOverlappingCoarse(const AxisAlignedBounds &searchBounds, InteractionLayerMask interactionMask=std::numeric_limits< InteractionLayerMask >::max()) const
Returns a list of entities (by their IDs) whose AABBs overlap a search AABB.
Definition system.cpp:33
void rebuildOctree()
Triggers the destruction of any presently existing octree and replaces it with a new one.
Definition system.cpp:222
void onSimulationActivated() override
Marks this system as requiring initialization on the nearest update.
Definition system.cpp:265
void onEntityEnabled(EntityID entityID) override
Marks this entity as requiring an octree update on the nearest simulation step.
Definition system.cpp:248
void updateBoundingVolume(EntityID entity, ObjectBounds::TrueVolumeType volumeType, const ObjectBounds::TrueVolume &volume, const glm::vec3 &positionOffset, const glm::quat &orientationOffset)
Manually updates the volume component of an entity.
Definition system.cpp:301
bool mRequiresInitialization
Whether a fresh Octree should be built for this system as soon as possible.
Definition system.hpp:323
void onPostTransformUpdate(uint32_t timestepMillis) override
Uses latest transforms to update object bounds if required.
Definition system.cpp:284
void onEntityUpdated(EntityID entityID, ComponentType updatedComponent) override
Marks this entity as requiring an octree update on the nearest simulation step.
Definition system.cpp:257
std::vector< std::shared_ptr< SceneNodeCore > > findNodesOverlappingCoarse(const Ray &searchRay, InteractionLayerMask interactionMask=std::numeric_limits< InteractionLayerMask >::max())
Gets a list of nodes (by their base class pointers) whose AABBs intersect a search ray.
Definition system.cpp:7
void updateTransform(EntityID entity)
Updates the world transform of an entity based on its objects bounds.
Definition system.cpp:205
void updateBounds(const std::shared_ptr< SceneNodeCore > &sceneNode, ObjectBounds::TrueVolumeType volumeType, const ObjectBounds::TrueVolume &volume, const glm::vec3 &positionOffset, const glm::quat &orientationOffset)
Manually updates the object bounds component of a scene object.
Definition system.hpp:200
void onEntityDisabled(EntityID entityID) override
Removes this entity from the Octree.
Definition system.cpp:252
void resetBoundsOverride(EntityID entity)
Allows bounds to be computed by spatial bounds compute systems.
Definition system.cpp:351
std::set< EntityID > mUpdateQueueAABB
A list of entities whose AABBs should be recomputed at the next simulation step.
Definition system.hpp:310
std::unique_ptr< Octree > mOctree
Pointer to the octree, the data structure responsible for spatially indexing scene objects.
Definition system.hpp:303
A system template that disables systems with this form of declaration.
Definition ecs_world.hpp:1087
ToyMaker Engine's implementation of an ECS system.
ECSType ComponentType
An unsigned integer representing the type of a component.
Definition ecs_world.hpp:103
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
uint16_t InteractionLayerMask
Bit field where each bit represents an interaction layer – a physics/spatial layer that can trigger o...
Definition types.hpp:57
A file that contains definitions for different types of lights, as components to entities,...
Classes, constructors for this engine's representation of 3D models.
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition application.hpp:25
Data structures, functions, and methods relating to the hierarchical organization and representation ...
System classes relating to the SceneSystem, which in some ways lies at the heart of the engine.
A component defining the true bounds of a spatially queryable object situated somewhere in the world.
Definition types.hpp:845
TrueVolumeType
The types of volumes supported by the engine.
Definition types.hpp:857
A set of numbers describing a ray with its source at some finite point in the world,...
Definition types.hpp:447
A union of supported volume structs.
Definition types.hpp:867