pub struct AttributeChannel {
pub name: String,
pub values: Vec<Scalar>,
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<Scalar>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<Scalar>,
width: usize,
blend: Blend,
) -> Self
pub fn new( name: impl Into<String>, values: Vec<Scalar>, width: usize, blend: Blend, ) -> Self
Build a per-vertex channel from flat values.
Sourcepub fn corner_indexed(
name: impl Into<String>,
values: Vec<Scalar>,
width: usize,
blend: Blend,
corner_indices: Vec<u32>,
) -> Self
pub fn corner_indexed( name: impl Into<String>, values: Vec<Scalar>, width: usize, blend: Blend, corner_indices: Vec<u32>, ) -> Self
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<&[Scalar]>
pub fn get(&self, vertex: usize) -> Option<&[Scalar]>
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<&[Scalar]>
pub fn at_corner( &self, mesh_indices: &[u32], corner: usize, ) -> Option<&[Scalar]>
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 more