Stowy Physics Engine 0.1.0
Loading...
Searching...
No Matches
stw::BroadPhaseGrid Class Reference

A grid in which the physical object are placed in. This is used to optimize performance by only checking collision with colliders that are in the same cell. More...

#include <BroadPhaseGrid.hpp>

Public Member Functions

 BroadPhaseGrid (float minX, float maxX, float minY, float maxY, float cellSize)
 Constructs a new grid.
 
void Update (const std::unordered_map< std::uint64_t, CollisionBody * > &bodies)
 Updates the layout of the grid.
 
std::vector< std::pair< std::uint64_t, std::uint64_t > > GetCollisionPairs () const
 Find all the pair of objects that are in the same cell. Doesn't contain any duplicates.
 

Detailed Description

A grid in which the physical object are placed in. This is used to optimize performance by only checking collision with colliders that are in the same cell.

A collider that spans on multiple cells will have a pointer on every cell.

Constructor & Destructor Documentation

◆ BroadPhaseGrid()

stw::BroadPhaseGrid::BroadPhaseGrid ( float minX,
float maxX,
float minY,
float maxY,
float cellSize )

Constructs a new grid.

Parameters
minXX coordinate on the bottom left point of the grid.
maxXX coordinate on the top right point of the grid.
minYY coordinate on the bottom left point of the grid.
maxYY coordinate on the top right point of the grid.
cellSizeSize (in meter) of a cell.

Member Function Documentation

◆ GetCollisionPairs()

std::vector< std::pair< std::uint64_t, std::uint64_t > > stw::BroadPhaseGrid::GetCollisionPairs ( ) const

Find all the pair of objects that are in the same cell. Doesn't contain any duplicates.

Returns
The pair of objects that will collide.

◆ Update()

void stw::BroadPhaseGrid::Update ( const std::unordered_map< std::uint64_t, CollisionBody * > & bodies)

Updates the layout of the grid.

Parameters
bodiesBodies in the physical world.

The documentation for this class was generated from the following files: