pub trait PhaseItem:
Sized
+ Send
+ Sync
+ 'static {
const AUTOMATIC_BATCHING: bool = true;
// Required methods
fn entity(&self) -> Entity;
fn main_entity(&self) -> MainEntity;
fn draw_function(&self) -> DrawFunctionId;
fn batch_range(&self) -> &Range<u32>;
fn batch_range_mut(&mut self) -> &mut Range<u32>;
fn extra_index(&self) -> PhaseItemExtraIndex;
fn batch_range_and_extra_index_mut(
&mut self,
) -> (&mut Range<u32>, &mut PhaseItemExtraIndex);
}
Expand description
An item (entity of the render world) which will be drawn to a texture or the screen, as part of a render phase.
The data required for rendering an entity is extracted from the main world in the
ExtractSchedule
.
Then it has to be queued up for rendering during the RenderSet::Queue
,
by adding a corresponding phase item to a render phase.
Afterwards it will be possibly sorted and rendered automatically in the
RenderSet::PhaseSort
and RenderSet::Render
, respectively.
PhaseItem
s come in two flavors: BinnedPhaseItem
s and
SortedPhaseItem
s.
-
Binned phase items have a
BinKey
which specifies what bin they’re to be placed in. All items in the same bin are eligible to be batched together. TheBinKey
s are sorted, but the individual bin items aren’t. Binned phase items are good for opaque meshes, in which the order of rendering isn’t important. Generally, binned phase items are faster than sorted phase items. -
Sorted phase items, on the other hand, are placed into one large buffer and then sorted all at once. This is needed for transparent meshes, which have to be sorted back-to-front to render with the painter’s algorithm. These types of phase items are generally slower than binned phase items.
Provided Associated Constants§
Sourceconst AUTOMATIC_BATCHING: bool = true
const AUTOMATIC_BATCHING: bool = true
Whether or not this PhaseItem
should be subjected to automatic batching. (Default: true
)
Required Methods§
Sourcefn entity(&self) -> Entity
fn entity(&self) -> Entity
The corresponding entity that will be drawn.
This is used to fetch the render data of the entity, required by the draw function, from the render world .
Sourcefn main_entity(&self) -> MainEntity
fn main_entity(&self) -> MainEntity
The main world entity represented by this PhaseItem
.
Sourcefn draw_function(&self) -> DrawFunctionId
fn draw_function(&self) -> DrawFunctionId
Specifies the Draw
function used to render the item.
Sourcefn batch_range(&self) -> &Range<u32>
fn batch_range(&self) -> &Range<u32>
The range of instances that the batch covers. After doing a batched draw, batch range length phase items will be skipped. This design is to avoid having to restructure the render phase unnecessarily.
fn batch_range_mut(&mut self) -> &mut Range<u32>
Sourcefn extra_index(&self) -> PhaseItemExtraIndex
fn extra_index(&self) -> PhaseItemExtraIndex
Returns the PhaseItemExtraIndex
.
If present, this is either a dynamic offset or an indirect parameters index.
Sourcefn batch_range_and_extra_index_mut(
&mut self,
) -> (&mut Range<u32>, &mut PhaseItemExtraIndex)
fn batch_range_and_extra_index_mut( &mut self, ) -> (&mut Range<u32>, &mut PhaseItemExtraIndex)
Returns a pair of mutable references to both the batch range and extra index.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.