1- use bevy_ecs:: prelude:: * ;
2- use bevy_ecs:: query:: QueryState ;
1+ use bevy_ecs:: query:: ROQueryItem ;
2+ use bevy_ecs:: { prelude:: * , system:: lifetimeless:: Read } ;
3+ use bevy_render:: render_graph:: ViewNode ;
34use bevy_render:: {
45 camera:: ExtractedCamera ,
56 prelude:: Color ,
6- render_graph:: { Node , NodeRunError , RenderGraphContext } ,
7+ render_graph:: { NodeRunError , RenderGraphContext } ,
78 render_phase:: RenderPhase ,
89 render_resource:: {
910 LoadOp , Operations , RenderPassColorAttachment , RenderPassDepthStencilAttachment ,
1011 RenderPassDescriptor ,
1112 } ,
1213 renderer:: RenderContext ,
13- view:: { ExtractedView , ViewDepthTexture } ,
14+ view:: ViewDepthTexture ,
1415} ;
1516#[ cfg( feature = "trace" ) ]
1617use bevy_utils:: tracing:: info_span;
@@ -20,48 +21,36 @@ use super::{AlphaMask3dPrepass, Opaque3dPrepass, ViewPrepassTextures};
2021/// Render node used by the prepass.
2122///
2223/// By default, inserted before the main pass in the render graph.
23- pub struct PrepassNode {
24- main_view_query : QueryState <
25- (
26- & ' static ExtractedCamera ,
27- & ' static RenderPhase < Opaque3dPrepass > ,
28- & ' static RenderPhase < AlphaMask3dPrepass > ,
29- & ' static ViewDepthTexture ,
30- & ' static ViewPrepassTextures ,
31- ) ,
32- With < ExtractedView > ,
33- > ,
34- }
35-
36- impl PrepassNode {
37- pub fn new ( world : & mut World ) -> Self {
38- Self {
39- main_view_query : QueryState :: new ( world) ,
40- }
24+ pub struct PrepassNode ;
25+ impl FromWorld for PrepassNode {
26+ fn from_world ( _world : & mut World ) -> Self {
27+ Self
4128 }
4229}
4330
44- impl Node for PrepassNode {
45- fn update ( & mut self , world : & mut World ) {
46- self . main_view_query . update_archetypes ( world) ;
47- }
31+ impl ViewNode for PrepassNode {
32+ type ViewWorldQuery = (
33+ Read < ExtractedCamera > ,
34+ Read < RenderPhase < Opaque3dPrepass > > ,
35+ Read < RenderPhase < AlphaMask3dPrepass > > ,
36+ Read < ViewDepthTexture > ,
37+ Read < ViewPrepassTextures > ,
38+ ) ;
4839
4940 fn run (
5041 & self ,
5142 graph : & mut RenderGraphContext ,
5243 render_context : & mut RenderContext ,
53- world : & World ,
54- ) -> Result < ( ) , NodeRunError > {
55- let view_entity = graph. view_entity ( ) ;
56- let Ok ( (
44+ (
5745 camera,
5846 opaque_prepass_phase,
5947 alpha_mask_prepass_phase,
6048 view_depth_texture,
6149 view_prepass_textures,
62- ) ) = self . main_view_query . get_manual ( world, view_entity) else {
63- return Ok ( ( ) ) ;
64- } ;
50+ ) : ROQueryItem < Self :: ViewWorldQuery > ,
51+ world : & World ,
52+ ) -> Result < ( ) , NodeRunError > {
53+ let view_entity = graph. view_entity ( ) ;
6554
6655 let mut color_attachments = vec ! [ ] ;
6756 color_attachments. push (
0 commit comments