1
1
use bevy_app:: { App , SubApp } ;
2
- use bevy_ecs:: world:: FromWorld ;
2
+ use bevy_ecs:: world:: { FromWorld , World } ;
3
3
use tracing:: warn;
4
4
5
5
use super :: { IntoRenderNodeArray , Node , RenderGraph , RenderLabel , RenderSubGraph } ;
@@ -32,15 +32,15 @@ pub trait RenderGraphExt {
32
32
) -> & mut Self ;
33
33
}
34
34
35
- impl RenderGraphExt for SubApp {
35
+ impl RenderGraphExt for World {
36
36
fn add_render_graph_node < T : Node + FromWorld > (
37
37
& mut self ,
38
38
sub_graph : impl RenderSubGraph ,
39
39
node_label : impl RenderLabel ,
40
40
) -> & mut Self {
41
41
let sub_graph = sub_graph. intern ( ) ;
42
- let node = T :: from_world ( self . world_mut ( ) ) ;
43
- let mut render_graph = self . world_mut ( ) . get_resource_mut :: < RenderGraph > ( ) . expect (
42
+ let node = T :: from_world ( self ) ;
43
+ let mut render_graph = self . get_resource_mut :: < RenderGraph > ( ) . expect (
44
44
"RenderGraph not found. Make sure you are using add_render_graph_node on the RenderApp" ,
45
45
) ;
46
46
if let Some ( graph) = render_graph. get_sub_graph_mut ( sub_graph) {
@@ -59,7 +59,7 @@ impl RenderGraphExt for SubApp {
59
59
edges : impl IntoRenderNodeArray < N > ,
60
60
) -> & mut Self {
61
61
let sub_graph = sub_graph. intern ( ) ;
62
- let mut render_graph = self . world_mut ( ) . get_resource_mut :: < RenderGraph > ( ) . expect (
62
+ let mut render_graph = self . get_resource_mut :: < RenderGraph > ( ) . expect (
63
63
"RenderGraph not found. Make sure you are using add_render_graph_edges on the RenderApp" ,
64
64
) ;
65
65
if let Some ( graph) = render_graph. get_sub_graph_mut ( sub_graph) {
@@ -79,7 +79,7 @@ impl RenderGraphExt for SubApp {
79
79
input_node : impl RenderLabel ,
80
80
) -> & mut Self {
81
81
let sub_graph = sub_graph. intern ( ) ;
82
- let mut render_graph = self . world_mut ( ) . get_resource_mut :: < RenderGraph > ( ) . expect (
82
+ let mut render_graph = self . get_resource_mut :: < RenderGraph > ( ) . expect (
83
83
"RenderGraph not found. Make sure you are using add_render_graph_edge on the RenderApp" ,
84
84
) ;
85
85
if let Some ( graph) = render_graph. get_sub_graph_mut ( sub_graph) {
@@ -93,21 +93,56 @@ impl RenderGraphExt for SubApp {
93
93
}
94
94
95
95
fn add_render_sub_graph ( & mut self , sub_graph : impl RenderSubGraph ) -> & mut Self {
96
- let mut render_graph = self . world_mut ( ) . get_resource_mut :: < RenderGraph > ( ) . expect (
96
+ let mut render_graph = self . get_resource_mut :: < RenderGraph > ( ) . expect (
97
97
"RenderGraph not found. Make sure you are using add_render_sub_graph on the RenderApp" ,
98
98
) ;
99
99
render_graph. add_sub_graph ( sub_graph, RenderGraph :: default ( ) ) ;
100
100
self
101
101
}
102
102
}
103
103
104
+ impl RenderGraphExt for SubApp {
105
+ fn add_render_graph_node < T : Node + FromWorld > (
106
+ & mut self ,
107
+ sub_graph : impl RenderSubGraph ,
108
+ node_label : impl RenderLabel ,
109
+ ) -> & mut Self {
110
+ World :: add_render_graph_node :: < T > ( self . world_mut ( ) , sub_graph, node_label) ;
111
+ self
112
+ }
113
+
114
+ fn add_render_graph_edge (
115
+ & mut self ,
116
+ sub_graph : impl RenderSubGraph ,
117
+ output_node : impl RenderLabel ,
118
+ input_node : impl RenderLabel ,
119
+ ) -> & mut Self {
120
+ World :: add_render_graph_edge ( self . world_mut ( ) , sub_graph, output_node, input_node) ;
121
+ self
122
+ }
123
+
124
+ fn add_render_graph_edges < const N : usize > (
125
+ & mut self ,
126
+ sub_graph : impl RenderSubGraph ,
127
+ edges : impl IntoRenderNodeArray < N > ,
128
+ ) -> & mut Self {
129
+ World :: add_render_graph_edges ( self . world_mut ( ) , sub_graph, edges) ;
130
+ self
131
+ }
132
+
133
+ fn add_render_sub_graph ( & mut self , sub_graph : impl RenderSubGraph ) -> & mut Self {
134
+ World :: add_render_sub_graph ( self . world_mut ( ) , sub_graph) ;
135
+ self
136
+ }
137
+ }
138
+
104
139
impl RenderGraphExt for App {
105
140
fn add_render_graph_node < T : Node + FromWorld > (
106
141
& mut self ,
107
142
sub_graph : impl RenderSubGraph ,
108
143
node_label : impl RenderLabel ,
109
144
) -> & mut Self {
110
- SubApp :: add_render_graph_node :: < T > ( self . main_mut ( ) , sub_graph, node_label) ;
145
+ World :: add_render_graph_node :: < T > ( self . world_mut ( ) , sub_graph, node_label) ;
111
146
self
112
147
}
113
148
@@ -117,7 +152,7 @@ impl RenderGraphExt for App {
117
152
output_node : impl RenderLabel ,
118
153
input_node : impl RenderLabel ,
119
154
) -> & mut Self {
120
- SubApp :: add_render_graph_edge ( self . main_mut ( ) , sub_graph, output_node, input_node) ;
155
+ World :: add_render_graph_edge ( self . world_mut ( ) , sub_graph, output_node, input_node) ;
121
156
self
122
157
}
123
158
@@ -126,12 +161,12 @@ impl RenderGraphExt for App {
126
161
sub_graph : impl RenderSubGraph ,
127
162
edges : impl IntoRenderNodeArray < N > ,
128
163
) -> & mut Self {
129
- SubApp :: add_render_graph_edges ( self . main_mut ( ) , sub_graph, edges) ;
164
+ World :: add_render_graph_edges ( self . world_mut ( ) , sub_graph, edges) ;
130
165
self
131
166
}
132
167
133
168
fn add_render_sub_graph ( & mut self , sub_graph : impl RenderSubGraph ) -> & mut Self {
134
- SubApp :: add_render_sub_graph ( self . main_mut ( ) , sub_graph) ;
169
+ World :: add_render_sub_graph ( self . world_mut ( ) , sub_graph) ;
135
170
self
136
171
}
137
172
}
0 commit comments