Initial Commit

This commit is contained in:
SoraKatadzuma committed 2026-10-30 15:05:57 -05:00
commit 7e9ae866a7
34 files changed
+4608

No files matched your search

+304
View File
@@ -0,0 +1,304 @@
#! Times what `linear` does most, each over a thousand values two thousand
#! times, against the same worked a number at a time on a `vec3` of 12 bytes,
#! as hearth's scenes worked it before: adding and scaling vectors, their dots
#! and lengths, quaternions' products and turns, and matrices' products,
#! points, and inverses.
#!
#! Each pass is a function of its own, as a system is, and what it times is
#! called from elsewhere too, so nothing is inlined only for being called once:
#! the code an executable makes of a loop hangs on what is around it.
#!
#! `blossom build`, then run `malunal.linear.bench`, as an executable
#! optimized with `-O2`: the VM works numbers one at a time either way.
import std::io;
import std::math;
import std::time;
import std::containers;
import malunal::linear;
# A vector of three of 12 bytes, and the rest, as they were before.
struct old3 { var x: f32; var y: f32; var z: f32; }
struct oldq { var x: f32; var y: f32; var z: f32; var w: f32; }
struct oldm { var m: f32[16]; }
def old3::add(&this, o: &old3): old3 { return old3{ this.x + o.x, this.y + o.y, this.z + o.z }; }
def old3::mul(&this, by: &f32): old3 { return old3{ this.x * by, this.y * by, this.z * by }; }
def old3::dot(&this, o: old3): f32 { return this.x * o.x + this.y * o.y + this.z * o.z; }
def old3::cross(&this, o: old3): old3 { return old3{ this.y * o.z - this.z * o.y, this.z * o.x - this.x * o.z, this.x * o.y - this.y * o.x }; }
def old3::normalized(&this): old3 {
val l := math::sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
return l > 0 ? old3{ this.x / l, this.y / l, this.z / l } : old3{};
}
def oldq::mul(&this, o: &oldq): oldq {
return oldq{
this.w * o.x + this.x * o.w + this.y * o.z - this.z * o.y,
this.w * o.y - this.x * o.z + this.y * o.w + this.z * o.x,
this.w * o.z + this.x * o.y - this.y * o.x + this.z * o.w,
this.w * o.w - this.x * o.x - this.y * o.y - this.z * o.z,
};
}
def oldq::turn(&this, v: &old3): old3 {
val q := old3{ this.x, this.y, this.z };
val t := q.cross(v) * 2;
return v + t * this.w + q.cross(t);
}
def oldm::mul(&this, other: &oldm): oldm {
var made := oldm{};
for c in 0..4u {
for r in 0..4u {
made.m[c * 4 + r] = this.m[r] * other.m[c * 4] + this.m[4 + r] * other.m[c * 4 + 1]
+ this.m[8 + r] * other.m[c * 4 + 2] + this.m[12 + r] * other.m[c * 4 + 3];
}
}
return made;
}
# A matrix of three as one would be worked a number at a time.
struct old33 { var x: old3; var y: old3; var z: old3; }
def old33::turned(&this, v: &old3): old3 {
return old3{
this.x.x * v.x + this.y.x * v.y + this.z.x * v.z,
this.x.y * v.x + this.y.y * v.y + this.z.y * v.z,
this.x.z * v.x + this.y.z * v.y + this.z.z * v.z,
};
}
def old33::mul(&this, o: &old33): old33 {
return old33{ this.turned(&o.x), this.turned(&o.y), this.turned(&o.z) };
}
def oldm::point(&this, p: old3): old3 {
return old3{
this.m[0] * p.x + this.m[4] * p.y + this.m[8] * p.z + this.m[12],
this.m[1] * p.x + this.m[5] * p.y + this.m[9] * p.z + this.m[13],
this.m[2] * p.x + this.m[6] * p.y + this.m[10] * p.z + this.m[14],
};
}
const count: u64 = 1024;
const rounds: u64 = 2000;
const dt: f32 = 0.016;
# What each pass works over.
struct data {
var ps: vector<vec3>;
var vs: vector<vec3>;
var qs: vector<quat>;
var ms: vector<mat4>;
var rs: vector<mat3>;
var ws: vector<vec4>;
var out: vector<mat4>;
var ops: vector<old3>;
var ovs: vector<old3>;
var oqs: vector<oldq>;
var oms: vector<oldm>;
var oout: vector<oldm>;
var ors: vector<old33>;
var r_out: vector<mat3>;
var or_out: vector<old33>;
var sum: f32;
}
# How long a pass took, for each value, beside what it took before.
def report(what: strview, started: &instant, before: f64): f64 {
val ns := started.elapsed().in_nanoseconds as f64 / (count * rounds) as f64;
if before == 0 {
println($"{what}: {ns} ns");
} else {
println($"{what}: {ns} ns, before {before} ns, {before / ns}x");
}
return ns;
}
def step_before(d: &mut data): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.ops[i] = d.ops[i] + d.ovs[i] * dt; } }
return report("vec3 p + v * dt, before", &at, 0);
}
def step(d: &mut data, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.ps[i] = d.ps[i] + d.vs[i] * dt; } }
_ = report("vec3 p + v * dt", &at, before);
}
def dots_before(d: &mut data): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.sum += d.ops[i].dot(d.ovs[i]); } }
return report("vec3 dot, before", &at, 0);
}
def dots(d: &mut data, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.sum += d.ps[i].dot(d.vs[i]); } }
_ = report("vec3 dot", &at, before);
}
def normals_before(d: &mut data): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.ovs[i] = (d.ovs[i] + d.ops[i]).normalized(); } }
return report("vec3 normalized, before", &at, 0);
}
def normals(d: &mut data, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.vs[i] = (d.vs[i] + d.ps[i]).normalized(); } }
_ = report("vec3 normalized", &at, before);
}
def crosses_before(d: &mut data): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.ovs[i] = d.ovs[i].cross(d.ops[i]); } }
return report("vec3 cross, before", &at, 0);
}
def crosses(d: &mut data, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.vs[i] = d.vs[i].cross(d.ps[i]); } }
_ = report("vec3 cross", &at, before);
}
def turns_before(d: &mut data, by: &oldq): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.oqs[i] = d.oqs[i] * by; } }
return report("quat * quat, before", &at, 0);
}
def turns(d: &mut data, by: &quat, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.qs[i] = d.qs[i] * by; } }
_ = report("quat * quat", &at, before);
}
def rotations_before(d: &mut data): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.ops[i] = d.oqs[i].turn(&d.ops[i]); } }
return report("quat * vec3, before", &at, 0);
}
def rotations(d: &mut data, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.ps[i] = d.qs[i] * d.ps[i]; } }
_ = report("quat * vec3", &at, before);
}
def directions(d: &mut data): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.ps[i] = d.rs[i] * d.ps[i]; } }
_ = report("mat3 * vec3", &at, 0);
}
def tensors_before(d: &mut data): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.or_out[i] = d.ors[i] * d.ors[(i + 1) % count]; } }
return report("mat3 * mat3, a number at a time", &at, 0);
}
def tensors(d: &mut data, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.r_out[i] = d.rs[i] * d.rs[(i + 1) % count]; } }
_ = report("mat3 * mat3", &at, before);
}
def products_before(d: &mut data): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.oout[i] = d.oms[i] * d.oms[(i + 1) % count]; } }
return report("mat4 * mat4, before", &at, 0);
}
def products(d: &mut data, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.out[i] = d.ms[i] * d.ms[(i + 1) % count]; } }
_ = report("mat4 * mat4", &at, before);
}
def projections(d: &mut data): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.ws[i] = d.ms[i] * d.ws[i]; } }
_ = report("mat4 * vec4", &at, 0);
}
def points_before(d: &mut data): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.ops[i] = d.oms[i].point(d.ops[i]); } }
return report("mat4 transform_point, before", &at, 0);
}
def points(d: &mut data, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.ps[i] = d.ms[i].transform_point(d.ps[i]); } }
_ = report("mat4 transform_point", &at, before);
}
def inverses(d: &mut data): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.out[i] = d.ms[i].inverse(); } }
_ = report("mat4 inverse", &at, 0);
}
# Each of what's timed, called once more, so none is called from one place.
def elsewhere(d: &mut data): void {
d.ps[0] = d.ps[1] + d.vs[1] * 2;
d.ops[0] = d.ops[1] + d.ovs[1] * 2;
d.sum += d.ps[1].dot(d.vs[1]) + d.ops[1].dot(d.ovs[1]);
d.vs[0] = d.vs[1].normalized().cross(d.ps[1]);
d.ovs[0] = d.ovs[1].normalized().cross(d.ops[1]);
d.qs[0] = d.qs[1] * d.qs[2];
d.oqs[0] = d.oqs[1] * d.oqs[2];
d.ps[0] = d.qs[1] * (d.rs[1] * d.ps[1]);
d.ops[0] = d.oqs[1].turn(&d.ops[1]);
d.out[0] = d.ms[1] * d.ms[2];
d.oout[0] = d.oms[1] * d.oms[2];
d.r_out[0] = d.rs[1] * d.rs[2];
d.or_out[0] = d.ors[1] * d.ors[2];
d.ws[0] = d.ms[1] * d.ws[1];
d.ps[0] = d.ms[1].transform_point(d.ps[1]);
d.ops[0] = d.oms[1].point(d.ops[1]);
d.out[0] = d.ms[1].inverse();
}
def main(): void {
println($"lanes held: {lanes_held()}");
var d := data{
ps = vector::<vec3>::new(), vs = vector::<vec3>::new(), qs = vector::<quat>::new(), ms = vector::<mat4>::new(),
rs = vector::<mat3>::new(), ws = vector::<vec4>::new(), out = vector::<mat4>::new(), ops = vector::<old3>::new(),
ovs = vector::<old3>::new(), oqs = vector::<oldq>::new(), oms = vector::<oldm>::new(), oout = vector::<oldm>::new(),
ors = vector::<old33>::new(), r_out = vector::<mat3>::new(), or_out = vector::<old33>::new(),
};
for i in 0..count {
d.ps.append(vec3{ i as f32 * 0.001, 1, 2 });
d.vs.append(vec3{ 0.5, 0.25, 0.125 });
d.ops.append(old3{ i as f32 * 0.001, 1, 2 });
d.ovs.append(old3{ 0.5, 0.25, 0.125 });
val q := quat::axis_angle(vec3{ 1, 2, i as f32 }, i as f32 * 0.01);
d.qs.append(q);
d.oqs.append(oldq{ q.x, q.y, q.z, q.w });
val r := mat3::rotation(q);
d.rs.append(r);
d.ors.append(old33{
old3{ r.x_axis.x, r.x_axis.y, r.x_axis.z }, old3{ r.y_axis.x, r.y_axis.y, r.y_axis.z }, old3{ r.z_axis.x, r.z_axis.y, r.z_axis.z },
});
val m := mat4::compose(vec3{ i as f32, 1, 2 }, q, vec3{ 1, 2, 1 });
d.ms.append(m);
d.oms.append(oldm{ m = m.m });
d.ws.append(vec4{ i as f32, 1, 2, 1 });
}
d.out.resize(count);
d.oout.resize(count);
d.r_out.resize(count);
d.or_out.resize(count);
elsewhere(&mut d);
step(&mut d, step_before(&mut d));
dots(&mut d, dots_before(&mut d));
normals(&mut d, normals_before(&mut d));
crosses(&mut d, crosses_before(&mut d));
val turn := quat::axis_angle(vec3::up, 0.001);
turns(&mut d, &turn, turns_before(&mut d, &oldq{ turn.x, turn.y, turn.z, turn.w }));
rotations(&mut d, rotations_before(&mut d));
directions(&mut d);
tensors(&mut d, tensors_before(&mut d));
products(&mut d, products_before(&mut d));
projections(&mut d);
points(&mut d, points_before(&mut d));
inverses(&mut d);
# What was worked, so none of it is left out.
println($"checks: {d.sum} {d.ps[3].y} {d.ops[3].y} {d.vs[5].x} {d.ovs[5].x} {d.qs[7].w} {d.oqs[7].w} {d.out[9].m[5]} {d.oout[9].m[5]} {d.ws[2].y}");
}
+236
View File
@@ -0,0 +1,236 @@
#! Times what `geometry` does most, each over a thousand values two thousand
#! times, against the same worked a number at a time on a `vec3` of 12 bytes:
#! a camera's frustum culling boxes and spheres, rays meeting boxes and
#! spheres, and boxes moved by matrices.
#!
#! Each pass is a function of its own, as a system is, and what it times is
#! called from elsewhere too, so nothing is inlined only for being called once:
#! the code an executable makes of a loop hangs on what is around it.
#!
#! `blossom build`, then run `malunal.geometry.bench`, as an executable
#! optimized with `-O2`: the VM works numbers one at a time either way.
import std::io;
import std::math;
import std::time;
import std::containers;
import malunal::linear;
import malunal::geometry;
# The shapes as they'd be written a number at a time, of vectors of 12 bytes.
struct old3 { var x: f32; var y: f32; var z: f32; }
struct oldp { var x: f32; var y: f32; var z: f32; var d: f32; }
struct oldb { var min: old3; var max: old3; }
struct olds { var center: old3; var radius: f32; }
struct oldr { var origin: old3; var direction: old3; }
struct oldm { var m: f32[16]; }
# Whether a box is in front of each of six planes, of the corner furthest in
# front of each, a plane at a time.
def oldb::seen(&this, planes: &oldp[6]): bool {
for i in 0..6u {
val p := planes[i];
val x := p.x < 0 ? this.min.x : this.max.x;
val y := p.y < 0 ? this.min.y : this.max.y;
val z := p.z < 0 ? this.min.z : this.max.z;
return false if p.x * x + p.y * y + p.z * z - p.d < 0;
}
return true;
}
def olds::seen(&this, planes: &oldp[6]): bool {
for i in 0..6u {
val p := planes[i];
return false if p.x * this.center.x + p.y * this.center.y + p.z * this.center.z - p.d + this.radius < 0;
}
return true;
}
# Where a ray meets a box, or -1, between the box's faces along each axis.
def oldr::hit(&this, b: &oldb): f32 {
val ix := 1 / this.direction.x;
val iy := 1 / this.direction.y;
val iz := 1 / this.direction.z;
val x0 := (b.min.x - this.origin.x) * ix;
val x1 := (b.max.x - this.origin.x) * ix;
val y0 := (b.min.y - this.origin.y) * iy;
val y1 := (b.max.y - this.origin.y) * iy;
val z0 := (b.min.z - this.origin.z) * iz;
val z1 := (b.max.z - this.origin.z) * iz;
val enter := math::max(math::max(math::min(x0, x1), math::min(y0, y1)), math::max(math::min(z0, z1), 0));
val leave := math::min(math::min(math::max(x0, x1), math::max(y0, y1)), math::max(z0, z1));
return enter <= leave ? enter : -1;
}
# Where a ray meets a sphere, or -1.
def oldr::hit(&this, s: &olds): f32 {
val mx := this.origin.x - s.center.x;
val my := this.origin.y - s.center.y;
val mz := this.origin.z - s.center.z;
val c := mx * mx + my * my + mz * mz - s.radius * s.radius;
return 0 if c <= 0;
val b := mx * this.direction.x + my * this.direction.y + mz * this.direction.z;
return -1 if b >= 0;
val a := this.direction.x * this.direction.x + this.direction.y * this.direction.y + this.direction.z * this.direction.z;
val d := b * b - a * c;
return d < 0 ? -1 : (-b - math::sqrt(d)) / a;
}
# The box holding a box a matrix moves.
def oldb::moved(&this, by: &oldm): oldb {
val m := &by.m;
val cx := (this.min.x + this.max.x) * 0.5;
val cy := (this.min.y + this.max.y) * 0.5;
val cz := (this.min.z + this.max.z) * 0.5;
val hx := (this.max.x - this.min.x) * 0.5;
val hy := (this.max.y - this.min.y) * 0.5;
val hz := (this.max.z - this.min.z) * 0.5;
val x := m[0] * cx + m[4] * cy + m[8] * cz + m[12];
val y := m[1] * cx + m[5] * cy + m[9] * cz + m[13];
val z := m[2] * cx + m[6] * cy + m[10] * cz + m[14];
val rx := math::abs(m[0]) * hx + math::abs(m[4]) * hy + math::abs(m[8]) * hz;
val ry := math::abs(m[1]) * hx + math::abs(m[5]) * hy + math::abs(m[9]) * hz;
val rz := math::abs(m[2]) * hx + math::abs(m[6]) * hy + math::abs(m[10]) * hz;
return oldb{ old3{ x - rx, y - ry, z - rz }, old3{ x + rx, y + ry, z + rz } };
}
const count: u64 = 1024;
const rounds: u64 = 2000;
# What each pass works over.
struct data {
var boxes: vector<bounds>;
var spheres: vector<sphere>;
var rays: vector<ray>;
var ms: vector<mat4>;
var moved: vector<bounds>;
var oboxes: vector<oldb>;
var ospheres: vector<olds>;
var orays: vector<oldr>;
var oms: vector<oldm>;
var omoved: vector<oldb>;
var seen: u64;
var sum: f32;
}
# How long a pass took, for each value, beside what it took before.
def report(what: strview, started: &instant, before: f64): f64 {
val ns := started.elapsed().in_nanoseconds as f64 / (count * rounds) as f64;
if before == 0 {
println($"{what}: {ns} ns");
} else {
println($"{what}: {ns} ns, before {before} ns, {before / ns}x");
}
return ns;
}
def culled_boxes_before(d: &mut data, planes: &oldp[6]): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.seen += d.oboxes[i].seen(planes) ? 1 : 0; } }
return report("frustum overlaps bounds, before", &at, 0);
}
def culled_boxes(d: &mut data, f: &frustum, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.seen += f.overlaps(d.boxes[i]) ? 1 : 0; } }
_ = report("frustum overlaps bounds", &at, before);
}
def culled_spheres_before(d: &mut data, planes: &oldp[6]): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.seen += d.ospheres[i].seen(planes) ? 1 : 0; } }
return report("frustum overlaps sphere, before", &at, 0);
}
def culled_spheres(d: &mut data, f: &frustum, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.seen += f.overlaps(d.spheres[i]) ? 1 : 0; } }
_ = report("frustum overlaps sphere", &at, before);
}
def boxes_hit_before(d: &mut data): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.sum += d.orays[i].hit(&d.oboxes[(i + 1) % count]); } }
return report("ray hit bounds, before", &at, 0);
}
def boxes_hit(d: &mut data, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.sum += d.rays[i].hit(d.boxes[(i + 1) % count]) is some(t) ? t : -1; } }
_ = report("ray hit bounds", &at, before);
}
def spheres_hit_before(d: &mut data): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.sum += d.orays[i].hit(&d.ospheres[(i + 1) % count]); } }
return report("ray hit sphere, before", &at, 0);
}
def spheres_hit(d: &mut data, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.sum += d.rays[i].hit(d.spheres[(i + 1) % count]) is some(t) ? t : -1; } }
_ = report("ray hit sphere", &at, before);
}
def moves_before(d: &mut data): f64 {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.omoved[i] = d.oboxes[i].moved(&d.oms[i]); } }
return report("bounds transformed, before", &at, 0);
}
def moves(d: &mut data, before: f64): void {
val at := instant::now();
for _ in 0..rounds { for i in 0..count { d.moved[i] = d.boxes[i].transformed(d.ms[i]); } }
_ = report("bounds transformed", &at, before);
}
# Each of what's timed, called once more, so none is called from one place.
def elsewhere(d: &mut data, f: &frustum, planes: &oldp[6]): void {
d.seen += (f.overlaps(d.boxes[1]) ? 1 : 0) + (d.oboxes[1].seen(planes) ? 1 : 0);
d.seen += (f.overlaps(d.spheres[1]) ? 1 : 0) + (d.ospheres[1].seen(planes) ? 1 : 0);
d.sum += d.orays[1].hit(&d.oboxes[2]) + d.orays[1].hit(&d.ospheres[2]);
d.sum += (d.rays[1].hit(d.boxes[2]) is some(t) ? t : -1) + (d.rays[1].hit(d.spheres[2]) is some(u) ? u : -1);
d.moved[0] = d.boxes[1].transformed(d.ms[1]);
d.omoved[0] = d.oboxes[1].moved(&d.oms[1]);
}
def old3_of(v: vec3): old3 {
return old3{ v.x, v.y, v.z };
}
def main(): void {
println($"lanes held: {lanes_held()}");
var d := data{
boxes = vector::<bounds>::new(), spheres = vector::<sphere>::new(), rays = vector::<ray>::new(), ms = vector::<mat4>::new(),
moved = vector::<bounds>::new(), oboxes = vector::<oldb>::new(), ospheres = vector::<olds>::new(),
orays = vector::<oldr>::new(), oms = vector::<oldm>::new(), omoved = vector::<oldb>::new(),
};
# A camera at the middle of a field of boxes, seeing about half of them.
val f := frustum::of(mat4::perspective(math::pi as f32 / 3, 16.0 / 9.0, 0.1, 400) * mat4::look_at(vec3{ 0, 5, 0 }, vec3{ 0, 0, -10 }));
var planes: oldp[6];
for i in 0..6u {
val p := f.planes[i];
planes[i] = oldp{ p.normal.x, p.normal.y, p.normal.z, p.distance };
}
for i in 0..count {
val at := vec3{ (i % 32) as f32 * 8 - 128, (i % 3) as f32, (i / 32) as f32 * 8 - 128 };
val b := bounds::around(at, vec3{ 1, 2, 1.5 });
d.boxes.append(b);
d.oboxes.append(oldb{ old3_of(b.min), old3_of(b.max) });
d.spheres.append(sphere{ at, 2 });
d.ospheres.append(olds{ old3_of(at), 2 });
val r := ray::toward(vec3{ 0, 5, 0 }, at);
d.rays.append(r);
d.orays.append(oldr{ old3_of(r.origin), old3_of(r.direction) });
val m := mat4::compose(at, quat::axis_angle(vec3{ 1, 2, i as f32 }, i as f32 * 0.01), vec3{ 1, 2, 1 });
d.ms.append(m);
d.oms.append(oldm{ m = m.m });
}
d.moved.resize(count);
d.omoved.resize(count);
elsewhere(&mut d, &f, &planes);
culled_boxes(&mut d, &f, culled_boxes_before(&mut d, &planes));
culled_spheres(&mut d, &f, culled_spheres_before(&mut d, &planes));
boxes_hit(&mut d, boxes_hit_before(&mut d));
spheres_hit(&mut d, spheres_hit_before(&mut d));
moves(&mut d, moves_before(&mut d));
# What was worked, so none of it is left out.
println($"checks: {d.seen} {d.sum} {d.moved[3].max.y} {d.omoved[3].max.y}");
}