Aegis2D
Modular C++26 2D game engine for networked games
Loading...
Searching...
No Matches
collision.hpp File Reference

Collision detection: a uniform grid finds the entities close enough to collide (broad phase), then box overlap and layer masks keep the real contacts (narrow phase). More...

#include <aegis2d/core/math.hpp>
#include <aegis2d/ecs/components.hpp>
#include <aegis2d/ecs/entity.hpp>
#include <aegis2d/ecs/export.hpp>
#include <aegis2d/ecs/registry.hpp>
#include <compare>
#include <cstddef>
#include <cstdint>
#include <span>
#include <vector>

Go to the source code of this file.

Classes

struct  aegis2d::ecs::Aabb
 Axis-aligned box given by its two corners, in logical pixels. More...
 
struct  aegis2d::ecs::CollisionPair
 Two entities that may collide, the one with the smaller handle first. More...
 
struct  aegis2d::ecs::Contact
 Two entities whose boxes overlap and whose layers interact. More...
 
class  aegis2d::ecs::CollisionGrid
 Broad phase of collision detection: a uniform grid over the play area. More...
 

Namespaces

namespace  aegis2d
 Root namespace of the engine.
 
namespace  aegis2d::ecs
 Entity-Component-System used by client and server.
 

Functions

constexpr bool aegis2d::ecs::hits (const Collider &attacker, const Collider &target) noexcept
 Tells whether a collider can hit another one, according to their layers.
 
void aegis2d::ecs::find_contacts (const Registry &registry, std::span< const CollisionPair > candidates, std::vector< Contact > &out)
 Narrow phase: keeps the candidate pairs whose layers interact and boxes overlap.
 
std::vector< Contact > aegis2d::ecs::find_contacts (const Registry &registry, const CollisionGrid &grid)
 Broad and narrow phases on a grid built for this tick.
 

Detailed Description

Collision detection: a uniform grid finds the entities close enough to collide (broad phase), then box overlap and layer masks keep the real contacts (narrow phase).