libs/physics
2D Rigid-Body Physics & Game Engine
A fast 2D rigid-body physics engine designed to demonstrate Kale's computational efficiency. Implements convex polygon and circle collision testing, impulse-based contact solver, friction, restitution, and broadphase spatial hashing.

High-Throughput Systems Foundation
Engineered to maximize CPU instruction pipelining and data cache locality. Every algorithm avoids heap pointer indirection wherever contiguous stack or arena buffers can be employed.

import "libs/physics/world.kl" as phys;
fn main() -> int32 {
let world: phys.World = phys.create_world(0.0, -9.81);
let body: phys.Body = phys.create_box(&world, 0.0, 10.0, 1.0, 1.0, 1.0);
let step: int32 = 0;
while step < 60 {
phys.step(&world, 1.0 / 60.0);
step = step + 1;
}
return 0;
}Deterministic command-line invocations to build, link native dynamic dependencies, and run automated regression tests:
kale build tests/test_physics.kl -o bin/test_phys.exe./bin/test_phys.exeGPG Key 1B917D4779A6102E • Continuous integration with automated symbol verification.
Accurately computes minimum penetration vectors and contact points between arbitrary convex shapes.
Sequential impulse solver resolving stacking stability, friction cones, and elasticity.
Fast broadphase pruning scaling efficiently to thousands of active rigid bodies.