59 lines
15 KiB
HTML
59 lines
15 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="An item (entity of the render world) which will be drawn to a texture or the screen, as part of a render phase."><title>PhaseItem in bevy_render::render_phase - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="bevy_render" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://bevyengine.org/assets/icon.png"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../bevy_render/index.html"><img src="https://bevyengine.org/assets/icon.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../bevy_render/index.html"><img src="https://bevyengine.org/assets/icon.png" alt="logo"></a><h2><a href="../../bevy_render/index.html">bevy_<wbr>render</a><span class="version">0.15.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Phase<wbr>Item</a></h2><h3><a href="#provided-associated-consts">Provided Associated Constants</a></h3><ul class="block"><li><a href="#associatedconstant.AUTOMATIC_BATCHING" title="AUTOMATIC_BATCHING">AUTOMATIC_BATCHING</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.batch_range" title="batch_range">batch_range</a></li><li><a href="#tymethod.batch_range_and_extra_index_mut" title="batch_range_and_extra_index_mut">batch_range_and_extra_index_mut</a></li><li><a href="#tymethod.batch_range_mut" title="batch_range_mut">batch_range_mut</a></li><li><a href="#tymethod.draw_function" title="draw_function">draw_function</a></li><li><a href="#tymethod.entity" title="entity">entity</a></li><li><a href="#tymethod.extra_index" title="extra_index">extra_index</a></li><li><a href="#tymethod.main_entity" title="main_entity">main_entity</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In bevy_<wbr>render::<wbr>render_<wbr>phase</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">bevy_render</a>::<wbr><a href="index.html">render_phase</a></span><h1>Trait <span class="trait">PhaseItem</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/bevy_render/render_phase/mod.rs.html#844-875">Source</a> </span></div><pre class="rust item-decl"><code>pub trait PhaseItem:
|
||
<a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>
|
||
+ <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>
|
||
+ <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>
|
||
+ 'static {
|
||
const <a href="#associatedconstant.AUTOMATIC_BATCHING" class="constant">AUTOMATIC_BATCHING</a>: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.bool.html">bool</a> = true;
|
||
|
||
// Required methods
|
||
fn <a href="#tymethod.entity" class="fn">entity</a>(&self) -> <a class="struct" href="../../bevy_ecs/entity/struct.Entity.html" title="struct bevy_ecs::entity::Entity">Entity</a>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.main_entity" class="fn">main_entity</a>(&self) -> <a class="struct" href="../sync_world/struct.MainEntity.html" title="struct bevy_render::sync_world::MainEntity">MainEntity</a>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.draw_function" class="fn">draw_function</a>(&self) -> <a class="struct" href="struct.DrawFunctionId.html" title="struct bevy_render::render_phase::DrawFunctionId">DrawFunctionId</a>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.batch_range" class="fn">batch_range</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/1.84.0/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.batch_range_mut" class="fn">batch_range_mut</a>(&mut self) -> &mut <a class="struct" href="https://doc.rust-lang.org/1.84.0/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.extra_index" class="fn">extra_index</a>(&self) -> <a class="struct" href="struct.PhaseItemExtraIndex.html" title="struct bevy_render::render_phase::PhaseItemExtraIndex">PhaseItemExtraIndex</a>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.batch_range_and_extra_index_mut" class="fn">batch_range_and_extra_index_mut</a>(
|
||
&mut self,
|
||
) -> (&mut <a class="struct" href="https://doc.rust-lang.org/1.84.0/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>>, &mut <a class="struct" href="struct.PhaseItemExtraIndex.html" title="struct bevy_render::render_phase::PhaseItemExtraIndex">PhaseItemExtraIndex</a>);
|
||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>An item (entity of the render world) which will be drawn to a texture or the screen,
|
||
as part of a render phase.</p>
|
||
<p>The data required for rendering an entity is extracted from the main world in the
|
||
<a href="../struct.ExtractSchedule.html" title="struct bevy_render::ExtractSchedule"><code>ExtractSchedule</code></a>.
|
||
Then it has to be queued up for rendering during the <a href="../enum.RenderSet.html#variant.Queue" title="variant bevy_render::RenderSet::Queue"><code>RenderSet::Queue</code></a>,
|
||
by adding a corresponding phase item to a render phase.
|
||
Afterwards it will be possibly sorted and rendered automatically in the
|
||
<a href="../enum.RenderSet.html#variant.PhaseSort" title="variant bevy_render::RenderSet::PhaseSort"><code>RenderSet::PhaseSort</code></a> and <a href="../enum.RenderSet.html#variant.Render" title="variant bevy_render::RenderSet::Render"><code>RenderSet::Render</code></a>, respectively.</p>
|
||
<p><code>PhaseItem</code>s come in two flavors: <a href="trait.BinnedPhaseItem.html" title="trait bevy_render::render_phase::BinnedPhaseItem"><code>BinnedPhaseItem</code></a>s and
|
||
<a href="trait.SortedPhaseItem.html" title="trait bevy_render::render_phase::SortedPhaseItem"><code>SortedPhaseItem</code></a>s.</p>
|
||
<ul>
|
||
<li>
|
||
<p>Binned phase items have a <code>BinKey</code> which specifies what bin they’re to be
|
||
placed in. All items in the same bin are eligible to be batched together.
|
||
The <code>BinKey</code>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.</p>
|
||
</li>
|
||
<li>
|
||
<p>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.</p>
|
||
</li>
|
||
</ul>
|
||
</div></details><h2 id="provided-associated-consts" class="section-header">Provided Associated Constants<a href="#provided-associated-consts" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedconstant.AUTOMATIC_BATCHING" class="method"><a class="src rightside" href="../../src/bevy_render/render_phase/mod.rs.html#846">Source</a><h4 class="code-header">const <a href="#associatedconstant.AUTOMATIC_BATCHING" class="constant">AUTOMATIC_BATCHING</a>: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.bool.html">bool</a> = true</h4></section></summary><div class="docblock"><p>Whether or not this <code>PhaseItem</code> should be subjected to automatic batching. (Default: <code>true</code>)</p>
|
||
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.entity" class="method"><a class="src rightside" href="../../src/bevy_render/render_phase/mod.rs.html#852">Source</a><h4 class="code-header">fn <a href="#tymethod.entity" class="fn">entity</a>(&self) -> <a class="struct" href="../../bevy_ecs/entity/struct.Entity.html" title="struct bevy_ecs::entity::Entity">Entity</a></h4></section></summary><div class="docblock"><p>The corresponding entity that will be drawn.</p>
|
||
<p>This is used to fetch the render data of the entity, required by the draw function,
|
||
from the render world .</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.main_entity" class="method"><a class="src rightside" href="../../src/bevy_render/render_phase/mod.rs.html#855">Source</a><h4 class="code-header">fn <a href="#tymethod.main_entity" class="fn">main_entity</a>(&self) -> <a class="struct" href="../sync_world/struct.MainEntity.html" title="struct bevy_render::sync_world::MainEntity">MainEntity</a></h4></section></summary><div class="docblock"><p>The main world entity represented by this <code>PhaseItem</code>.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.draw_function" class="method"><a class="src rightside" href="../../src/bevy_render/render_phase/mod.rs.html#858">Source</a><h4 class="code-header">fn <a href="#tymethod.draw_function" class="fn">draw_function</a>(&self) -> <a class="struct" href="struct.DrawFunctionId.html" title="struct bevy_render::render_phase::DrawFunctionId">DrawFunctionId</a></h4></section></summary><div class="docblock"><p>Specifies the <a href="trait.Draw.html" title="trait bevy_render::render_phase::Draw"><code>Draw</code></a> function used to render the item.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.batch_range" class="method"><a class="src rightside" href="../../src/bevy_render/render_phase/mod.rs.html#863">Source</a><h4 class="code-header">fn <a href="#tymethod.batch_range" class="fn">batch_range</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/1.84.0/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>></h4></section></summary><div class="docblock"><p>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.</p>
|
||
</div></details><section id="tymethod.batch_range_mut" class="method"><a class="src rightside" href="../../src/bevy_render/render_phase/mod.rs.html#864">Source</a><h4 class="code-header">fn <a href="#tymethod.batch_range_mut" class="fn">batch_range_mut</a>(&mut self) -> &mut <a class="struct" href="https://doc.rust-lang.org/1.84.0/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>></h4></section><details class="toggle method-toggle" open><summary><section id="tymethod.extra_index" class="method"><a class="src rightside" href="../../src/bevy_render/render_phase/mod.rs.html#870">Source</a><h4 class="code-header">fn <a href="#tymethod.extra_index" class="fn">extra_index</a>(&self) -> <a class="struct" href="struct.PhaseItemExtraIndex.html" title="struct bevy_render::render_phase::PhaseItemExtraIndex">PhaseItemExtraIndex</a></h4></section></summary><div class="docblock"><p>Returns the <a href="struct.PhaseItemExtraIndex.html" title="struct bevy_render::render_phase::PhaseItemExtraIndex"><code>PhaseItemExtraIndex</code></a>.</p>
|
||
<p>If present, this is either a dynamic offset or an indirect parameters
|
||
index.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.batch_range_and_extra_index_mut" class="method"><a class="src rightside" href="../../src/bevy_render/render_phase/mod.rs.html#874">Source</a><h4 class="code-header">fn <a href="#tymethod.batch_range_and_extra_index_mut" class="fn">batch_range_and_extra_index_mut</a>(
|
||
&mut self,
|
||
) -> (&mut <a class="struct" href="https://doc.rust-lang.org/1.84.0/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>>, &mut <a class="struct" href="struct.PhaseItemExtraIndex.html" title="struct bevy_render::render_phase::PhaseItemExtraIndex">PhaseItemExtraIndex</a>)</h4></section></summary><div class="docblock"><p>Returns a pair of mutable references to both the batch range and extra
|
||
index.</p>
|
||
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.84.0/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../../trait.impl/bevy_render/render_phase/trait.PhaseItem.js" async></script></section></div></main></body></html> |