pub struct Mesh { /* private fields */ }Expand description
A prototype’s geometry in its own local space.
Its primitive list changes only through crate::World::rebuild_primitives and crate::World::edit_mesh, which
keep every per-primitive component (material variants, dialect provenance) in step: a mesh is built whole
(Mesh::new), read (Mesh::primitives) and edited one primitive at a time, field by field
(Mesh::primitives_mut, Mesh::primitive_mut: a PrimitiveMut edits a primitive’s streams, indices,
topology and material, and cannot replace, reorder, add or remove primitives, so per-primitive components stay with
the primitive they describe).
Each mesh built with Mesh::new has an identity of its own, which a clone and an edit in place keep, so the
conservation diagnostics (crate::ledger) tell a mesh edited in place from one replaced by another. Equality and
Debug ignore it; nothing writes it.
Implementations§
Source§impl Mesh
impl Mesh
pub fn new(primitives: Vec<Primitive>) -> Self
pub fn primitives(&self) -> &[Primitive]
Sourcepub fn primitives_mut(
&mut self,
) -> impl ExactSizeIterator<Item = PrimitiveMut<'_>>
pub fn primitives_mut( &mut self, ) -> impl ExactSizeIterator<Item = PrimitiveMut<'_>>
The primitives, each editable field by field in place (see PrimitiveMut).
Sourcepub fn primitive_mut(&mut self, i: usize) -> Option<PrimitiveMut<'_>>
pub fn primitive_mut(&mut self, i: usize) -> Option<PrimitiveMut<'_>>
Primitive i, editable field by field in place; None past the last.
pub fn into_primitives(self) -> Vec<Primitive>
Trait Implementations§
Source§impl Component for Mesh
impl Component for Mesh
Source§const VERSION: u32 = 2
const VERSION: u32 = 2
Version 2 gives tangent streams a set index, serialized like TexCoord(n).
Source§fn apply_linear(&self, l: &Linear) -> Linearity<Self>
fn apply_linear(&self, l: &Linear) -> Linearity<Self>
Every stream mapped by its meaning’s rule (Semantic::moves, crate::Linear); triangles reversed under a
mirror. A mesh with normals or tangents cannot follow a singular map (crate::Linear::singular): unsupported.
Source§fn payload_bytes(&self) -> u64
fn payload_bytes(&self) -> u64
Every stream’s bytes and 4 bytes per index.
Source§fn verify(&self, e: Entity, w: &World) -> Result<(), String>
fn verify(&self, e: Entity, w: &World) -> Result<(), String>
Each primitive whole: a position stream of points (and every other stream that moves as a point, three floats),
every stream as long as it (one value per vertex), indices
within it, whole triangles or lines; and float streams finite (glTF and every writer we have refuse NaN and
infinity). Joint and weight streams mean a skin: only on an entity with a core.skin, which checks them.
Source§fn to_json(&self) -> Result<Option<Value>, JsonError>
fn to_json(&self) -> Result<Option<Value>, JsonError>
A summary, not the vertex data: per primitive its topology, vertex and index counts, streams and material.
const NAME: &'static str = "core.mesh"
Source§const GEOMETRY: Geometry = crate::Geometry::None
const GEOMETRY: Geometry = crate::Geometry::None
Geometry). Stated by every component,
with no default, so data that describes a mesh can’t be left behind by an edit of it unawares: the World’s edit
paths take it from there.Source§fn references(&self, out: &mut Vec<Entity>)
fn references(&self, out: &mut Vec<Entity>)
out: the edges
World::closure follows. A component holding entity references must declare every one of them.Source§fn remap_primitives(&self, _from: &[usize]) -> Option<Result<Self, String>>
fn remap_primitives(&self, _from: &[usize]) -> Option<Result<Self, String>>
Geometry::PerPrimitive, Geometry::PerVertex): new primitive i comes from old primitive
from[i] (a source may repeat, when a primitive is split, or be absent, when one is dropped). Such a component
always answers (a value holding nothing per primitive answers with itself); None, the default, is for
components of Geometry::None, and World::remap_primitives refuses a dependent component that gives it.
An index the component does not have is an error. remap_list does the work for a list with one entry per
primitive.Source§fn remap_vertices(
&self,
_primitive: usize,
_from: &[u32],
) -> Option<Result<Self, String>>
fn remap_vertices( &self, _primitive: usize, _from: &[u32], ) -> Option<Result<Self, String>>
primitive were compacted or reordered, for a
component that holds something per vertex (Geometry::PerVertex): new vertex i of that primitive is old
vertex from[i] (a source may repeat or be absent). Such a component always answers (with itself when it holds
nothing for that primitive); None, the default, is for the others, and World::remap_vertices refuses a
per-vertex component that gives it. An index the component does not have is an error. Every pass that compacts
or reorders a primitive’s vertices calls World::remap_vertices. After a rebuild of the primitive list
(World::rebuild_primitives, Component::remap_primitives) a primitive’s per-vertex data is its source
primitive’s, and the vertex map is relative to that source.Source§fn blend_vertices(
&self,
_primitive: usize,
_from: &[VertexBlend],
) -> Option<Result<Self, String>>
fn blend_vertices( &self, _primitive: usize, _from: &[VertexBlend], ) -> Option<Result<Self, String>>
primitive were rebuilt as blends of old ones
(VertexBlend), for a component that holds something per vertex (Geometry::PerVertex): new vertex i
is the combination from[i] of old vertices, in whatever way the component’s data combines (a morph target’s
delta is interpolated, the way the surface it moves is). It answers as Component::remap_vertices does: with
itself when it holds nothing for that primitive; None, the default, is for a component that does not know how
to combine its data, and World::blend_vertices refuses a per-vertex component that gives it. An index the
component does not have is an error. A vertex that is a copy of one old vertex (VertexBlend::copy) is the
case Component::remap_vertices states, and a component answering one answers the other alike.Source§fn restate(&self, _resolved: &Resolved<'_>) -> Restated<Self>
fn restate(&self, _resolved: &Resolved<'_>) -> Restated<Self>
resolve-state (crate::state::ResolveState) gave the axes in resolved their values: a
component that holds crate::state::Clauses of its own (a record of parts each present in some states) reduces
them as core.condition is reduced (crate::state::Resolved::reduce: a clause that fails is dropped, a clause
left with no literal holds whatever the other axes are). Restated::Absent says the entity is not present in
this state (every clause failed): it is despawned as one whose core.condition fails is. The default holds no
clause: Restated::Unchanged.