Class BroadphaseUniformGrid

Inheritance Relationships

Base Type

Class Documentation

class legion::physics::BroadphaseUniformGrid : public legion::physics::BroadPhaseCollisionAlgorithm

Implementation of broad-phase collision detection Creates a virtual axis-aligned grid in which it sorts all physics components with colliders. All colliders in 1 cell have a possibility of colliding, and will be checked in narrow-phase.

Public Functions

inline BroadphaseUniformGrid(math::ivec3 cellSize, size_type emptyCellDestroyThreshold = 0)

Constructor of BroadPhaseUniformGrid.

Parameters
  • cellSize: The size of the cells for the grid

  • emptyCellDestroyThreshold: the empty cell count at which the entire uniform grid is reset and rebuild. This can be usefull since every empty cell still takes up space in lists. when a new object is added to the list the list may have to be moved in memory, which takes time. By keeping the lists small and removing empty cells lists require less moving.

virtual const std::vector<std::vector<physics_manifold_precursor>> &collectPairs(std::vector<physics_manifold_precursor> &&manifoldPrecursors) override

Collects collider pairs that have a chance of colliding and should be checked in narrow-phase collision detection.

Return

a list-list of colliders that have a chance of colliding and should be checked

Parameters
  • manifoldPrecursors: all the physics components

const std::vector<std::vector<physics_manifold_precursor>> &reConstruct(std::vector<physics_manifold_precursor> &&manifoldPrecursors)

Collects collider pairs that have a chance of colliding and should be checked in narrow-phase collision detection. Unlike collectPairs this function ignores all the cached data and reconstructs the grid every time.

Return

a list-list of colliders that have a chance of colliding and should be checked

Parameters
  • manifoldPrecursors: all the physics components

inline void setCellSize(math::ivec3 cellSize)

Sets the cell size which will be used for the virtual grid.

virtual void debugDraw() override