Skip to main content

oxiphysics_geometry/csg/
csgintersection_traits.rs

1//! # CsgIntersection - Trait Implementations
2//!
3//! This module contains trait implementations for `CsgIntersection`.
4//!
5//! ## Implemented Traits
6//!
7//! - `ImplicitSurface`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use super::functions::ImplicitSurface;
12#[allow(unused_imports)]
13use super::functions::*;
14use super::types::CsgIntersection;
15
16impl ImplicitSurface for CsgIntersection {
17    fn sdf(&self, p: [f64; 3]) -> f64 {
18        self.a.sdf(p).max(self.b.sdf(p))
19    }
20    fn gradient(&self, p: [f64; 3]) -> [f64; 3] {
21        if self.a.sdf(p) > self.b.sdf(p) {
22            self.a.gradient(p)
23        } else {
24            self.b.gradient(p)
25        }
26    }
27}