pub trait Interpolatable: Default + Clone {
// Required method
fn add_with_weight(&mut self, src: &Self, weight: f32);
}Expand description
Trait for data that can be interpolated by subdivision rules.
Implement this for any type you want to subdivide: positions, UVs, colors, normals, scalar weights, custom attributes.
Follows the OpenSubdiv Clear() / AddWithWeight() pattern.
Using a local trait avoids orphan-rule problems that arise with
Mul<f32> on foreign array types.
§Example
use subdiv_kernels::Interpolatable;
#[derive(Default, Clone)]
struct Color { r: f32, g: f32, b: f32, a: f32 }
impl Interpolatable for Color {
fn add_with_weight(&mut self, src: &Self, weight: f32) {
self.r += src.r * weight;
self.g += src.g * weight;
self.b += src.b * weight;
self.a += src.a * weight;
}
}Required Methods§
Sourcefn add_with_weight(&mut self, src: &Self, weight: f32)
fn add_with_weight(&mut self, src: &Self, weight: f32)
Accumulate src scaled by weight into self.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".