use std::marker::PhantomData;
use crate::{sdf::SDF, utils::AABB, vector::Vector};
#[derive(Copy, Clone)]
pub struct Combinator<const N: usize, V: Vector<N>, A: SDF<N, V>, B: SDF<N, V>> {
pub obj_a: A,
pub ovj_b: B,
pub function: fn(a: f32, b: f32) -> f32,
_phantom: PhantomData<V>,
}
impl<const N: usize, V: Vector<N>, A: SDF<N, V>, B: SDF<N, V>> SDF<N, V>
for Combinator<N, V, A, B>
{
fn dist(&self, p: V) -> f32 {
(self.function)(self.obj_a.dist(p), self.ovj_b.dist(p))
}
fn aabb(&self) -> crate::utils::AABB<N, V> {
let (abb, bbb) = (self.obj_a.aabb(), self.ovj_b.aabb());
AABB {
min: abb.min.cmin(bbb.min),
max: abb.max.cmax(bbb.max),
}
}
}