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;
12use super::types::CsgIntersection;
13
14impl ImplicitSurface for CsgIntersection {
15 fn sdf(&self, p: [f64; 3]) -> f64 {
16 self.a.sdf(p).max(self.b.sdf(p))
17 }
18 fn gradient(&self, p: [f64; 3]) -> [f64; 3] {
19 if self.a.sdf(p) > self.b.sdf(p) {
20 self.a.gradient(p)
21 } else {
22 self.b.gradient(p)
23 }
24 }
25}