Skip to main content

Interpolatable

Trait Interpolatable 

Source
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§

Source

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".

Implementations on Foreign Types§

Source§

impl Interpolatable for f32

Source§

fn add_with_weight(&mut self, src: &Self, weight: f32)

Source§

impl Interpolatable for f64

Source§

fn add_with_weight(&mut self, src: &Self, weight: f32)

Source§

impl<const N: usize> Interpolatable for [f32; N]
where [f32; N]: Default,

Source§

fn add_with_weight(&mut self, src: &Self, weight: f32)

Source§

impl<const N: usize> Interpolatable for [f64; N]
where [f64; N]: Default,

Source§

fn add_with_weight(&mut self, src: &Self, weight: f32)

Implementors§