Skip to main content

GridStyle

Struct GridStyle 

Source
pub struct GridStyle {
    pub spacing: f32,
    pub coarse_multiple: f32,
    pub line_width: f32,
    pub fade_distance: f32,
    pub fine_color: [f32; 4],
    pub coarse_color: [f32; 4],
}
Expand description

How the grid is drawn.

Every field lands in the shader’s params, fine_color and coarse_color rows — see shaders/grid.slang for what each one does to a fragment.

Fields§

§spacing: f32

The fine cell size, in world units.

§coarse_multiple: f32

How many fine cells make one coarse cell.

§line_width: f32

Line width, in pixels. Constant at any zoom, which is the whole point of taking coverage from a screen-space derivative.

§fade_distance: f32

The distance, in world units, at which the grid has faded to nothing.

§fine_color: [f32; 4]

The fine lines’ linear RGB, with their peak opacity in a.

§coarse_color: [f32; 4]

The coarse lines’ linear RGB, with their peak opacity in a. Composited over the fine lines.

Implementations§

Source§

impl GridStyle

Source

pub fn for_extent(extent: f32) -> Self

A style scaled to a subject extent world units across.

Default is a metre grid fading at a hundred, which suits content authored at human scale and nothing else: a five-centimetre model sits inside a single cell, and a five-hundred-metre one is entirely past the fade. A viewer opening arbitrary documents cannot assume either.

The spacing snaps to a power of ten. A cell of 0.1, 1 or 10 units is a number a person can count in and do arithmetic with, which is the grid’s whole job; a cell of 3.7 gives the same line density and tells the eye nothing. Blender’s adaptive grid steps by powers of ten for the same reason. So this picks the power of ten nearest to extent / CELLS_ACROSS rather than that value itself.

A non-finite or non-positive extent returns Default — there is no scale to derive one from, and a log10 of zero is -inf.

Trait Implementations§

Source§

impl Clone for GridStyle

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 Copy for GridStyle

Source§

impl Debug for GridStyle

Source§

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

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

impl Default for GridStyle

Source§

fn default() -> Self

One-metre cells with a heavier line every ten, fading out at a hundred metres.

A metre because that is the unit the rest of the engine’s 3D content is authored in — crcbl_greybox::primitives sizes every prototype solid in metres — so the fine cell is the size of the smallest thing anyone places, and the coarse cell is the ten-metre block a room is laid out on.

Source§

impl PartialEq for GridStyle

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 StructuralPartialEq for GridStyle

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
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.