Skip to main content

SegmentInstance

Struct SegmentInstance 

Source
#[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: f32

Half-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: f32

How 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: f32

How 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: f32

How 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

Source§

fn clone(&self) -> SegmentInstance

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 Debug for SegmentInstance

Source§

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

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

impl PartialEq for SegmentInstance

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Zeroable for SegmentInstance

§

fn zeroed() -> Self

Source§

impl Copy for SegmentInstance

Source§

impl Pod for SegmentInstance

Source§

impl StructuralPartialEq for SegmentInstance

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
§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

§

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

If this function returns true, then it must be valid to reinterpret bits as &Self.
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> 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<T> AnyBitPattern for T
where T: Pod,

§

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> NoUninit for T
where T: Pod,

§

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

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,