Skip to main content

Module paint

Module paint 

Source
Expand description

The documents of the surface paint chunk (SPEC.md, section 10.1): the masks themselves, which crate::surface carries without reading.

Version 1 gives every triangle of a mesh one value, as runs. Version 2 gives every painted triangle a tree that splits it into smaller pieces, each with its own value: what a support brush paints when it covers part of a triangle.

version 1   u32 triangle count, 48 bytes fingerprint,
            u32 count, then per run: u32 length, u8 value
version 2   u32 triangle count, 48 bytes fingerprint,
            u32 count, then per painted triangle: u32 gap,
            u32 length, the trees as a bit stream of 4-bit groups

A document that breaks a rule never makes a file unreadable: a reader treats its entry as absent. SurfaceEntry::paint does that check, with the leaf’s mesh, and gives the document only when it applies.

Structs§

PaintPiece
A piece of a painted triangle, the leaf of its tree.
PaintRun
Triangles in a row that have the same value.
PaintRuns
A version 1 document: the value of every triangle, as runs.
PaintTrees
A version 2 document: the painted triangles and their trees.
PaintedTriangle
One painted triangle of a version 2 document.

Enums§

DecodePaintError
Why a document could not be decoded.
EncodePaintError
Why a document could not be encoded.
PaintDocument
A surface paint document.
PaintNode
A node of a version 2 tree.

Constants§

FINGERPRINT_SIZE
The size of a mesh fingerprint, a SHA-384 digest.
MAX_PAINT_DEPTH
How deep a node of a version 2 tree may be: the root is at depth 0.
MUST_NOT_TOUCH
The value of kind PAINT_SUPPORTS_BOTH_WAYS where supports must not touch.
MUST_TOUCH
The value of kind PAINT_SUPPORTS_BOTH_WAYS where supports must touch.
PAINT_DETAIL
The kind of paint that marks details to keep: values 0 to 255.
PAINT_SUPPORTS_BOTH_WAYS
The kind of paint that marks both, as a support brush paints them: 0 bare, 1 supports must touch, 2 supports must not touch.
PAINT_SUPPORTS_MUST_NOT_TOUCH
The kind of paint that marks where supports must not touch: values 0 to 255.
PAINT_SUPPORTS_MUST_TOUCH
The kind of paint that marks where supports must touch: values 0 to 255.

Functions§

decode_paint
Decodes a surface paint document of version.
encode_paint
Encodes a surface paint document, as the version PaintDocument::version gives.
mesh_fingerprint
The fingerprint that names a mesh in a paint document (section 10.1): the SHA-384 digest of the vertex count as a u64, the bits of every coordinate as u32s, the triangle count as a u64, and every triangle’s indices as u32s, all little-endian.