Initial Commit
This commit is contained in:
22 files changed
+2437
No files matched your search
@@ -0,0 +1,119 @@
|
||||
#! Contains `bounds`, a box along the axes: the least corner and the greatest of
|
||||
#! what it holds, as of a mesh, a body, or a part of a scene, so whether two
|
||||
#! meet, or a ray or a camera reaches one, is a few comparisons.
|
||||
|
||||
import std::math;
|
||||
import linear;
|
||||
module geometry;
|
||||
|
||||
#! A box along the axes, from its least corner to its greatest.
|
||||
pub struct bounds {
|
||||
pub var min: vec3;
|
||||
pub var max: vec3;
|
||||
}
|
||||
|
||||
#! The box holding nothing, from infinity to minus infinity, which takes the
|
||||
#! place or box it's first grown by.
|
||||
pub val bounds::empty := bounds{
|
||||
vec3{ math::infinity::<f32>(), math::infinity::<f32>(), math::infinity::<f32>() },
|
||||
vec3{ -math::infinity::<f32>(), -math::infinity::<f32>(), -math::infinity::<f32>() },
|
||||
};
|
||||
|
||||
#! The box of a center, reaching so far from it along each axis.
|
||||
pub def bounds::around(center: vec3, half_size: vec3): bounds {
|
||||
return bounds{ center - half_size, center + half_size };
|
||||
}
|
||||
|
||||
#! The least box holding places, or `empty` of none.
|
||||
pub def bounds::of(points: span<vec3>): bounds {
|
||||
var made := bounds::empty;
|
||||
for p in points {
|
||||
made = made.including(p);
|
||||
}
|
||||
return made;
|
||||
}
|
||||
|
||||
#! The least box holding a sphere.
|
||||
pub def bounds::of(s: sphere): bounds {
|
||||
return bounds::around(s.center, vec3{ s.radius, s.radius, s.radius });
|
||||
}
|
||||
|
||||
pub val bounds::center: vec3 {
|
||||
get => (this.min + this.max) * 0.5;
|
||||
}
|
||||
|
||||
pub val bounds::size: vec3 {
|
||||
get => this.max - this.min;
|
||||
}
|
||||
|
||||
#! How far it reaches from its center along each axis.
|
||||
pub val bounds::half_size: vec3 {
|
||||
get => (this.max - this.min) * 0.5;
|
||||
}
|
||||
|
||||
#! Whether it holds nothing, as `empty` does: a least corner past its greatest.
|
||||
pub val bounds::is_empty: bool {
|
||||
get => this.min.x > this.max.x || this.min.y > this.max.y || this.min.z > this.max.z;
|
||||
}
|
||||
|
||||
pub def bounds::equals(&this, other: &bounds): bool {
|
||||
return this.min == other.min && this.max == other.max;
|
||||
}
|
||||
|
||||
#! Whether a place is within it.
|
||||
pub def bounds::contains(&this, p: vec3): bool {
|
||||
return p.x >= this.min.x && p.y >= this.min.y && p.z >= this.min.z
|
||||
&& p.x <= this.max.x && p.y <= this.max.y && p.z <= this.max.z;
|
||||
}
|
||||
|
||||
#! Whether another box is within it whole.
|
||||
pub def bounds::contains(&this, other: bounds): bool {
|
||||
return this.contains(other.min) && this.contains(other.max);
|
||||
}
|
||||
|
||||
#! Whether it and another box meet.
|
||||
pub def bounds::overlaps(&this, other: bounds): bool {
|
||||
return this.min.x <= other.max.x && this.min.y <= other.max.y && this.min.z <= other.max.z
|
||||
&& this.max.x >= other.min.x && this.max.y >= other.min.y && this.max.z >= other.min.z;
|
||||
}
|
||||
|
||||
#! Whether it and a sphere meet.
|
||||
pub def bounds::overlaps(&this, s: sphere): bool {
|
||||
return s.overlaps(this);
|
||||
}
|
||||
|
||||
#! Its place nearest another: the place itself where it's within.
|
||||
pub def bounds::closest(&this, p: vec3): vec3 {
|
||||
return p.max(this.min).min(this.max);
|
||||
}
|
||||
|
||||
#! The box grown to hold a place too.
|
||||
pub def bounds::including(&this, p: vec3): bounds {
|
||||
return bounds{ this.min.min(p), this.max.max(p) };
|
||||
}
|
||||
|
||||
#! The least box holding it and another.
|
||||
pub def bounds::merged(&this, other: bounds): bounds {
|
||||
return bounds{ this.min.min(other.min), this.max.max(other.max) };
|
||||
}
|
||||
|
||||
#! The least box along the axes holding this one moved, turned, and scaled by a
|
||||
#! matrix that doesn't project: its center moved, and its reach along each of
|
||||
#! its own axes turned, each number made positive, and added.
|
||||
pub def bounds::transformed(&this, by: mat4): bounds {
|
||||
return bounds::empty if this.is_empty;
|
||||
val half := this.half_size;
|
||||
val m := &by.m;
|
||||
if lanes_held() {
|
||||
# Each column as lanes, read where it lies, as `mat4`'s products read them.
|
||||
val reach := lanes_at(&m[0]).abs() * f32x4::splat(half.x) + lanes_at(&m[4]).abs() * f32x4::splat(half.y)
|
||||
+ lanes_at(&m[8]).abs() * f32x4::splat(half.z);
|
||||
return bounds::around(by.transform_point(this.center), vec3::of_lanes(reach));
|
||||
}
|
||||
val reach := vec3{
|
||||
math::abs(m[0]) * half.x + math::abs(m[4]) * half.y + math::abs(m[8]) * half.z,
|
||||
math::abs(m[1]) * half.x + math::abs(m[5]) * half.y + math::abs(m[9]) * half.z,
|
||||
math::abs(m[2]) * half.x + math::abs(m[6]) * half.y + math::abs(m[10]) * half.z,
|
||||
};
|
||||
return bounds::around(by.transform_point(this.center), reach);
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
#! Contains `frustum`, the part of space a camera sees: the six planes bounding
|
||||
#! what a projection draws, each facing in, and whether a place, a box, or a
|
||||
#! sphere is within them, so a renderer draws only what might be seen. The
|
||||
#! planes' numbers are lanes, so an executable holding vectors in registers
|
||||
#! tests four planes at once, then the other two: as two vectors of four, which
|
||||
#! it holds in registers as it works them, where one of eight went through
|
||||
#! memory a half at a time, twice as slow.
|
||||
|
||||
import linear;
|
||||
module geometry;
|
||||
|
||||
#! The part of space a camera sees, within six planes facing in: left, right,
|
||||
#! bottom, top, near, and far. It holds their normals' `x`s, `y`s, and `z`s, and
|
||||
#! how far the origin is in front of each, eight of each, read as two `f32x4`s;
|
||||
#! the last two are of planes of zeros, which nothing is behind.
|
||||
pub struct frustum {
|
||||
var _x: f32[8];
|
||||
var _y: f32[8];
|
||||
var _z: f32[8];
|
||||
var _d: f32[8];
|
||||
}
|
||||
|
||||
#! The frustum of what a matrix projects into its clip space, its planes in the
|
||||
#! space it projects from: of `projection * view`, the world's, and of a
|
||||
#! projection alone, the camera's. Clip space bounds x and y between -w and w,
|
||||
#! and depth between 0 and w, so each plane is the matrix's row of w with
|
||||
#! another row added or taken away, and the near plane its row of depth alone.
|
||||
pub def frustum::of(clip: mat4): frustum {
|
||||
val m := &clip.m;
|
||||
val x := vec4{ m[0], m[4], m[8], m[12] };
|
||||
val y := vec4{ m[1], m[5], m[9], m[13] };
|
||||
val z := vec4{ m[2], m[6], m[10], m[14] };
|
||||
val w := vec4{ m[3], m[7], m[11], m[15] };
|
||||
return frustum::of_planes([plane_of(w + x), plane_of(w - x), plane_of(w + y), plane_of(w - y), plane_of(z), plane_of(w - z)]);
|
||||
}
|
||||
|
||||
# The plane of a matrix's row: the places that, with a 1 after them, it makes
|
||||
# 0 of, in front where it makes more, made of length 1.
|
||||
def plane_of(row: vec4): plane {
|
||||
val l := row.xyz.length;
|
||||
return plane{ row.xyz / l, -row.w / l };
|
||||
}
|
||||
|
||||
#! The frustum of six planes facing in: left, right, bottom, top, near, and far.
|
||||
pub def frustum::of_planes(planes: plane[6]): frustum {
|
||||
var made := frustum{};
|
||||
for i in 0..6u {
|
||||
made._x[i] = planes[i].normal.x;
|
||||
made._y[i] = planes[i].normal.y;
|
||||
made._z[i] = planes[i].normal.z;
|
||||
made._d[i] = -planes[i].distance;
|
||||
}
|
||||
return made;
|
||||
}
|
||||
|
||||
#! Its planes: left, right, bottom, top, near, and far.
|
||||
pub val frustum::planes: plane[6] {
|
||||
get {
|
||||
var made: plane[6];
|
||||
for i in 0..6u {
|
||||
made[i] = plane{ vec3{ this._x[i], this._y[i], this._z[i] }, -this._d[i] };
|
||||
}
|
||||
return made;
|
||||
}
|
||||
}
|
||||
|
||||
#! Whether a place is within it.
|
||||
pub def frustum::contains(&this, p: vec3): bool {
|
||||
if lanes_held() {
|
||||
val x := f32x4::splat(p.x);
|
||||
val y := f32x4::splat(p.y);
|
||||
val z := f32x4::splat(p.z);
|
||||
return in_front(this.ahead(0, x, y, z), this.ahead(4, x, y, z));
|
||||
}
|
||||
for i in 0..6u {
|
||||
return false if this._x[i] * p.x + this._y[i] * p.y + this._z[i] * p.z + this._d[i] < 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#! Whether a box might be seen: whether, of each plane, the box's corner
|
||||
#! furthest in front of it is in front. A box beside a corner of the frustum,
|
||||
#! outside it but in front of every plane, counts as seen, which a renderer
|
||||
#! draws for nothing; one it reaches always counts.
|
||||
pub def frustum::overlaps(&this, b: bounds): bool {
|
||||
if lanes_held() {
|
||||
return in_front(this.ahead_of(0, &b), this.ahead_of(4, &b));
|
||||
}
|
||||
for i in 0..6u {
|
||||
val x := this._x[i] < 0 ? b.min.x : b.max.x;
|
||||
val y := this._y[i] < 0 ? b.min.y : b.max.y;
|
||||
val z := this._z[i] < 0 ? b.min.z : b.max.z;
|
||||
return false if this._x[i] * x + this._y[i] * y + this._z[i] * z + this._d[i] < 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#! Whether a sphere might be seen: whether its center is no further behind any
|
||||
#! plane than its radius. As of a box, one beside a corner counts too.
|
||||
pub def frustum::overlaps(&this, s: sphere): bool {
|
||||
val c := s.center;
|
||||
if lanes_held() {
|
||||
val x := f32x4::splat(c.x);
|
||||
val y := f32x4::splat(c.y);
|
||||
val z := f32x4::splat(c.z);
|
||||
val r := f32x4::splat(s.radius);
|
||||
return in_front(this.ahead(0, x, y, z) + r, this.ahead(4, x, y, z) + r);
|
||||
}
|
||||
for i in 0..6u {
|
||||
return false if this._x[i] * c.x + this._y[i] * c.y + this._z[i] * c.z + this._d[i] + s.radius < 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
# How far places, a lane each, are in front of four planes from one, as lanes.
|
||||
def frustum::ahead(&this, first: u64, x: f32x4, y: f32x4, z: f32x4): f32x4 {
|
||||
return lanes_at(&this._x[first]) * x + lanes_at(&this._y[first]) * y + lanes_at(&this._z[first]) * z + lanes_at(&this._d[first]);
|
||||
}
|
||||
|
||||
# How far a box's corner furthest in front of each of four planes from one is
|
||||
# in front of it, as lanes.
|
||||
def frustum::ahead_of(&this, first: u64, b: &bounds): f32x4 {
|
||||
val zero := f32x4::splat(0);
|
||||
val x := lanes_at(&this._x[first]);
|
||||
val y := lanes_at(&this._y[first]);
|
||||
val z := lanes_at(&this._z[first]);
|
||||
return x * select(x.less(&zero), f32x4::splat(b.min.x), f32x4::splat(b.max.x))
|
||||
+ y * select(y.less(&zero), f32x4::splat(b.min.y), f32x4::splat(b.max.y))
|
||||
+ z * select(z.less(&zero), f32x4::splat(b.min.z), f32x4::splat(b.max.z)) + lanes_at(&this._d[first]);
|
||||
}
|
||||
|
||||
# Whether something is in front of each of eight planes, by how far it's in
|
||||
# front of each, as lanes.
|
||||
def in_front(first: f32x4, last: f32x4): bool {
|
||||
val zero := f32x4::splat(0);
|
||||
return (first.less(&zero) | last.less(&zero)).none();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#! Contains `geometry`: the shapes of space, made of `linear`'s vectors, and
|
||||
#! what games, their renderers, and their physics ask of them: where a ray first
|
||||
#! meets a plane, a sphere, or a box, which side of a plane something lies on,
|
||||
#! whether boxes and spheres meet or hold a place, and whether a camera's
|
||||
#! frustum reaches something, so only what it might see is drawn.
|
||||
#!
|
||||
#! Space is `linear`'s: right-handed, y up, and a camera looking down its -z. A
|
||||
#! frustum is of a matrix's clip space as `linear`'s projections make it, depth
|
||||
#! from 0 at the near plane to 1 at the far one.
|
||||
#!
|
||||
#! Each shape is of `linear`'s vectors and plain `f32`s, worked as lanes where
|
||||
#! `linear` works them, and a frustum holds its six planes' numbers a lane
|
||||
#! each, so an executable optimized with `-O2` tests a place, a box, or a sphere
|
||||
#! against four planes at once, then the other two. What gives a number of a
|
||||
#! few, as a dot product does, is a number at a time, as `linear`'s `cross` is:
|
||||
#! lanes taken apart to be added, then worked as numbers, ran two to three times
|
||||
#! as slow. The virtual machine works everything a number at a time, in the order
|
||||
#! the lanes do, so either way gives the same answers and the same bits.
|
||||
#!
|
||||
#! A place exactly on a shape's surface is within it: a box holds its corners,
|
||||
#! a sphere the places at its radius, and two boxes touching meet.
|
||||
|
||||
import linear;
|
||||
module geometry;
|
||||
|
||||
|
||||
# The dot product of two vectors, a number at a time, in the order `vec3::dot`
|
||||
# adds them.
|
||||
def dot_of(a: &vec3, b: &vec3): f32 {
|
||||
return a.x * b.x + a.y * b.y + a.z * b.z;
|
||||
}
|
||||
|
||||
# The square of the distance between two places, a number at a time, as the
|
||||
# dot product of `a - b` with itself gives it.
|
||||
def distance_squared(a: &vec3, b: &vec3): f32 {
|
||||
val x := a.x - b.x;
|
||||
val y := a.y - b.y;
|
||||
val z := a.z - b.z;
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
|
||||
# The lesser of two numbers, and the greater: of a NaN, either may be given,
|
||||
# where `math::min` and `math::max` work three times as long to give it.
|
||||
def least(a: f32, b: f32): f32 { return b < a ? b : a; }
|
||||
def most(a: f32, b: f32): f32 { return a < b ? b : a; }
|
||||
|
||||
# Four numbers as lanes, read from where the first lies, which needs no
|
||||
# alignment.
|
||||
def lanes_at(first: &f32): f32x4 {
|
||||
return ((first as *f32) as *f32x4)[0];
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
#! Contains `plane`, a flat surface without end, and which side of one something
|
||||
#! lies on: what bounds a frustum, a floor or a wall a ray meets, and what splits
|
||||
#! a space in two.
|
||||
|
||||
import linear;
|
||||
module geometry;
|
||||
|
||||
#! A plane: the places as far along its normal, a direction of length 1, as
|
||||
#! `distance`. Its front is the side the normal points to.
|
||||
pub struct plane {
|
||||
pub var normal: vec3;
|
||||
pub var distance: f32;
|
||||
}
|
||||
|
||||
#! Which side of a plane something lies on.
|
||||
pub enum side: u8 {
|
||||
front, #! Wholly where the normal points.
|
||||
back, #! Wholly behind.
|
||||
across, #! On both sides, or touching it.
|
||||
}
|
||||
|
||||
#! The plane through a place, facing a direction, made of length 1.
|
||||
pub def plane::through(point: vec3, normal: vec3): plane {
|
||||
val n := normal.normalized();
|
||||
return plane{ n, n.dot(point) };
|
||||
}
|
||||
|
||||
#! The plane through three places, facing where they turn counterclockwise, as
|
||||
#! a triangle's front does.
|
||||
pub def plane::of_points(a: vec3, b: vec3, c: vec3): plane {
|
||||
return plane::through(a, (b - a).cross(c - a));
|
||||
}
|
||||
|
||||
pub def plane::equals(&this, other: &plane): bool {
|
||||
return this.normal == other.normal && this.distance == other.distance;
|
||||
}
|
||||
|
||||
#! How far a place is in front of the plane, negative behind it.
|
||||
pub def plane::distance_to(&this, p: vec3): f32 {
|
||||
return dot_of(&this.normal, &p) - this.distance;
|
||||
}
|
||||
|
||||
#! The plane's place nearest another.
|
||||
pub def plane::closest(&this, p: vec3): vec3 {
|
||||
return p - this.normal * this.distance_to(p);
|
||||
}
|
||||
|
||||
#! The same plane facing the other way.
|
||||
pub def plane::flipped(&this): plane {
|
||||
return plane{ -this.normal, -this.distance };
|
||||
}
|
||||
|
||||
#! Which side of the plane a box lies on: how far its center is in front,
|
||||
#! against how far the box reaches along the normal.
|
||||
pub def plane::side_of(&this, b: bounds): side {
|
||||
val half := b.half_size;
|
||||
return side_at(this.distance_to(b.center), dot_of(&half, &this.normal.abs()));
|
||||
}
|
||||
|
||||
#! Which side of the plane a sphere lies on.
|
||||
pub def plane::side_of(&this, s: sphere): side {
|
||||
return side_at(this.distance_to(s.center), s.radius);
|
||||
}
|
||||
|
||||
# The side of what is centered so far in front of a plane, and reaches so far.
|
||||
def side_at(at: f32, reach: f32): side {
|
||||
return side::front if at > reach;
|
||||
return side::back if at < -reach;
|
||||
return side::across;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
#! Contains `ray`, a half line from a place in a direction, and where it first
|
||||
#! meets a plane, a sphere, or a box, as picking what's under a pointer, a line
|
||||
#! of sight, or a shot asks.
|
||||
|
||||
import std::math;
|
||||
import linear;
|
||||
module geometry;
|
||||
|
||||
#! A half line from a place in a direction. How far along it something lies is
|
||||
#! counted in lengths of its direction, so it's a distance where the direction
|
||||
#! is of length 1, as `toward` makes it.
|
||||
pub struct ray {
|
||||
pub var origin: vec3;
|
||||
pub var direction: vec3;
|
||||
}
|
||||
|
||||
#! The ray from a place toward another, its direction of length 1.
|
||||
pub def ray::toward(origin: vec3, target: vec3): ray {
|
||||
return ray{ origin, (target - origin).normalized() };
|
||||
}
|
||||
|
||||
pub def ray::equals(&this, other: &ray): bool {
|
||||
return this.origin == other.origin && this.direction == other.direction;
|
||||
}
|
||||
|
||||
#! The place so far along it.
|
||||
pub def ray::at(&this, t: f32): vec3 {
|
||||
return this.origin + this.direction * t;
|
||||
}
|
||||
|
||||
#! Its place nearest another, from its origin on.
|
||||
pub def ray::closest(&this, p: vec3): vec3 {
|
||||
val d := &this.direction;
|
||||
val toward := (p.x - this.origin.x) * d.x + (p.y - this.origin.y) * d.y + (p.z - this.origin.z) * d.z;
|
||||
val along := toward / dot_of(d, d);
|
||||
return this.at(along > 0 ? along : 0);
|
||||
}
|
||||
|
||||
#! How far along it it meets a plane, from either side, or none where it runs
|
||||
#! beside the plane or away from it.
|
||||
pub def ray::hit(&this, p: plane): maybe<f32> {
|
||||
val toward := dot_of(&p.normal, &this.direction);
|
||||
return nothing {} if toward == 0;
|
||||
val t := p.distance_to(this.origin) / -toward;
|
||||
return nothing {} if !(t >= 0);
|
||||
return t;
|
||||
}
|
||||
|
||||
#! How far along it it first meets a sphere, 0 where it begins within, or none
|
||||
#! where it passes by or away.
|
||||
pub def ray::hit(&this, s: sphere): maybe<f32> {
|
||||
val d := &this.direction;
|
||||
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 0f if c <= 0;
|
||||
# Outside, and moving away from the center or across it, it never comes nearer.
|
||||
val b := mx * d.x + my * d.y + mz * d.z;
|
||||
return nothing {} if b >= 0;
|
||||
val a := dot_of(d, d);
|
||||
val e := b * b - a * c;
|
||||
return nothing {} if e < 0;
|
||||
return (-b - math::sqrt(e)) / a;
|
||||
}
|
||||
|
||||
#! How far along it it first meets a box, 0 where it begins within, or none
|
||||
#! where it passes by or away: where it is between the box's faces along every
|
||||
#! axis at once. One along a face, in its plane, may meet the box or pass by.
|
||||
pub def ray::hit(&this, b: bounds): maybe<f32> {
|
||||
# Along an axis it doesn't move along, it's between the faces everywhere, or
|
||||
# nowhere, as dividing by zero gives infinities.
|
||||
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 := most(most(least(x0, x1), least(y0, y1)), most(least(z0, z1), 0));
|
||||
val leave := least(least(most(x0, x1), most(y0, y1)), most(z0, z1));
|
||||
return nothing {} if !(enter <= leave);
|
||||
return enter;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#! Contains `sphere`, the places within a distance of a center: what holds a
|
||||
#! body for the quickest test of whether two might meet, their distance against
|
||||
#! the sum of their radii.
|
||||
|
||||
import linear;
|
||||
module geometry;
|
||||
|
||||
#! The places within `radius` of `center`.
|
||||
pub struct sphere {
|
||||
pub var center: vec3;
|
||||
pub var radius: f32;
|
||||
}
|
||||
|
||||
#! The least sphere holding a box: of its center, reaching its corners.
|
||||
pub def sphere::of(b: bounds): sphere {
|
||||
return sphere{ b.center, b.half_size.length };
|
||||
}
|
||||
|
||||
pub def sphere::equals(&this, other: &sphere): bool {
|
||||
return this.center == other.center && this.radius == other.radius;
|
||||
}
|
||||
|
||||
#! Whether a place is within it.
|
||||
pub def sphere::contains(&this, p: vec3): bool {
|
||||
return distance_squared(&p, &this.center) <= this.radius * this.radius;
|
||||
}
|
||||
|
||||
#! Whether it and another sphere meet.
|
||||
pub def sphere::overlaps(&this, other: sphere): bool {
|
||||
val reach := this.radius + other.radius;
|
||||
return distance_squared(&other.center, &this.center) <= reach * reach;
|
||||
}
|
||||
|
||||
#! Whether it and a box meet: whether the box's place nearest its center is
|
||||
#! within it.
|
||||
pub def sphere::overlaps(&this, b: bounds): bool {
|
||||
return this.contains(b.closest(this.center));
|
||||
}
|
||||
Reference in new issue
Block a user