pub struct AttributeChannel {
pub name: String,
pub values: Vec<f64>,
pub width: usize,
pub blend: Blend,
pub corner_indices: Option<Vec<u32>>,
}Expand description
Per-vertex or per-corner values under a caller-chosen name.
Per-vertex (the default, corner_indices: None): one tuple per position.
Per-corner (corner_indices: Some): one index into values for every
triangle corner, mirroring crate::NormalAttribute::indices. This is
how source formats store texture coordinates: a box corner shared by
three faces carries a different UV in each (#112). Positions stay shared,
so the mesh’s adjacency and closure do not depend on attribute seams.
Invariants are checked by crate::TriMesh::validate_structure rather
than enforced at construction, matching how this crate treats dirty
imported data: representable, then validated at a trust boundary.
Fields§
§name: StringCaller-chosen identifier, unique within a mesh.
values: Vec<f64>Scalar tuples, width entries each: one per vertex, or the pool the
corner indices point into.
width: usizeNumber of scalars per vertex. 2 for a UV, 1 for an id.
blend: BlendHow values may be combined when a vertex is created.
corner_indices: Option<Vec<u32>>Optional per-corner tuple indices, one per entry of the mesh’s
indices. None means the channel is per-vertex.
A triangle whose three entries are all Self::UNMAPPED carries no
value – real files texture only some faces. A triangle mixing
mapped and unmapped corners is invalid: it would have a value at
some corners and nothing to interpolate towards at the others.
Implementations§
Source§impl AttributeChannel
impl AttributeChannel
Sourcepub const UNMAPPED: u32 = 4_294_967_295u32
pub const UNMAPPED: u32 = 4_294_967_295u32
Corner-index marker for a triangle that carries no value.
Sourcepub fn new(
name: impl Into<String>,
values: Vec<f64>,
width: usize,
blend: Blend,
) -> AttributeChannel
pub fn new( name: impl Into<String>, values: Vec<f64>, width: usize, blend: Blend, ) -> AttributeChannel
Build a per-vertex channel from flat values.
Sourcepub fn corner_indexed(
name: impl Into<String>,
values: Vec<f64>,
width: usize,
blend: Blend,
corner_indices: Vec<u32>,
) -> AttributeChannel
pub fn corner_indexed( name: impl Into<String>, values: Vec<f64>, width: usize, blend: Blend, corner_indices: Vec<u32>, ) -> AttributeChannel
Build a per-corner channel: corner_indices[c] selects the tuple for
triangle corner c, or is Self::UNMAPPED.
Sourcepub fn is_corner_indexed(&self) -> bool
pub fn is_corner_indexed(&self) -> bool
Whether values are addressed per triangle corner.
Sourcepub fn value_count(&self) -> usize
pub fn value_count(&self) -> usize
Number of tuples in values.
Returns 0 for a zero width rather than dividing by it, so a
malformed channel is inspectable instead of panicking.
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Number of vertices a per-vertex channel covers.
The same as Self::value_count; kept for per-vertex callers, where
a tuple IS a vertex.
Sourcepub fn get(&self, vertex: usize) -> Option<&[f64]>
pub fn get(&self, vertex: usize) -> Option<&[f64]>
The tuple at a values index, or None when out of range.
For a per-vertex channel the index is a vertex. For a per-corner one
it is an entry of corner_indices; use Self::at_corner to go
from a mesh corner to its value.
Sourcepub fn at_corner(&self, mesh_indices: &[u32], corner: usize) -> Option<&[f64]>
pub fn at_corner(&self, mesh_indices: &[u32], corner: usize) -> Option<&[f64]>
The tuple at triangle corner corner of a mesh whose index buffer is
mesh_indices, whichever way the channel is addressed.
None for an unmapped corner or any out-of-range index. That makes
“no value here” a result the caller has to handle, never a zero.
Trait Implementations§
Source§impl Clone for AttributeChannel
impl Clone for AttributeChannel
Source§fn clone(&self) -> AttributeChannel
fn clone(&self) -> AttributeChannel
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AttributeChannel
impl Debug for AttributeChannel
Source§impl PartialEq for AttributeChannel
impl PartialEq for AttributeChannel
impl StructuralPartialEq for AttributeChannel
Auto Trait Implementations§
impl Freeze for AttributeChannel
impl RefUnwindSafe for AttributeChannel
impl Send for AttributeChannel
impl Sync for AttributeChannel
impl Unpin for AttributeChannel
impl UnwindSafe for AttributeChannel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more