11#ifndef TOYMAKERENGINE_SPATIALQUERYSWEEPPRUNE_H
12#define TOYMAKERENGINE_SPATIALQUERYSWEEPPRUNE_H
50 assert(
first !=
second &&
"Entities in constraint must be distinct");
112 using EdgeIndex = std::size_t;
125 std::array<std::pair<EdgeIndex, EdgeIndex>, 3> mIndices {};
140 inline bool operator<(
const Edge& other) {
142 mValue < other.mValue || (
143 mValue == other.mValue
144 && mEntity < other.mEntity
146 mValue == other.mValue
147 && mEntity == other.mEntity
148 && mBegin > other.mBegin
189 std::array<std::vector<Edge>, 3>
mEdges {};
An object containing a coarse simplified representation, AABB, of spatially queryable objects.
Definition types.hpp:1403
Names two distinct entities participating in a collision, with their entity IDs sorted in ascending o...
Definition sweep_prune.hpp:29
EntityID second() const
Returns the second entity in the link.
Definition sweep_prune.hpp:66
EntityID mFirst
The first entity in a constraint link.
Definition sweep_prune.hpp:35
EntityID first() const
Returns the first entity in the link.
Definition sweep_prune.hpp:60
CollisionPair(EntityID first, EntityID second)
Creates a collision pair out of two distinct entities, where the first entity's ID is lesser than the...
Definition sweep_prune.hpp:49
EntityID mSecond
The second entity in a constraint link.
Definition sweep_prune.hpp:41
A class designed around finding which pairs of AABBs may be intersecting (so as to limit the number o...
Definition sweep_prune.hpp:85
std::set< CollisionPair > mCollisionPairs
Storage for all detected collision pairs.
Definition sweep_prune.hpp:183
void updateObject(EntityID entity, const AxisAlignedBounds &bounds)
Definition sweep_prune.cpp:79
void sortEdges()
Sorts edges along every axis.
Definition sweep_prune.cpp:96
void removeObject(EntityID entity)
Removes an object from Sweep and Prune's tracking lists.
Definition sweep_prune.cpp:60
std::set< CollisionPair > getCollisionPairs()
Returns all collision pairs that have been detected thus far.
Definition sweep_prune.cpp:6
std::array< std::set< CollisionPair >, 3 > mOverlaps
Pairs of entities which are overlapping on each axis.
Definition sweep_prune.hpp:195
void findCollisionPairs()
Scans edge lists to find likely collision pairs.
Definition sweep_prune.cpp:137
void addObject(EntityID entity, const AxisAlignedBounds &bounds)
Adds an object for sweep and prune to track.
Definition sweep_prune.cpp:13
std::array< std::vector< Edge >, 3 > mEdges
Sorted list of edges along each axis.
Definition sweep_prune.hpp:189
std::unordered_map< EntityID, Object > mObjects
Indices into edge lists for each axis per entity.
Definition sweep_prune.hpp:177
bool mRecomputeCollisions
Whether collision pairs need to be recomputed, as they would after an update.
Definition sweep_prune.hpp:201
ToyMaker Engine's implementation of an ECS system.
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
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition application.hpp:25
Classes and structs representing data related to the engine's spatial query system (the precursor to ...
Represents the projection of a bounding box along the axis represented by the edge list that this ite...
Definition sweep_prune.hpp:135
Contains the start and end indices of a sweep and prune object in each dimension's edge list.
Definition sweep_prune.hpp:124