math: Implement function to determine Ray hit fallback precision
This commit is contained in:
parent
4d6b3e200f
commit
0273e12902
1 changed files with 14 additions and 1 deletions
|
|
@ -5,7 +5,20 @@ const testing = mach.testing;
|
||||||
const math = mach.math;
|
const math = mach.math;
|
||||||
const vec = @import("vec.zig");
|
const vec = @import("vec.zig");
|
||||||
|
|
||||||
fn maxDim(v: math.Vec3) u32 {
|
// Determine the fallback precision for valid floating point precisions
|
||||||
|
// our Ray computations can have. Will return twice the input precision
|
||||||
|
fn floatFallbackPrecision(comptime float_precision: type) type {
|
||||||
|
switch (float_precision) {
|
||||||
|
f16 => return f32,
|
||||||
|
f32 => return f64,
|
||||||
|
f64 => return f128,
|
||||||
|
else => @compileError("Expected f16, f32, f64, found '" ++
|
||||||
|
@typeName(float_precision) ++ "'"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine the 3D vector dimension with the largest scalar value
|
||||||
|
fn maxDim(v: math.Vec3) u8 {
|
||||||
if (v.v[0] > v.v[1]) {
|
if (v.v[0] > v.v[1]) {
|
||||||
if (v.v[0] > v.v[2]) {
|
if (v.v[0] > v.v[2]) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue