ToyMaker Game Engine 0.0.2
ToyMaker is a game engine developed and maintained by Zoheb Shujauddin.
Loading...
Searching...
No Matches
ToyMaker::SweepPrune Class Reference

A class designed around finding which pairs of AABBs may be intersecting (so as to limit the number of full collision checks that need be performed). More...

#include <sweep_prune.hpp>

Classes

struct  Object
 Contains the start and end indices of a sweep and prune object in each dimension's edge list. More...
struct  Edge
 Represents the projection of a bounding box along the axis represented by the edge list that this item appears in. More...

Public Member Functions

std::set< CollisionPairgetCollisionPairs ()
 Returns all collision pairs that have been detected thus far.
void addObject (EntityID entity, const AxisAlignedBounds &bounds)
 Adds an object for sweep and prune to track.
void removeObject (EntityID entity)
 Removes an object from Sweep and Prune's tracking lists.
void updateObject (EntityID entity, const AxisAlignedBounds &bounds)

Private Types

enum  Axis : uint8_t { X , Y , Z }
using EdgeIndex = std::size_t

Private Member Functions

void sortEdges ()
 Sorts edges along every axis.
void sortEdges (Axis axis)
 Sorts edges along a particular axis.
void findCollisionPairs ()
 Scans edge lists to find likely collision pairs.

Private Attributes

std::unordered_map< EntityID, ObjectmObjects {}
 Indices into edge lists for each axis per entity.
std::set< CollisionPairmCollisionPairs {}
 Storage for all detected collision pairs.
std::array< std::vector< Edge >, 3 > mEdges {}
 Sorted list of edges along each axis.
std::array< std::set< CollisionPair >, 3 > mOverlaps {}
 Pairs of entities which are overlapping on each axis.
bool mRecomputeCollisions { true }
 Whether collision pairs need to be recomputed, as they would after an update.

Detailed Description

A class designed around finding which pairs of AABBs may be intersecting (so as to limit the number of full collision checks that need be performed).

Member Function Documentation

◆ updateObject()

void SweepPrune::updateObject ( EntityID entity,
const AxisAlignedBounds & bounds )

Updates the values of the boundaries of an object tracked by sweep and prune.


The documentation for this class was generated from the following files:
  • ToyMaker_Main/include/toymaker/engine/spatial_query/sweep_prune.hpp
  • ToyMaker_Main/src/spatial_query/sweep_prune.cpp