The spatial query system, an ECS System that tracks and updates spatial query data for objects in the scene, and which exposes spatial query methods.
More...
#include <system.hpp>
|
|
| SpatialQuerySystem (std::weak_ptr< ECSWorld > world) |
| 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.
|
| std::vector< std::pair< EntityID, AxisAlignedBounds > > | findEntitiesOverlappingCoarse (const Ray &ray, InteractionLayerMask interactionMask=std::numeric_limits< InteractionLayerMask >::max()) const |
| | Returns a list of entities (by their IDs) whose AABBs intersect a search ray.
|
| 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.
|
| std::vector< std::shared_ptr< SceneNodeCore > > | findNodesOverlappingCoarse (const AxisAlignedBounds &searchBounds, InteractionLayerMask interactionMask=std::numeric_limits< InteractionLayerMask >::max()) |
| | Gets a list of nodes whose AABBs overlap some search region (in the form of an AABB).
|
|
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.
|
| 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.
|
|
void | resetBoundsOverride (EntityID entity) |
| | Allows bounds to be computed by spatial bounds compute systems.
|
|
| static std::string | getSystemTypeName () |
| | Gets the system type string associated with this class.
|
|
| void | updateBounds (EntityID entity, bool forceUpdateFromTransform=false) |
| | Updates the axis aligned bounds of an entity based on its ObjectBounds.
|
| void | updateTransform (EntityID entity) |
| | Updates the world transform of an entity based on its objects bounds.
|
|
void | rebuildOctree () |
| | Triggers the destruction of any presently existing octree and replaces it with a new one.
|
|
void | onSimulationActivated () override |
| | Marks this system as requiring initialization on the nearest update.
|
| void | onSimulationPostStep (uint32_t timestepMillis) override |
| | Initializes the tree if necessary, and recomputes octree position for entities whose ObjectBounds were updated.
|
| void | onPostTransformUpdate (uint32_t timestepMillis) override |
| | Uses latest transforms to update object bounds if required.
|
| void | onEntityEnabled (EntityID entityID) override |
| | Marks this entity as requiring an octree update on the nearest simulation step.
|
| void | onEntityDisabled (EntityID entityID) override |
| | Removes this entity from the Octree.
|
| void | onEntityUpdated (EntityID entityID, ComponentType updatedComponent) override |
| | Marks this entity as requiring an octree update on the nearest simulation step.
|
|
|
std::unique_ptr< Octree > | mOctree { nullptr } |
| | Pointer to the octree, the data structure responsible for spatially indexing scene objects.
|
|
std::set< EntityID > | mUpdateQueueAABB {} |
| | A list of entities whose AABBs should be recomputed at the next simulation step.
|
|
std::set< EntityID > | mUpdateQueueTransform {} |
| | A list of entities whose transforms should be recomputed at the next simulation step.
|
|
bool | mRequiresInitialization { true } |
| | Whether a fresh Octree should be built for this system as soon as possible.
|
The spatial query system, an ECS System that tracks and updates spatial query data for objects in the scene, and which exposes spatial query methods.
It is presently implemented as an octree, and only answers questions that take the form of a Ray or an AABB.
- Todo
- SceneHierarchyData isn't required by this system, as far as I can tell.
◆ findEntitiesOverlappingCoarse() [1/2]
Returns a list of entities (by their IDs) whose AABBs overlap a search AABB.
- Parameters
-
| searchBounds | The AABB defining the search region. |
| interactionMask | Interaction layers in which entities are being searched for |
- Returns
- std::vector<std::pair<EntityID, AxisAlignedBounds>> The list of entities overlapping with the search region.
◆ findEntitiesOverlappingCoarse() [2/2]
Returns a list of entities (by their IDs) whose AABBs intersect a search ray.
- Parameters
-
| ray | The ray intersecting which a list of entities should be found. |
| interactionMask | Interaction layers in which entities are being searched for |
- Returns
- std::vector<std::pair<EntityID, AxisAlignedBounds>> A list of entities intersected by the query ray.
◆ findNodesOverlappingCoarse() [1/2]
Gets a list of nodes whose AABBs overlap some search region (in the form of an AABB).
- Parameters
-
| searchBounds | The search region (as an AABB). |
| interactionMask | A list of layers in which entities are being searched for |
- Returns
- std::vector<std::shared_ptr<SceneNodeCore>> The list of nodes contained by or overlapping the search region.
◆ findNodesOverlappingCoarse() [2/2]
Gets a list of nodes (by their base class pointers) whose AABBs intersect a search ray.
- Parameters
-
| searchRay | The ray intersecting which a list of nodes should be found. |
| interactionMask | A list of layers in which entities are being searched for |
- Returns
- std::vector<std::shared_ptr<SceneNodeCore>> A list of nodes intersecting the search ray.
◆ getSystemTypeName()
| std::string ToyMaker::SpatialQuerySystem::getSystemTypeName |
( |
| ) |
|
|
inlinestatic |
Gets the system type string associated with this class.
- Returns
- std::string This class' system type string.
◆ onEntityDisabled()
| void SpatialQuerySystem::onEntityDisabled |
( |
EntityID | entityID | ) |
|
|
overrideprivate |
Removes this entity from the Octree.
- Parameters
-
| entityID | The entity being removed. |
◆ onEntityEnabled()
| void SpatialQuerySystem::onEntityEnabled |
( |
EntityID | entityID | ) |
|
|
overrideprivate |
Marks this entity as requiring an octree update on the nearest simulation step.
- Parameters
-
| entityID | The entity in need of an update. |
◆ onEntityUpdated()
Marks this entity as requiring an octree update on the nearest simulation step.
- Parameters
-
| entityID | The entity in need of an AABB update. |
◆ onPostTransformUpdate()
| void SpatialQuerySystem::onPostTransformUpdate |
( |
uint32_t | timestepMillis | ) |
|
|
overrideprivate |
Uses latest transforms to update object bounds if required.
- Parameters
-
| timestepMillis | The time by which the simulation will be advanced this step |
◆ onSimulationPostStep()
| void SpatialQuerySystem::onSimulationPostStep |
( |
uint32_t | timestepMillis | ) |
|
|
overrideprivate |
Initializes the tree if necessary, and recomputes octree position for entities whose ObjectBounds were updated.
- Parameters
-
| timestepMillis | The time by which the simulation will be advanced this simulation frame. |
◆ updateBounds() [1/2]
Manually updates the object bounds component of a scene object.
Does not change the value of the origin of the bounds.
◆ updateBounds() [2/2]
| void SpatialQuerySystem::updateBounds |
( |
EntityID | entity, |
|
|
bool | forceUpdateFromTransform = false ) |
|
private |
Updates the axis aligned bounds of an entity based on its ObjectBounds.
Transform-based updates are forced during spatial query system initialization.
- Parameters
-
| entity | The entity whose axis aligned bounds are being updated. |
| forceUpdateFromTransform | Whether transform should influence bounds location regardless of bounds settings |
◆ updateTransform()
| void SpatialQuerySystem::updateTransform |
( |
EntityID | entity | ) |
|
|
private |
Updates the world transform of an entity based on its objects bounds.
- Parameters
-
| entity | The entity whose transform must be updated. |
- Warning
- This works assuming that the entity has had its position updated via its ObjectBounds component. The only system (for now) which will perform such an update is the physics system.
The documentation for this class was generated from the following files:
- ToyMaker_Main/include/toymaker/engine/spatial_query/system.hpp
- ToyMaker_Main/src/spatial_query/system.cpp