Struct AttributeChannel

Source
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: String

Caller-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: usize

Number of scalars per vertex. 2 for a UV, 1 for an id.

§blend: Blend

How 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

Source

pub const UNMAPPED: u32 = 4_294_967_295u32

Corner-index marker for a triangle that carries no value.

Source

pub fn new( name: impl Into<String>, values: Vec<f64>, width: usize, blend: Blend, ) -> AttributeChannel

Build a per-vertex channel from flat values.

Source

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.

Source

pub fn is_corner_indexed(&self) -> bool

Whether values are addressed per triangle corner.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> AttributeChannel

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AttributeChannel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for AttributeChannel

Source§

fn eq(&self, other: &AttributeChannel) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for AttributeChannel

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,