FIx the 'Morph' node to not fail on topology changes like holes

This commit is contained in:
Keavon Chambers
2025-04-29 03:30:06 -07:00
parent 0c3cae2ba5
commit 80b8df8d42
4 changed files with 82 additions and 66 deletions

View File

@@ -114,14 +114,22 @@ fn multiply<U: Mul<T>, T>(
}
/// The division operation (÷) calculates the quotient of two numbers.
///
/// Produces 0 if the denominator is 0.
#[node_macro::node(category("Math: Arithmetic"))]
fn divide<U: Div<T>, T>(
fn divide<U: Div<T> + Default + PartialEq, T: Default + PartialEq>(
_: impl Ctx,
#[implementations(f64, &f64, f64, &f64, f32, &f32, f32, &f32, u32, &u32, u32, &u32, DVec2, DVec2, f64)] numerator: U,
#[implementations(f64, f64, f32, f32, u32, u32, DVec2, DVec2, f64)] numerator: U,
#[default(1.)]
#[implementations(f64, f64, &f64, &f64, f32, f32, &f32, &f32, u32, u32, &u32, &u32, DVec2, f64, DVec2)]
#[implementations(f64, f64, f32, f32, u32, u32, DVec2, f64, DVec2)]
denominator: T,
) -> <U as Div<T>>::Output {
) -> <U as Div<T>>::Output
where
<U as Div<T>>::Output: Default,
{
if denominator == T::default() {
return <U as Div<T>>::Output::default();
}
numerator / denominator
}