module

Flock::Collision::Narrowphase2D

Exact shape-vs-shape tests. Each returns a Manifold2D? (nil when the shapes do not overlap), with the normal pointing from A toward B.

All shape pairs are supported, with rotation: circle / capsule pairs -> unified as "rounded cores" (point or segment + radius) via closest-segment-segment, so circle-circle, circle-capsule and capsule-capsule share one routine. box (OBB) pairs -> SAT for box-box, closest-point-on-OBB for box-vs-rounded.

box-box produces up to TWO contact points (reference/incident face clipping) so resting boxes stay flat instead of pivoting on one point.

Known v1 limitations (documented, not silent):

  • box-capsule produces a single contact point (fine for an upright capsule resting on a box; a capsule lying flat gets one point, not two).
  • capsule-box uses an accurate closest-point test when the capsule's core segment is outside the box (the common resting case) and an approximate minimum-translation push when the core actually penetrates the box.

Constants

EPS = 1e-6_f32

Instance methods

box_box(pa : Flock::Vec2, ha : Flock::Vec2, pb : Flock::Vec2, hb : Flock::Vec2) : ContactManifold2D | Nil

Axis-aligned box A vs axis-aligned box B (thin wrapper over the OBB test).

Source
capsule_obb(a0 : Flock::Vec2, a1 : Flock::Vec2, r : Float32, box : OBB) : Manifold2D | Nil

Capsule A (core segment a0..a1, radius r) vs box B. Normal points A -> B.

Source
circle_box(cpos : Flock::Vec2, r : Float32, bpos : Flock::Vec2, half : Flock::Vec2) : Manifold2D | Nil

Circle A vs an axis-aligned box B (thin wrapper over the OBB test).

Source
circle_circle(pa : Flock::Vec2, ra : Float32, pb : Flock::Vec2, rb : Float32) : Manifold2D | Nil
Source
circle_obb(cpos : Flock::Vec2, r : Float32, box : OBB) : Manifold2D | Nil

Circle A (center cpos, radius r) vs box B. Normal points A -> B.

Source
collide(ca : Collider2D, ta : Flock::Transform2D, cb : Collider2D, tb : Flock::Transform2D) : ContactManifold2D | Nil

Dispatch on the shape pair. A is (ca, ta), B is (cb, tb). Returns a ContactManifold2D (1 or 2 points); box-box yields two points when the contact is edge-to-edge.

Source
obb_obb(a : OBB, b : OBB) : ContactManifold2D | Nil

Box A vs box B via SAT (2D: 4 axes) followed by reference/incident face clipping to produce up to two contact points. Normal points A -> B.

Source
rounded_pair(a0 : Flock::Vec2, a1 : Flock::Vec2, ra : Float32, b0 : Flock::Vec2, b1 : Flock::Vec2, rb : Float32) : Manifold2D | Nil

Two rounded cores: (a0,a1) with radius ra and (b0,b1) with radius rb. A circle is the degenerate case a0 == a1. Normal points A -> B.

Source