#[repr(C)]pub struct SegmentInstance {
pub a: [f32; 2],
pub b: [f32; 2],
pub color: [f32; 3],
pub width: f32,
pub ext_a: f32,
pub alpha: f32,
pub ext_b: f32,
}Expand description
One line segment: endpoints a/b in world space (x is divided by aspect
in the shader, matching the swarm’s convention), an RGB colour, a
half-width in world units, and the per-endpoint extension length the join
needs.
Fields§
§a: [f32; 2]First endpoint (world space).
b: [f32; 2]Second endpoint (world space).
color: [f32; 3]RGB colour (pre-brightness; additive blend sums overlaps).
width: f32Half-width in world units — the isotropic space, where the stroke is the same thickness on screen at every orientation (ADR-0160). It is numerically an NDC-y half-width: world y and NDC y are the same axis, so the horizontal case is the same number in either space and every other orientation agrees with it.
Unless the draw selected StrokeMetric::Clip, where this is an NDC
half-width and the on-screen thickness varies with the segment’s
orientation by up to the aspect. That metric is per draw call rather than
per instance, and warp_mesh is the one surface on it.
ext_a: f32How far the quad extends backward past a, along the segment’s own
direction, in the same world half-width units as width.
0.0 is a free end (ADR-0158).
The length is the producer’s to compute: only it knows whether an end
is shared with a neighbour and at what interior angle, which is the same
argument that put connectivity on the producer side. 0.0 renders exactly
the geometry an unflagged end rendered, because dir * 0.0 is exactly
zero — that is what keeps the isolated producers, spectrum’s Bars and
RadialRing, byte-identical.
A length, not a factor. It is resolved against width at
the moment the producer fills the instance. Every producer in this crate
rebuilds its instance buffer per frame, so the two cannot drift; a
producer that ever caches instances across frames while animating
thickness would have to recompute this alongside it.
alpha: f32How much of its own footprint this stroke occupies, on top of the
across-the-stroke falloff — the fragment’s alpha is falloff * alpha.
1.0 for every producer that draws through the additive seam, and that is
the value to pass unless you know otherwise: ADR-0056’s rule is that a
dimmed stroke still covers its own footprint, so brightness belongs in
color and never here. Every line scene in this crate
passes 1.0, which makes the fragment exactly what it was before this
field existed.
What it is for is LineRenderer::draw_split’s second range, where the
stroke is composited over rather than added and the blend needs the
producer’s real coverage: a MilkDrop waveform at wave_a = 0.1 must
replace a tenth of what is under it, not all of it (Plan 0100 Phase 4).
Its position in this struct is load-bearing. vertex_attr_array!
derives each attribute’s byte offset from the order of the shader
locations, so a field inserted ahead of this one shifts location 5 onto
the bytes location 4 is reading and every attribute after it by one slot.
The result compiles, renders, and quietly reinterprets one field as
another’s mantissa — which is what it did, moving five composite golden
baselines. A new field goes last, which is where
ext_b is.
ext_b: f32How far the quad extends forward past b. The b-end counterpart of
ext_a, in the same units and with the same 0.0-is-free
convention.
Declared last, for the reason alpha records: it was
appended when the endpoint stopped carrying a flag and started carrying a
length, and appending is the only placement that re-points nothing.
Trait Implementations§
Source§impl Clone for SegmentInstance
impl Clone for SegmentInstance
Source§fn clone(&self) -> SegmentInstance
fn clone(&self) -> SegmentInstance
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SegmentInstance
impl Debug for SegmentInstance
Source§impl PartialEq for SegmentInstance
impl PartialEq for SegmentInstance
Source§fn eq(&self, other: &SegmentInstance) -> bool
fn eq(&self, other: &SegmentInstance) -> bool
self and other values to be equal, and is used by ==.impl Copy for SegmentInstance
impl Pod for SegmentInstance
impl StructuralPartialEq for SegmentInstance
Auto Trait Implementations§
impl Freeze for SegmentInstance
impl RefUnwindSafe for SegmentInstance
impl Send for SegmentInstance
impl Sync for SegmentInstance
impl Unpin for SegmentInstance
impl UnsafeUnpin for SegmentInstance
impl UnwindSafe for SegmentInstance
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.