use crate::Index;
#[derive(Debug, Clone, Copy, Default)]
pub struct FVarChannelDescriptor<'a> {
pub num_values: usize,
pub value_indices: &'a [Index],
}
impl<'a> FVarChannelDescriptor<'a> {
pub fn new(num_values: usize, value_indices: &'a [Index]) -> Self {
Self {
num_values,
value_indices,
}
}
}
#[derive(Debug, Clone, Copy, Default)]
pub struct TopologyDescriptor<'a> {
pub num_vertices: usize,
pub num_verts_per_face: &'a [usize],
pub vert_indices_per_face: &'a [Index],
pub crease_vertex_index_pairs: &'a [[Index; 2]],
pub crease_weights: &'a [f32],
pub corner_vertex_indices: &'a [Index],
pub corner_weights: &'a [f32],
pub hole_indices: &'a [Index],
pub fvar_channels: &'a [FVarChannelDescriptor<'a>],
}
impl<'a> TopologyDescriptor<'a> {
pub fn new(
num_vertices: usize,
num_verts_per_face: &'a [usize],
vert_indices_per_face: &'a [Index],
) -> Self {
TopologyDescriptor {
num_vertices,
num_verts_per_face,
vert_indices_per_face,
..Default::default()
}
}
pub fn with_creases(mut self, vertex_pairs: &'a [[Index; 2]], weights: &'a [f32]) -> Self {
self.crease_vertex_index_pairs = vertex_pairs;
self.crease_weights = weights;
self
}
pub fn with_corners(mut self, vertices: &'a [Index], weights: &'a [f32]) -> Self {
self.corner_vertex_indices = vertices;
self.corner_weights = weights;
self
}
pub fn with_holes(mut self, hole_indices: &'a [Index]) -> Self {
self.hole_indices = hole_indices;
self
}
pub fn with_fvar_channels(mut self, channels: &'a [FVarChannelDescriptor<'a>]) -> Self {
self.fvar_channels = channels;
self
}
}