R-Type 0.1
Loading...
Searching...
No Matches
rtk::systems::ColliderSystem Class Referencefinal

Detects overlapping colliders with a uniform spatial hash grid. More...

#include <systems/ColliderSystem.hpp>

Inheritance diagram for rtk::systems::ColliderSystem:
[legend]

Public Member Functions

 ColliderSystem (rtk::collision::CollisionBuffer &collisionBuffer, float cellSize, busEvent &eventBus)
 Creates the system.
 
void onStart (rtk::ecs::Registry &) override
 Logs that the system is loaded.
 
void update (rtk::ecs::Registry &registry, float) override
 Rebuilds the grid and reports every overlapping pair.
 
void onStop (rtk::ecs::Registry &) override
 Clears the grid and the collision buffer.
 

Detailed Description

Detects overlapping colliders with a uniform spatial hash grid.

Each pair is reported once per frame in the CollisionBuffer and as a rtk::collision::Collision event, if each collider mask accepts the other collider layer.

Constructor & Destructor Documentation

◆ ColliderSystem()

rtk::systems::ColliderSystem::ColliderSystem ( rtk::collision::CollisionBuffer & collisionBuffer,
float cellSize,
busEvent & eventBus )
inline

Creates the system.

Parameters
collisionBufferBuffer filled with the collisions of each frame.
cellSizeSide of a grid cell, in pixels.
eventBusBus on which collisions are published.

Member Function Documentation

◆ update()

void rtk::systems::ColliderSystem::update ( rtk::ecs::Registry & registry,
float  )
inlineoverride

Rebuilds the grid and reports every overlapping pair.

Parameters
registryRegistry holding the colliders.