use crate::compiled::real::LawMinMax;
use glam::Vec3;
#[inline(always)]
pub fn modifier_extrude(child_distance: f32, p_z: f32, half_height: f32) -> f32 {
let w_x = child_distance;
let w_y = p_z.abs() - half_height;
w_x.law_max(w_y).law_min(0.0) + glam::Vec2::new(w_x.law_max(0.0), w_y.law_max(0.0)).length()
}
#[inline(always)]
pub const fn modifier_extrude_point(p: Vec3) -> Vec3 {
Vec3::new(p.x, p.y, 0.0)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_extrude_inside() {
let d = modifier_extrude(-1.0, 0.0, 1.0);
assert!(d < 0.0, "Should be inside extruded shape, got {}", d);
}
#[test]
fn test_extrude_outside_z() {
let d = modifier_extrude(-1.0, 2.0, 0.5);
assert!(d > 0.0, "Should be outside due to Z, got {}", d);
}
#[test]
fn test_extrude_outside_xy() {
let d = modifier_extrude(1.0, 0.0, 1.0);
assert!(d > 0.0, "Should be outside due to XY, got {}", d);
}
#[test]
fn test_extrude_on_surface() {
let d = modifier_extrude(0.0, 1.0, 1.0);
assert!(d.abs() < 0.001, "Should be on surface, got {}", d);
}
}