Skip to content

CollisionObject

Generated from engine/collision/collision_object.h at 862e08b. The text under each declaration is the header's own comment, word for word. About the reference says how these pages are made.

Browse the collision module

#include "engine/collision/collision_object.h" · namespace labrador

A GameObject the collision module can see.

An interface that asks each object is_colliding(other) - "are you two overlapping?" - and, by way of the same predicate, "should you be tested at all?" delegates two questions the engine should keep: every class then answers the first with the same copied AABB-then-narrow block and the second with a hand-written type list, and the lists diverge (see collision_layer.h). Both are answered once, in find_contacts.

What is left is what only the object can know: its shape, which groups it belongs to and responds to, what it is in the game's own vocabulary, and what a contact means to it.

~CollisionObject() override = default;
virtual const mattmath::Shape* shape() const = 0;

The fine half of the pair GameObject::bounds() opens. bounds() is the coarse extent a broad phase indexes; this is the geometry the narrow phase measures. Never null.

virtual CollisionLayer layer() const = 0;
virtual CollisionMask mask() const = 0;
virtual CollisionTag tag() const = 0;
virtual void on_contact(const CollisionObject& other,
const mattmath::Vector2F& normal, float penetration) = 0;

Something overlapped this object, this frame.

normal is a unit vector pointing from this object towards other, and penetration is how far they overlap along it - so the two participants of one contact are told the same overlap with opposite normals, and each is told exactly once.

Separation is the game's call, not the engine's, which is why this hands over the measurement rather than the movement: a one-way platform separates only when the contact comes from above, a ramp separates vertically rather than along the slope, and a projectile does not separate at all - it dies. engine/collision/resolve.h has the arithmetic for the cases that do separate.

virtual bool for_deletion() const = 0;

Retired at the end of this tick. Objects flagged mid-frame generate no further contacts, so a projectile that hits a wall cannot also hit the player standing behind it.

virtual void set_for_deletion(bool /*for_deletion*/);

Requests removal at the end of the frame. Objects that are part of a level's fixed geometry (walls, platforms) cannot be removed and ignore this by default.

Named in the public declarations above: GameObject, Shape, Vector2F.

The files that include this header directly. A file can also reach it through another header.

Development documentation (unreleased). Built from Labrador 862e08b of 2026-10-08.