alice-sdf 2.1.0

ALICE-SDF: 3D/Spatial Data Specialist — Store laws, not polygons. GLSL/WGSL/HLSL transpile, SVO, GPU marching cubes, texture-fit, procedural CSG. Optional bridges to alice-physics / alice-codec / libasp / alice-cache behind features.
Documentation
//! Subtraction operation for SDFs (Deep Fried Edition)
//!
//! # Deep Fried Optimizations
//! - **Forced Inlining**: `#[inline(always)]` guarantees no call overhead.
//!
//! Author: Moroya Sakamoto

use crate::compiled::real::Real;

/// Subtraction of B from A (A minus B)
///
/// # Returns
/// max(d1, -d2)
#[inline(always)]
pub fn sdf_subtraction(d1: f32, d2: f32) -> f32 {
    d1.max(-d2)
}

/// Subtraction of B from A (generic over [`Real`]).
#[inline(always)]
pub fn sdf_subtraction_r<R: Real>(d1: R, d2: R) -> R {
    d1.max(-d2)
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_subtraction() {
        assert_eq!(sdf_subtraction(1.0, 2.0), 1.0); // max(1, -2)
        assert_eq!(sdf_subtraction(1.0, -2.0), 2.0); // max(1, 2)
    }
}