Skip to main content

DebugDraw

Struct DebugDraw 

Source
pub struct DebugDraw { /* private fields */ }
Expand description

The immediate-mode buffer every system appends to, and the pass that draws it.

Built by ForwardRenderer, which owns one and hands it out through debug_draw; appending is all a system ever does with it.

Implementations§

Source§

impl DebugDraw

Source

pub const MAX_PASSES: u32 = 1

The most passes this layer adds to one frame.

The most rather than the count: a frame with nothing appended adds none. What a caller sizing PassTimers adds up.

ForwardRenderer::add_passes is what records it.

Source

pub fn enabled() -> bool

Whether the console has the layer switched on.

The read half of r_debug_draw, for a system deciding whether to build its overlay at all: appending while it is off is harmless — the buffer is cleared and never uploaded — but a system whose geometry costs something to compute wants to know before it computes it.

Source

pub fn line(&mut self, from: Vec3, to: Vec3, color: [f32; 4])

Appends one world-space segment.

Every other primitive here is written in terms of this one.

Source

pub fn aabb(&mut self, min: Vec3, max: Vec3, color: [f32; 4])

Appends the twelve edges of the axis-aligned box spanning min..=max.

Source

pub fn frustum(&mut self, view_proj: Mat4, color: [f32; 4])

Appends the twelve edges of the view volume view_proj projects.

A view volume with no finite corners appends nothing and says so, on frustum_corners’s terms — which is the engine’s own camera, whose far plane is at infinity. A caller that wants to handle that itself calls frustum_corners and box_edges.

Source

pub fn box_edges(&mut self, corners: &[Vec3; 8], color: [f32; 4])

Appends the twelve edges joining eight corners in frustum_corners’ order.

What aabb and frustum share: a box and a view volume differ in where their corners come from and in nothing else.

Source

pub fn sphere(&mut self, centre: Vec3, radius: f32, color: [f32; 4])

Appends three great circles of radius about centre, one in each coordinate plane, each of SPHERE_SEGMENTS segments.

Three circles rather than a mesh of latitudes and longitudes: what a debug sphere has to show is where a radius reaches, and three rings show it from any angle without filling the frame with lines.

Source

pub fn segments(&self) -> usize

How many segments have been appended since the renderer last opened a frame.

The observable a check asking “did this system draw anything” wants, and what says a primitive helper appended the edges it claims to.

Trait Implementations§

Source§

impl Debug for DebugDraw

Source§

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

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

impl Default for DebugDraw

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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