use super::instruction::Instruction;
use super::prim_table::PrimTable;
use super::real::Vec3R;
use super::simd::Vec3x8;
use crate::compiled::real::LawMinMax;
use crate::operations::*;
use crate::primitives::*;
use glam::Vec3;
use wide::{f32x8, CmpGt, CmpLt};
#[allow(unused_variables)]
impl PrimTable for f32x8 {
#[inline(always)]
fn sphere(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
sdf_sphere_r(p, inst.params[0]) * scale_correction
}
#[inline(always)]
fn box3d(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
sdf_box3d_r(p, Vec3::new(inst.params[0], inst.params[1], inst.params[2])) * scale_correction
}
#[inline(always)]
fn cylinder(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
sdf_cylinder_r(p, inst.params[0], inst.params[1]) * scale_correction
}
#[inline(always)]
fn torus(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
sdf_torus_r(p, inst.params[0], inst.params[1]) * scale_correction
}
#[inline(always)]
fn plane(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
sdf_plane_r(
p,
Vec3::new(inst.params[0], inst.params[1], inst.params[2]),
inst.params[3],
) * scale_correction
}
#[inline(always)]
fn capsule(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
sdf_capsule_r(
p,
Vec3::new(inst.params[0], inst.params[1], inst.params[2]),
Vec3::new(inst.params[3], inst.params[4], inst.params[5]),
inst.get_capsule_radius(),
) * scale_correction
}
#[inline(always)]
fn cone(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
sdf_cone_r(p, inst.params[0], inst.params[1]) * scale_correction
}
#[inline(always)]
fn ellipsoid(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
sdf_ellipsoid_r(p, Vec3::new(inst.params[0], inst.params[1], inst.params[2]))
* scale_correction
}
#[inline(always)]
fn rounded_cone(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
sdf_rounded_cone_r(p, inst.params[0], inst.params[1], inst.params[2]) * scale_correction
}
#[inline(always)]
fn pyramid(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
sdf_pyramid_r(p, inst.params[0]) * scale_correction
}
#[inline(always)]
fn octahedron(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
sdf_octahedron_r(p, inst.params[0]) * scale_correction
}
#[inline(always)]
fn hex_prism(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
sdf_hex_prism_r(p, inst.params[0], inst.params[1]) * scale_correction
}
#[inline(always)]
fn link(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
sdf_link_r(p, inst.params[0], inst.params[1], inst.params[2]) * scale_correction
}
#[inline(always)]
fn rounded_box(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let hx = Self::splat(inst.params[0]);
let hy = Self::splat(inst.params[1]);
let hz = Self::splat(inst.params[2]);
let rr = Self::splat(inst.params[3]);
let qx = p.x.abs() - hx;
let qy = p.y.abs() - hy;
let qz = p.z.abs() - hz;
let qx_pos = qx.law_max(Self::ZERO);
let qy_pos = qy.law_max(Self::ZERO);
let qz_pos = qz.law_max(Self::ZERO);
let outer = (qx_pos * qx_pos + qy_pos * qy_pos + qz_pos * qz_pos).sqrt();
let inner = qx.law_max(qy).law_max(qz).law_min(Self::ZERO);
let d = outer + inner - rr;
out = d * scale_correction;
out
}
#[inline(always)]
fn capped_cone(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let h = Self::splat(inst.params[0]);
let r1 = Self::splat(inst.params[1]);
let r2 = Self::splat(inst.params[2]);
let qx = (p.x * p.x + p.z * p.z).sqrt();
let qy = p.y;
let k2x = r2 - r1;
let k2y = h * Self::splat(2.0);
let k2_dot = k2x * k2x + k2y * k2y;
let neg_mask = qy.cmp_lt(Self::ZERO);
let min_r = neg_mask.blend(r1, r2);
let ca_x = qx - qx.law_min(min_r);
let ca_y = qy.abs() - h;
let d_to_k1_x = r2 - qx;
let d_to_k1_y = h - qy;
let num = d_to_k1_x * k2x + d_to_k1_y * k2y;
let safe_k2_dot = k2_dot.law_max(Self::splat(0.0001));
let t = (num / safe_k2_dot).law_max(Self::ZERO).law_min(Self::ONE);
let cb_x = qx - r2 + k2x * t;
let cb_y = qy - h + k2y * t;
let ca_d2 = ca_x * ca_x + ca_y * ca_y;
let cb_d2 = cb_x * cb_x + cb_y * cb_y;
let both_neg = cb_x.cmp_lt(Self::ZERO) & ca_y.cmp_lt(Self::ZERO);
let s = both_neg.blend(Self::splat(-1.0), Self::ONE);
let d = s * ca_d2.law_min(cb_d2).sqrt();
out = d * scale_correction;
out
}
#[inline(always)]
fn capped_torus(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let major_r = Self::splat(inst.params[0]);
let minor_r = Self::splat(inst.params[1]);
let sc_sin = Self::splat(alice_det_math::sin(inst.params[2]));
let sc_cos = Self::splat(alice_det_math::cos(inst.params[2]));
let px = p.x.abs();
let dot_val = sc_sin * px + sc_cos * p.y;
let len_val = (px * px + p.y * p.y).sqrt();
let mask = (sc_cos * px).cmp_gt(sc_sin * p.y);
let k = mask.blend(dot_val, len_val);
let inner =
px * px + p.y * p.y + p.z * p.z + major_r * major_r - Self::splat(2.0) * major_r * k;
let d = inner.law_max(Self::ZERO).sqrt() - minor_r;
out = d * scale_correction;
out
}
#[inline(always)]
fn rounded_cylinder(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let radius = Self::splat(inst.params[0]);
let round_r = Self::splat(inst.params[1]);
let half_h = Self::splat(inst.params[2]);
let dx = (p.x * p.x + p.z * p.z).sqrt() - radius + round_r;
let dy = p.y.abs() - half_h;
let dx_pos = dx.law_max(Self::ZERO);
let dy_pos = dy.law_max(Self::ZERO);
let d = dx.law_max(dy).law_min(Self::ZERO) + (dx_pos * dx_pos + dy_pos * dy_pos).sqrt()
- round_r;
out = d * scale_correction;
out
}
#[inline(always)]
fn triangular_prism(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let width = Self::splat(inst.params[0]);
let half_depth = Self::splat(inst.params[1]);
let qx = p.x.abs();
let qy = p.y; let qz = p.z.abs();
let sqrt3_half = Self::splat(0.866025);
let half = Self::splat(0.5);
let d =
(qz - half_depth).law_max((qx * sqrt3_half + qy * half).law_max(-qy) - width * half);
out = d * scale_correction;
out
}
#[inline(always)]
fn cut_sphere(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let radius = Self::splat(inst.params[0]);
let ch = Self::splat(inst.params[1]); let w = (radius * radius - ch * ch).law_max(Self::ZERO).sqrt();
let qx = (p.x * p.x + p.z * p.z).sqrt();
let qy = p.y;
let q_len = (qx * qx + qy * qy).sqrt();
let s1 = (ch - radius) * qx * qx + w * w * (ch + radius - Self::splat(2.0) * qy);
let s2 = ch * qx - w * qy;
let s = s1.law_max(s2);
let d_sphere = q_len - radius;
let d_plane = ch - qy;
let ex = qx - w;
let ey = qy - ch;
let d_edge = (ex * ex + ey * ey).sqrt();
let mask_s_neg = s.cmp_lt(Self::ZERO);
let mask_qx_lt_w = qx.cmp_lt(w);
let d = mask_s_neg.blend(d_sphere, mask_qx_lt_w.blend(d_plane, d_edge));
out = d * scale_correction;
out
}
#[inline(always)]
fn cut_hollow_sphere(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let radius = Self::splat(inst.params[0]);
let ch = Self::splat(inst.params[1]);
let thickness = Self::splat(inst.params[2]);
let w = (radius * radius - ch * ch).law_max(Self::ZERO).sqrt();
let qx = (p.x * p.x + p.z * p.z).sqrt();
let qy = p.y;
let mask = (ch * qx).cmp_lt(w * qy);
let ex = qx - w;
let ey = qy - ch;
let d_cap = (ex * ex + ey * ey).sqrt() - thickness;
let q_len = (qx * qx + qy * qy).sqrt();
let d_shell = (q_len - radius).abs() - thickness;
let d = mask.blend(d_cap, d_shell);
out = d * scale_correction;
out
}
#[inline(always)]
fn death_star(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let ra = Self::splat(inst.params[0]);
let rb = Self::splat(inst.params[1]);
let dd = Self::splat(inst.params[2]);
let two = Self::splat(2.0);
#[allow(clippy::suspicious_operation_groupings)]
let a = (ra * ra - rb * rb + dd * dd) / (two * dd);
let b = (ra * ra - a * a).law_max(Self::ZERO).sqrt();
let p2x = p.x;
let p2y = (p.y * p.y + p.z * p.z).sqrt();
let lhs = p2x * b - p2y * a;
let rhs = dd * (b - p2y).law_max(Self::ZERO);
let mask = lhs.cmp_gt(rhs);
let ex = p2x - a;
let ey = p2y - b;
let d_edge = (ex * ex + ey * ey).sqrt();
let p2_len = (p2x * p2x + p2y * p2y).sqrt();
let dx = p2x - dd;
let d_ra = p2_len - ra;
let d_rb = -((dx * dx + p2y * p2y).sqrt() - rb);
let d_main = d_ra.law_max(d_rb);
let d = mask.blend(d_edge, d_main);
out = d * scale_correction;
out
}
#[inline(always)]
fn solid_angle(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let c_sin = Self::splat(alice_det_math::sin(inst.params[0]));
let c_cos = Self::splat(alice_det_math::cos(inst.params[0]));
let radius = Self::splat(inst.params[1]);
let qx = (p.x * p.x + p.z * p.z).sqrt();
let qy = p.y;
let q_len = (qx * qx + qy * qy).sqrt();
let l = q_len - radius;
let q_dot_c = (qx * c_sin + qy * c_cos)
.law_max(Self::ZERO)
.law_min(radius);
let proj_x = qx - c_sin * q_dot_c;
let proj_y = qy - c_cos * q_dot_c;
let m = (proj_x * proj_x + proj_y * proj_y).sqrt();
let sign_val = c_cos * qx - c_sin * qy;
let neg_mask = sign_val.cmp_lt(Self::ZERO);
let sign = neg_mask.blend(Self::splat(-1.0), Self::ONE);
let d = l.law_max(m * sign);
out = d * scale_correction;
out
}
#[inline(always)]
fn rhombus(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let la = Self::splat(inst.params[0]);
let lb = Self::splat(inst.params[1]);
let half_h = Self::splat(inst.params[2]);
let rr = Self::splat(inst.params[3]);
let ax = p.x.abs();
let ay = p.y.abs();
let az = p.z.abs();
let b_dot_b = la * la + lb * lb;
let ndot_val = la * (la - Self::splat(2.0) * ax) - lb * (lb - Self::splat(2.0) * az);
let f = (ndot_val / b_dot_b)
.law_max(Self::splat(-1.0))
.law_min(Self::ONE);
let half = Self::splat(0.5);
let proj_x = ax - half * la * (Self::ONE - f);
let proj_z = az - half * lb * (Self::ONE + f);
let qxz_len = (proj_x * proj_x + proj_z * proj_z).sqrt();
let sign_input = ax * lb + az * la - la * lb;
let pos = sign_input.cmp_gt(Self::ZERO);
let neg = sign_input.cmp_lt(Self::ZERO);
let sign = pos.blend(Self::ONE, neg.blend(Self::splat(-1.0), Self::ZERO));
let dx = qxz_len * sign - rr;
let dy = ay - half_h;
let dx_pos = dx.law_max(Self::ZERO);
let dy_pos = dy.law_max(Self::ZERO);
let d = dx.law_max(dy).law_min(Self::ZERO) + (dx_pos * dx_pos + dy_pos * dy_pos).sqrt();
out = d * scale_correction;
out
}
#[inline(always)]
fn horseshoe(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_horseshoe(
pt,
inst.params[0],
inst.params[1],
inst.params[2],
inst.params[3],
inst.params[4],
)
});
out = d * scale_correction;
out
}
#[inline(always)]
fn vesica(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| sdf_vesica(pt, inst.params[0], inst.params[1]));
out = d * scale_correction;
out
}
#[inline(always)]
fn infinite_cylinder(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let r = Self::splat(inst.params[0]);
let d = (p.x * p.x + p.z * p.z).sqrt() - r;
out = d * scale_correction;
out
}
#[inline(always)]
fn infinite_cone(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| sdf_infinite_cone(pt, inst.params[0]));
out = d * scale_correction;
out
}
#[inline(always)]
fn gyroid(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let scale = Self::splat(inst.params[0]);
let thickness = Self::splat(inst.params[1]);
let inv_scale = Self::splat(1.0 / inst.params[0]);
let spx = p.x * scale;
let spy = p.y * scale;
let spz = p.z * scale;
let (sx, cx) = alice_det_math::simd::sin_cos(spx);
let (sy, cy) = alice_det_math::simd::sin_cos(spy);
let (sz, cz) = alice_det_math::simd::sin_cos(spz);
let d = (sx * cy + sy * cz + sz * cx).abs() * inv_scale - thickness;
out = d * scale_correction;
out
}
#[inline(always)]
fn metric_ball(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_metric_ball(
pt,
inst.params[0],
inst.params[1],
inst.params[2],
inst.params[3],
)
});
out = d * scale_correction;
out
}
#[inline(always)]
fn heart(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| sdf_heart(pt, inst.params[0]));
out = d * scale_correction;
out
}
#[inline(always)]
fn tube(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let outer_r = Self::splat(inst.params[0]);
let thickness = Self::splat(inst.params[1]);
let half_h = Self::splat(inst.params[2]);
let xz_len = (p.x * p.x + p.z * p.z).sqrt();
let dx = (xz_len - outer_r).abs() - thickness;
let dy = p.y.abs() - half_h;
let dx_pos = dx.law_max(Self::ZERO);
let dy_pos = dy.law_max(Self::ZERO);
let d = (dx_pos * dx_pos + dy_pos * dy_pos).sqrt() + dx.law_max(dy).law_min(Self::ZERO);
out = d * scale_correction;
out
}
#[inline(always)]
fn barrel(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_barrel(pt, inst.params[0], inst.params[1], inst.params[2])
});
out = d * scale_correction;
out
}
#[inline(always)]
fn diamond(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| sdf_diamond(pt, inst.params[0], inst.params[1]));
out = d * scale_correction;
out
}
#[inline(always)]
fn chamfered_cube(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
let he = Vec3::new(inst.params[0], inst.params[1], inst.params[2]);
sdf_chamfered_cube(pt, he, inst.params[3])
});
out = d * scale_correction;
out
}
#[inline(always)]
fn schwarz_p(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let scale = Self::splat(inst.params[0]);
let thickness = Self::splat(inst.params[1]);
let inv_scale = Self::splat(1.0 / inst.params[0]);
let d = (cos_approx(p.x * scale) + cos_approx(p.y * scale) + cos_approx(p.z * scale)).abs()
* inv_scale
- thickness;
out = d * scale_correction;
out
}
#[inline(always)]
fn superellipsoid(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
let he = Vec3::new(inst.params[0], inst.params[1], inst.params[2]);
sdf_superellipsoid(pt, he, inst.params[3], inst.params[4])
});
out = d * scale_correction;
out
}
#[inline(always)]
fn rounded_x(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_rounded_x(pt, inst.params[0], inst.params[1], inst.params[2])
});
out = d * scale_correction;
out
}
#[inline(always)]
fn pie(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_pie(pt, inst.params[0], inst.params[1], inst.params[2])
});
out = d * scale_correction;
out
}
#[inline(always)]
fn trapezoid(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_trapezoid(
pt,
inst.params[0],
inst.params[1],
inst.params[2],
inst.params[3],
)
});
out = d * scale_correction;
out
}
#[inline(always)]
fn parallelogram(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_parallelogram(
pt,
inst.params[0],
inst.params[1],
inst.params[2],
inst.params[3],
)
});
out = d * scale_correction;
out
}
#[inline(always)]
fn tunnel(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_tunnel(pt, inst.params[0], inst.params[1], inst.params[2])
});
out = d * scale_correction;
out
}
#[inline(always)]
fn uneven_capsule(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_uneven_capsule(
pt,
inst.params[0],
inst.params[1],
inst.params[2],
inst.params[3],
)
});
out = d * scale_correction;
out
}
#[inline(always)]
fn egg(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| sdf_egg(pt, inst.params[0], inst.params[1]));
out = d * scale_correction;
out
}
#[inline(always)]
fn arc_shape(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_arc_shape(
pt,
inst.params[0],
inst.params[1],
inst.params[2],
inst.params[3],
)
});
out = d * scale_correction;
out
}
#[inline(always)]
fn moon(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_moon(
pt,
inst.params[0],
inst.params[1],
inst.params[2],
inst.params[3],
)
});
out = d * scale_correction;
out
}
#[inline(always)]
fn cross_shape(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_cross_shape(
pt,
inst.params[0],
inst.params[1],
inst.params[2],
inst.params[3],
)
});
out = d * scale_correction;
out
}
#[inline(always)]
fn blobby_cross(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_blobby_cross(pt, inst.params[0], inst.params[1])
});
out = d * scale_correction;
out
}
#[inline(always)]
fn parabola_segment(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_parabola_segment(pt, inst.params[0], inst.params[1], inst.params[2])
});
out = d * scale_correction;
out
}
#[inline(always)]
fn regular_polygon(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_regular_polygon(pt, inst.params[0], inst.params[1], inst.params[2])
});
out = d * scale_correction;
out
}
#[inline(always)]
fn star_polygon(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_star_polygon(
pt,
inst.params[0],
inst.params[1],
inst.params[2],
inst.params[3],
)
});
out = d * scale_correction;
out
}
#[inline(always)]
fn stairs(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_stairs(
pt,
inst.params[0],
inst.params[1],
inst.params[2],
inst.params[3],
)
});
out = d * scale_correction;
out
}
#[inline(always)]
fn helix(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let d = eval_per_lane(&p, |pt| {
sdf_helix(
pt,
inst.params[0],
inst.params[1],
inst.params[2],
inst.params[3],
)
});
out = d * scale_correction;
out
}
#[inline(always)]
fn tetrahedron(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let radius = Self::splat(inst.params[0]);
let s = Self::splat(0.577_350_26_f32); let ns = Self::splat(-0.577_350_26_f32);
let d0 = p.x * s + p.y * s + p.z * s;
let d1 = p.x * ns + p.y * ns + p.z * s;
let d2 = p.x * ns + p.y * s + p.z * ns;
let d3 = p.x * s + p.y * ns + p.z * ns;
let d = d0.law_max(d1).law_max(d2).law_max(d3) - radius;
out = d * scale_correction;
out
}
#[inline(always)]
fn dodecahedron(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let radius = Self::splat(inst.params[0]);
let a = Self::splat(0.850_650_8_f32); let b = Self::splat(0.525_731_1_f32); let d0 = (p.y * a + p.z * b).abs();
let d1 = (p.y * a - p.z * b).abs();
let d2 = (p.x * a + p.y * b).abs();
let d3 = (p.x * a - p.y * b).abs();
let d4 = (p.x * b + p.z * a).abs();
let d5 = (p.x * b - p.z * a).abs();
let d = d0
.law_max(d1)
.law_max(d2)
.law_max(d3)
.law_max(d4)
.law_max(d5)
- radius;
out = d * scale_correction;
out
}
#[inline(always)]
fn icosahedron(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let radius = Self::splat(inst.params[0]);
let s = Self::splat(0.577_350_26_f32); let ia = Self::splat(0.525_731_1_f32); let ib = Self::splat(0.850_650_8_f32); let d0 = (p.x * s + p.y * s + p.z * s).abs();
let d1 = (-p.x * s + p.y * s + p.z * s).abs();
let d2 = (p.x * s - p.y * s + p.z * s).abs();
let d3 = (p.x * s + p.y * s - p.z * s).abs();
let d4 = (p.y * ia + p.z * ib).abs();
let d5 = (p.y * ia - p.z * ib).abs();
let d6 = (p.x * ia + p.y * ib).abs();
let d7 = (p.x * ia - p.y * ib).abs();
let d8 = (p.x * ib + p.z * ia).abs();
let d9 = (p.x * ib - p.z * ia).abs();
let d = d0
.law_max(d1)
.law_max(d2)
.law_max(d3)
.law_max(d4)
.law_max(d5)
.law_max(d6)
.law_max(d7)
.law_max(d8)
.law_max(d9)
- radius;
out = d * scale_correction;
out
}
#[inline(always)]
fn truncated_octahedron(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let radius = Self::splat(inst.params[0]);
let s = Self::splat(0.577_350_26_f32);
let d0 = p.x.abs();
let d1 = p.y.abs();
let d2 = p.z.abs();
let d3 = (p.x * s + p.y * s + p.z * s).abs();
let d4 = (-p.x * s + p.y * s + p.z * s).abs();
let d5 = (p.x * s - p.y * s + p.z * s).abs();
let d6 = (p.x * s + p.y * s - p.z * s).abs();
let d = d0
.law_max(d1)
.law_max(d2)
.law_max(d3)
.law_max(d4)
.law_max(d5)
.law_max(d6)
- radius;
out = d * scale_correction;
out
}
#[inline(always)]
fn truncated_icosahedron(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let radius = Self::splat(inst.params[0]);
let s = Self::splat(0.577_350_26_f32);
let ia = Self::splat(0.525_731_1_f32);
let ib = Self::splat(0.850_650_8_f32);
let d0 = (p.x * s + p.y * s + p.z * s).abs();
let d1 = (-p.x * s + p.y * s + p.z * s).abs();
let d2 = (p.x * s - p.y * s + p.z * s).abs();
let d3 = (p.x * s + p.y * s - p.z * s).abs();
let d4 = (p.y * ia + p.z * ib).abs();
let d5 = (p.y * ia - p.z * ib).abs();
let d6 = (p.x * ia + p.y * ib).abs();
let d7 = (p.x * ia - p.y * ib).abs();
let d8 = (p.x * ib + p.z * ia).abs();
let d9 = (p.x * ib - p.z * ia).abs();
let d10 = (p.y * ib + p.z * ia).abs();
let d11 = (p.y * ib - p.z * ia).abs();
let d12 = (p.x * ib + p.y * ia).abs();
let d13 = (p.x * ib - p.y * ia).abs();
let d14 = (p.x * ia + p.z * ib).abs();
let d15 = (p.x * ia - p.z * ib).abs();
let d = d0
.law_max(d1)
.law_max(d2)
.law_max(d3)
.law_max(d4)
.law_max(d5)
.law_max(d6)
.law_max(d7)
.law_max(d8)
.law_max(d9)
.law_max(d10)
.law_max(d11)
.law_max(d12)
.law_max(d13)
.law_max(d14)
.law_max(d15)
- radius;
out = d * scale_correction;
out
}
#[inline(always)]
fn box_frame(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let bx = Self::splat(inst.params[0]);
let by = Self::splat(inst.params[1]);
let bz = Self::splat(inst.params[2]);
let e = Self::splat(inst.params[3]);
let zero = Self::ZERO;
let px = p.x.abs() - bx;
let py = p.y.abs() - by;
let pz = p.z.abs() - bz;
let qx = (px + e).abs() - e;
let qy = (py + e).abs() - e;
let qz = (pz + e).abs() - e;
let v1x = px.law_max(zero);
let v1y = qy.law_max(zero);
let v1z = qz.law_max(zero);
let d1 =
(v1x * v1x + v1y * v1y + v1z * v1z).sqrt() + px.law_max(qy.law_max(qz)).law_min(zero);
let v2x = qx.law_max(zero);
let v2y = py.law_max(zero);
let v2z = qz.law_max(zero);
let d2 =
(v2x * v2x + v2y * v2y + v2z * v2z).sqrt() + qx.law_max(py.law_max(qz)).law_min(zero);
let v3x = qx.law_max(zero);
let v3y = qy.law_max(zero);
let v3z = pz.law_max(zero);
let d3 =
(v3x * v3x + v3y * v3y + v3z * v3z).sqrt() + qx.law_max(qy.law_max(pz)).law_min(zero);
let d = d1.law_min(d2).law_min(d3);
out = d * scale_correction;
out
}
#[inline(always)]
fn diamond_surface(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let scale = Self::splat(inst.params[0]);
let thickness = Self::splat(inst.params[1]);
let inv_scale = Self::splat(1.0 / inst.params[0]);
let spx = p.x * scale;
let spy = p.y * scale;
let spz = p.z * scale;
let (sx, cx) = alice_det_math::simd::sin_cos(spx);
let (sy, cy) = alice_det_math::simd::sin_cos(spy);
let (sz, cz) = alice_det_math::simd::sin_cos(spz);
let d = sx * sy * sz + sx * cy * cz + cx * sy * cz + cx * cy * sz;
let d = d.abs() * inv_scale - thickness;
out = d * scale_correction;
out
}
#[inline(always)]
fn neovius(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let scale = Self::splat(inst.params[0]);
let thickness = Self::splat(inst.params[1]);
let inv_scale = Self::splat(1.0 / inst.params[0]);
let three = Self::splat(3.0);
let four = Self::splat(4.0);
let cx = cos_approx(p.x * scale);
let cy = cos_approx(p.y * scale);
let cz = cos_approx(p.z * scale);
let d = three * (cx + cy + cz) + four * cx * cy * cz;
let d = d.abs() * inv_scale - thickness;
out = d * scale_correction;
out
}
#[inline(always)]
fn lidinoid(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let scale = Self::splat(inst.params[0]);
let thickness = Self::splat(inst.params[1]);
let inv_scale = Self::splat(1.0 / inst.params[0]);
let two = Self::splat(2.0);
let one = Self::ONE;
let half = Self::splat(0.5);
let spx = p.x * scale;
let spy = p.y * scale;
let spz = p.z * scale;
let (sx, cx) = alice_det_math::simd::sin_cos(spx);
let (sy, cy) = alice_det_math::simd::sin_cos(spy);
let (sz, cz) = alice_det_math::simd::sin_cos(spz);
let s2x = two * sx * cx;
let s2y = two * sy * cy;
let s2z = two * sz * cz;
let c2x = two * cx * cx - one;
let c2y = two * cy * cy - one;
let c2z = two * cz * cz - one;
let term1 = half * (s2x * cy * sz + sx * s2y * cz + cx * sy * s2z);
let term2 = half * (c2x * c2y + c2y * c2z + c2z * c2x);
let d = (term1 - term2 + Self::splat(0.15)).abs() * inv_scale - thickness;
out = d * scale_correction;
out
}
#[inline(always)]
fn iwp(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let scale = Self::splat(inst.params[0]);
let thickness = Self::splat(inst.params[1]);
let inv_scale = Self::splat(1.0 / inst.params[0]);
let two = Self::splat(2.0);
let one = Self::ONE;
let cx = cos_approx(p.x * scale);
let cy = cos_approx(p.y * scale);
let cz = cos_approx(p.z * scale);
let c2x = two * cx * cx - one;
let c2y = two * cy * cy - one;
let c2z = two * cz * cz - one;
let d = two * (cx * cy + cy * cz + cz * cx) - (c2x + c2y + c2z);
let d = d.abs() * inv_scale - thickness;
out = d * scale_correction;
out
}
#[inline(always)]
fn frd(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let scale = Self::splat(inst.params[0]);
let thickness = Self::splat(inst.params[1]);
let inv_scale = Self::splat(1.0 / inst.params[0]);
let two = Self::splat(2.0);
let one = Self::ONE;
let spx = p.x * scale;
let spy = p.y * scale;
let spz = p.z * scale;
let (sx, cx) = alice_det_math::simd::sin_cos(spx);
let (sy, cy) = alice_det_math::simd::sin_cos(spy);
let (sz, cz) = alice_det_math::simd::sin_cos(spz);
let c2x = two * cx * cx - one;
let c2y = two * cy * cy - one;
let c2z = two * cz * cz - one;
let d = c2x * sy * cz + cx * c2y * sz + sx * cy * c2z;
let d = d.abs() * inv_scale - thickness;
out = d * scale_correction;
out
}
#[inline(always)]
fn fischer_koch_s(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let scale = Self::splat(inst.params[0]);
let thickness = Self::splat(inst.params[1]);
let inv_scale = Self::splat(1.0 / inst.params[0]);
let two = Self::splat(2.0);
let one = Self::ONE;
let spx = p.x * scale;
let spy = p.y * scale;
let spz = p.z * scale;
let (sx, cx) = alice_det_math::simd::sin_cos(spx);
let (sy, cy) = alice_det_math::simd::sin_cos(spy);
let (sz, cz) = alice_det_math::simd::sin_cos(spz);
let c2x = two * cx * cx - one;
let c2y = two * cy * cy - one;
let c2z = two * cz * cz - one;
let d = c2x * sy * cz + cx * c2y * sz + sx * cy * c2z - Self::splat(0.4);
let d = d.abs() * inv_scale - thickness;
out = d * scale_correction;
out
}
#[inline(always)]
fn pmy(inst: &Instruction, aux_data: &[f32], p: Vec3R<Self>, scale_correction: Self) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let scale = Self::splat(inst.params[0]);
let thickness = Self::splat(inst.params[1]);
let inv_scale = Self::splat(1.0 / inst.params[0]);
let two = Self::splat(2.0);
let spx = p.x * scale;
let spy = p.y * scale;
let spz = p.z * scale;
let (sx, cx) = alice_det_math::simd::sin_cos(spx);
let (sy, cy) = alice_det_math::simd::sin_cos(spy);
let (sz, cz) = alice_det_math::simd::sin_cos(spz);
let s2x = two * sx * cx;
let s2y = two * sy * cy;
let s2z = two * sz * cz;
let d = two * cx * cy * cz + s2x * sy + sx * s2z + s2y * sz;
let d = d.abs() * inv_scale - thickness;
out = d * scale_correction;
out
}
#[inline(always)]
fn circle_2d(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let r = Self::splat(inst.params[0]);
let half_h = Self::splat(inst.params[1]);
let d2d = (p.x * p.x + p.y * p.y).sqrt() - r;
let dz = p.z.abs() - half_h;
let wx = d2d.law_max(Self::ZERO);
let wy = dz.law_max(Self::ZERO);
let d = (wx * wx + wy * wy).sqrt() + d2d.law_max(dz).law_min(Self::ZERO);
out = d * scale_correction;
out
}
#[inline(always)]
fn rect_2d(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let hx = Self::splat(inst.params[0]);
let hy = Self::splat(inst.params[1]);
let half_h = Self::splat(inst.params[2]);
let dx = p.x.abs() - hx;
let dy = p.y.abs() - hy;
let d2d = (dx.law_max(Self::ZERO) * dx.law_max(Self::ZERO)
+ dy.law_max(Self::ZERO) * dy.law_max(Self::ZERO))
.sqrt()
+ dx.law_max(dy).law_min(Self::ZERO);
let dz = p.z.abs() - half_h;
let wx = d2d.law_max(Self::ZERO);
let wy = dz.law_max(Self::ZERO);
let d = (wx * wx + wy * wy).sqrt() + d2d.law_max(dz).law_min(Self::ZERO);
out = d * scale_correction;
out
}
#[inline(always)]
fn segment_2d(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let a = glam::Vec2::new(inst.params[0], inst.params[1]);
let b = glam::Vec2::new(inst.params[2], inst.params[3]);
let (thickness, half_h) = (inst.params[4], inst.params[5]);
let d = eval_per_lane(&p, |q| sdf_segment_2d(q, a, b, thickness, half_h));
out = d * scale_correction;
out
}
#[inline(always)]
fn polygon_2d(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let aux_off = inst.aux_offset as usize;
let flat = &aux_data[aux_off..aux_off + inst.aux_len as usize];
let half_h = inst.params[0];
let d = eval_per_lane(&p, |q| sdf_polygon_2d_flat(q, flat, half_h));
out = d * scale_correction;
out
}
#[inline(always)]
fn rounded_rect_2d(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let hx = Self::splat(inst.params[0]);
let hy = Self::splat(inst.params[1]);
let round_r = Self::splat(inst.params[2]);
let half_h = Self::splat(inst.params[3]);
let dx = p.x.abs() - hx + round_r;
let dy = p.y.abs() - hy + round_r;
let d2d = (dx.law_max(Self::ZERO) * dx.law_max(Self::ZERO)
+ dy.law_max(Self::ZERO) * dy.law_max(Self::ZERO))
.sqrt()
+ dx.law_max(dy).law_min(Self::ZERO)
- round_r;
let dz = p.z.abs() - half_h;
let wx = d2d.law_max(Self::ZERO);
let wy = dz.law_max(Self::ZERO);
let d = (wx * wx + wy * wy).sqrt() + d2d.law_max(dz).law_min(Self::ZERO);
out = d * scale_correction;
out
}
#[inline(always)]
fn annular_2d(
inst: &Instruction,
aux_data: &[f32],
p: Vec3R<Self>,
scale_correction: Self,
) -> Self {
let p: Vec3x8 = p.into();
#[allow(clippy::needless_late_init, unused_variables)]
let out;
let outer_r = Self::splat(inst.params[0]);
let thickness = Self::splat(inst.params[1]);
let half_h = Self::splat(inst.params[2]);
let d2d = ((p.x * p.x + p.y * p.y).sqrt() - outer_r).abs() - thickness;
let dz = p.z.abs() - half_h;
let wx = d2d.law_max(Self::ZERO);
let wy = dz.law_max(Self::ZERO);
let d = (wx * wx + wy * wy).sqrt() + d2d.law_max(dz).law_min(Self::ZERO);
out = d * scale_correction;
out
}
#[inline(always)]
fn union(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_union_r(a, b)
}
#[inline(always)]
fn intersection(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_intersection_r(a, b)
}
#[inline(always)]
fn subtraction(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_subtraction_r(a, b)
}
#[inline(always)]
fn smooth_union(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_smooth_union_rk_r(a, b, inst.params[0], inst.params[1])
}
#[inline(always)]
fn smooth_intersection(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_smooth_intersection_rk_r(a, b, inst.params[0], inst.params[1])
}
#[inline(always)]
fn smooth_subtraction(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_smooth_subtraction_rk_r(a, b, inst.params[0], inst.params[1])
}
#[inline(always)]
fn chamfer_union(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_chamfer_union_r(a, b, inst.params[0])
}
#[inline(always)]
fn chamfer_intersection(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_chamfer_intersection_r(a, b, inst.params[0])
}
#[inline(always)]
fn chamfer_subtraction(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_chamfer_subtraction_r(a, b, inst.params[0])
}
#[inline(always)]
fn stairs_union(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_stairs_union_r(a, b, inst.params[0], inst.params[1])
}
#[inline(always)]
fn stairs_intersection(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_stairs_intersection_r(a, b, inst.params[0], inst.params[1])
}
#[inline(always)]
fn stairs_subtraction(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_stairs_subtraction_r(a, b, inst.params[0], inst.params[1])
}
#[inline(always)]
fn xor(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_xor_r(a, b)
}
#[inline(always)]
fn morph(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_morph_r(a, b, inst.params[0])
}
#[inline(always)]
fn columns_union(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_columns_union_r(a, b, inst.params[0], inst.params[1])
}
#[inline(always)]
fn columns_intersection(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_columns_intersection_r(a, b, inst.params[0], inst.params[1])
}
#[inline(always)]
fn columns_subtraction(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_columns_subtraction_r(a, b, inst.params[0], inst.params[1])
}
#[inline(always)]
fn pipe(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_pipe_r(a, b, inst.params[0])
}
#[inline(always)]
fn engrave(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_engrave_r(a, b, inst.params[0])
}
#[inline(always)]
fn groove(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_groove_r(a, b, inst.params[0], inst.params[1])
}
#[inline(always)]
fn tongue(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_tongue_r(a, b, inst.params[0], inst.params[1])
}
#[inline(always)]
fn exp_smooth_union(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_exp_smooth_union_r(a, b, inst.params[0])
}
#[inline(always)]
fn exp_smooth_intersection(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_exp_smooth_intersection_r(a, b, inst.params[0])
}
#[inline(always)]
fn exp_smooth_subtraction(inst: &Instruction, a: Self, b: Self) -> Self {
sdf_exp_smooth_subtraction_r(a, b, inst.params[0])
}
}
#[inline(always)]
fn eval_per_lane(p: &Vec3x8, f: impl Fn(Vec3) -> f32) -> f32x8 {
let px = p.x.as_array_ref();
let py = p.y.as_array_ref();
let pz = p.z.as_array_ref();
let mut results = [0.0f32; 8];
for i in 0..8 {
results[i] = f(Vec3::new(px[i], py[i], pz[i]));
}
f32x8::new(results)
}
#[inline(always)]
fn cos_approx(x: f32x8) -> f32x8 {
alice_det_math::simd::cos(x)
}