Skip to main content

Geometry

Enum Geometry 

Source
pub enum Geometry<'a> {
    Flat {
        vertices: Cow<'a, [u8]>,
        uv_range: UvRange,
        indices: Cow<'a, [u32]>,
        clusters: MeshClusters,
        flags: u32,
    },
    Dag {
        uv_range: UvRange,
        levels: Vec<Cow<'a, [u8]>>,
        dag: ClusterDag,
        flags: u32,
    },
}
Expand description

One resident mesh’s geometry, as the renderer needs it: triangles for a vertex stage, clusters for a mesh stage, and nothing else.

The clusters are supplied rather than built, because building them is crcbl-scene’s build_meshlets and the renderer must not depend on that crate — §3.5 makes the meshlet build a bake step for exactly that reason.

Variants§

§

Flat

A mesh with no level hierarchy: one vertex range, one index range, one run of clusters, drawn from every camera.

Fields

§vertices: Cow<'a, [u8]>

Vertices as mesh::MeshVertex bytes — mesh::VERTEX_STRIDE per vertex, little-endian, exactly what cube_vertex_bytes produces.

Interleaved, which is not how the pool stores them. A record is a position and then its attributes; crate::MeshPool::upload separates the two streams, so a caller describes geometry once and the position region reaches the device contiguous.

§uv_range: UvRange

The scale and offset every UV lane in vertices was quantised against — UvRange::from_uvs over the mesh’s float coordinates, before any vertex was built.

It has to travel with the bytes: a unorm16 lane means nothing without it, and the pool cannot recover it from lanes that are already quantised. It reaches the shaders through mesh::GpuMesh::uv_range.

§indices: Cow<'a, [u32]>

Triangle indices into vertices, mesh-relative: the pool’s base vertex is added by the shader through the mesh table.

§clusters: MeshClusters

The same triangles partitioned for a mesh stage. Read on GeometryPath::MeshShader and on no other path.

§flags: u32

Per-mesh bits for mesh::GpuMesh::flags — today only MESH_AUTHORED_TANGENTS.

Zero is the honest value for a caller that builds its vertices with mesh::MeshVertex::from_normal, which is every mesh this engine authors for itself: that constructor fills the frame with orthonormal_basis’ stand-in, which is orthonormal and agrees with no UV parameterisation, so a normal map read through it would be rotated by an angle nobody chose. Setting the bit is a claim that these vertices came from a real TANGENT, and the fragment stage takes the caller at its word — the screen-space derivative frame is what it falls back to otherwise.

§

Dag

Topic 25’s cluster DAG: several levels of one surface, each its own vertex range, with the grouping that relates them.

§A coarse level has no attributes, and the caller has to supply them

crcbl_scene::simplify is position-only and says so in its own module docs: a coarser level’s vertices are wherever the collapses put them and belong to no vertex of the level below, so the decimator carries no normals and no UVs. ClusterDag therefore holds positions, and this variant’s levels is where the attributes come back — one vertex-byte array per level, which the caller produces however it can.

demo’s dunes patch can do it because the surface is analytic: crcbl_shaders::dunes::vertex_at evaluates the height field at a position rather than interpolating an attribute nothing recorded. An application-supplied DAG needs attribute-aware simplification or nearest-source attribute transfer, which is unbuilt topic 25 work — so this variant is usable today only by a caller that can answer that question for its own surface.

Fields

§uv_range: UvRange

The range every level’s UV lanes were quantised against — one for all of them.

The mesh path resolves a row through the instance’s mesh, which for a DAG is level 0, so a coarser level’s vertices are decoded through level 0’s range. A caller that quantised each level against its own bounds would see the coarse levels’ texture slide.

§levels: Vec<Cow<'a, [u8]>>

Vertex bytes per level, finest first and parallel to dag.levels — same length, and one vertex per position of the level beside it.

§dag: ClusterDag

The levels, their clusters, and the groups that relate them.

§flags: u32

Per-mesh bits for mesh::GpuMesh::flags — today only MESH_AUTHORED_TANGENTS.

Zero is the honest value for a caller that builds its vertices with mesh::MeshVertex::from_normal, which is every mesh this engine authors for itself: that constructor fills the frame with orthonormal_basis’ stand-in, which is orthonormal and agrees with no UV parameterisation, so a normal map read through it would be rotated by an angle nobody chose. Setting the bit is a claim that these vertices came from a real TANGENT, and the fragment stage takes the caller at its word — the screen-space derivative frame is what it falls back to otherwise.

Implementations§

Source§

impl Geometry<'_>

Source

pub fn levels(&self) -> usize

How many mesh table entries this geometry occupies: one for a flat mesh, one per level for a DAG.

Never zero, and it is what a description’s mesh ids are spaced by.

Trait Implementations§

Source§

impl<'a> Clone for Geometry<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Geometry<'a>

Source§

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

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

impl<'a> PartialEq for Geometry<'a>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Geometry<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Geometry<'a>

§

impl<'a> RefUnwindSafe for Geometry<'a>

§

impl<'a> Send for Geometry<'a>

§

impl<'a> Sync for Geometry<'a>

§

impl<'a> Unpin for Geometry<'a>

§

impl<'a> UnsafeUnpin for Geometry<'a>

§

impl<'a> UnwindSafe for Geometry<'a>

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> HalThreadSafe for T
where T: Send + Sync,

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.