module

Flock::Collision

Constants

VERSION = "0.1.0"

Class methods

cast_collider2d(o : Flock::Vec2, d : Flock::Vec2, col : Collider2D, tf : Flock::Transform2D) : Tuple(Float32, Flock::Vec2) | Nil

Ray (unit d) vs a single collider; returns {distance, normal} or nil. Used by ray casts and by continuous collision (swept) detection.

Source
cast_collider3d(o : Flock::Vec3, d : Flock::Vec3, col : Collider3D, pos : Flock::Vec3, q : Flock::Quaternion) : Tuple(Float32, Flock::Vec3) | Nil

Ray (unit d) vs a single collider; returns {distance, normal} or nil.

Source
overlap_circle2d(world : Flock::World, center : Flock::Vec2, radius : Float32, mask : UInt32 = 4294967295_u32) : Array(Flock::Entity)

Returns every entity whose collider overlaps the query circle (center, radius). mask filters by collider layer bits. Reuses the narrowphase, so it handles circle/box/capsule colliders with rotation.

Source
overlap_point2d(world : Flock::World, point : Flock::Vec2, mask : UInt32 = 4294967295_u32) : Array(Flock::Entity)

Every entity whose collider contains point.

Source
overlap_point3d(world : Flock::World, point : Flock::Vec3, mask : UInt32 = 4294967295_u32) : Array(Flock::Entity)

Every entity whose collider contains point.

Source
overlap_sphere3d(world : Flock::World, center : Flock::Vec3, radius : Float32, mask : UInt32 = 4294967295_u32) : Array(Flock::Entity)

Every entity whose collider overlaps the query sphere (center, radius). mask filters by collider layer bits. Collider orientation comes from each body's RigidBody3D.orientation (NOT Transform3D.rotation); only entities carrying a RigidBody3D are considered, so bare Collider3D + Transform3D geometry is invisible to this query. The same applies to overlap_point3d.

Source
raycast2d(world : Flock::World, origin : Flock::Vec2, direction : Flock::Vec2, max_distance : Float32 = Float32::INFINITY, mask : UInt32 = 4294967295_u32) : RayHit2D | Nil

Casts a ray and returns the nearest collider it hits, or nil. direction need not be unit length, but a ~zero-length direction yields no hit (nil) rather than a bogus result. mask filters by collider layer bits.

Source
raycast3d(world : Flock::World, origin : Flock::Vec3, direction : Flock::Vec3, max_distance : Float32 = Float32::INFINITY, mask : UInt32 = 4294967295_u32) : RayHit3D | Nil

Casts a ray in 3D and returns the nearest collider hit, or nil. direction need not be unit length, but a ~zero-length direction yields no hit (nil) rather than a bogus result. Orientation comes from each body's RigidBody3D.orientation (NOT Transform3D.rotation), so a rotated static collider must be oriented via RigidBody3D.static(orientation:). Only entities carrying a RigidBody3D are considered — bare Collider3D + Transform3D geometry is invisible to the raycast.

Source
step(world : Flock::World) : Nil

One fixed-timestep 2D physics step (registered in FixedUpdate).

Source
step3d(world : Flock::World) : Nil

One fixed-timestep 3D physics step. Orientation authority is RigidBody3D.orientation; Transform3D.rotation is IGNORED (rotate static geometry via RigidBody3D.static(orientation:)). Only entities carrying a RigidBody3D participate — a bare Collider3D + Transform3D is invisible to the step. Results are written to each dynamic entity's Transform3D (position + matrix_override). Static bodies are left as authored. Resting bodies sleep per contact island.

Source

Nested types