Skip to main content

DrawObject

Struct DrawObject 

Source
pub struct DrawObject {
Show 17 fields pub vertex_offset: usize, pub vertex_count: usize, pub index_offset: usize, pub index_count: usize, pub base_vertex: i32, pub geometry_generation: u32, pub model: [[f32; 4]; 4], pub texture_slot: usize, pub normal_map_slot: usize, pub material: MaterialUniforms, pub shader_bucket: u32, pub visible: bool, pub resident: bool, pub bb_min: [f32; 3], pub bb_max: [f32; 3], pub cull_distance: f32, pub lod_alternates: Vec<LodSlice>,
}
Expand description

One renderable object: vertex/index slice within the shared GPU buffers, a model matrix, albedo and normal-map texture slots, and material parameters.

Fields§

§vertex_offset: usize

Byte offset into the shared vertex buffer.

§vertex_count: usize

Number of vertices this object occupies in the shared vertex buffer, starting at vertex_offset. Used by mesh streaming to memcpy the object’s geometry region in and out of the GPU buffer.

§index_offset: usize

Element offset into the shared index buffer.

§index_count: usize

Number of indices to draw.

§base_vertex: i32

Value added to every index before the vertex fetch (the drawIndexedPrimitives baseVertex / D3D12 BaseVertexLocation / Vulkan vertex_offset). 0 for static and streamed-mesh geometry, whose indices are already absolute into the shared vertex buffer. Streamed VoxelWorld chunks instead keep mesh-relative (0-based) indices and set this to their vertex region’s base, so a chunk placed past the 65 535-vertex u16 index range still renders. Read by all three backends’ shadow/main/velocity passes.

§geometry_generation: u32

Bumped every time the slot’s vertex / index bytes are rewritten in place at unchanged offsets (a size-matched asset hot-reload). The offsets and counts above identify only where the geometry lives, so without this counter an in-place rewrite is indistinguishable from no change at all and a ray-tracing BLAS built over the previous contents would be reused.

§model: [[f32; 4]; 4]

Column-major model-to-world matrix.

§texture_slot: usize

Index into the shared texture pool for this object’s albedo map. Clamped to the last slot if out of range.

§normal_map_slot: usize

Index into the shared texture pool for this object’s normal map, or NO_NORMAL_MAP_SLOT when the object has no normal map (the backend then substitutes the flat-normal fallback).

§material: MaterialUniforms

Per-draw material scalars pushed to the fragment shader at buffer(3).

§shader_bucket: u32

When false the object is skipped in both the shadow and main passes. Which world shader renders this object: the dense ShaderHandle value of the material’s shader reference, or 0 (the world default) when the material names none. The backend binds the matching pipeline for each bucket; the value never changes after the draw is built.

§visible: bool

Controlled by scene switches to hide props belonging to inactive scenes.

§resident: bool

When false the object’s geometry is not yet uploaded to the GPU buffers and the object is skipped in every pass. Always true unless the asset- streaming subsystem is active; the mesh streamer flips it to true once the geometry region is resident. Read by the shadow/main/velocity passes.

§bb_min: [f32; 3]

World-space axis-aligned bounding box used for frustum culling. Baked from the mesh’s local bounds and the prop’s initial model matrix at GraphicsSystem init. Set to a degenerate (NaN) box to disable culling.

§bb_max: [f32; 3]

Upper corner of the world-space culling AABB.

§cull_distance: f32

If > 0, the object is skipped when the camera is further than this from the AABB centre. Lets a Prop opt in to distance-based unloading.

§lod_alternates: Vec<LodSlice>

LOD1..N slices for this draw, in ascending switch_distance order. Empty when the mesh declared lod_levels <= 1; the renderer then always uses the LOD0 (index_offset, index_count) carried on this object. With non-empty alternates the renderer picks the highest slice whose threshold is ≤ the camera→AABB-centre distance each frame.

Implementations§

Source§

impl DrawObject

Source

pub fn active_lod(&self, distance: f32) -> (usize, usize)

Pick the active (index_offset, index_count) for this object given the current camera distance to its AABB centre. Returns the LOD0 pair when no alternates are present or when the camera is closer than the first alternate’s threshold; otherwise returns the highest-indexed alternate whose switch_distancedistance.

Source

pub fn cullable(&self) -> bool

Returns true when the AABB encodes valid finite bounds suitable for frustum/distance culling. A degenerate box (NaN min) disables culling.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more