Skip to content

Commit b47af22

Browse files
committed
add_node_edges
1 parent f51aca8 commit b47af22

File tree

4 files changed

+11
-26
lines changed

4 files changed

+11
-26
lines changed

crates/bevy_core_pipeline/src/core_2d/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,9 @@ impl Plugin for Core2dPlugin {
7777
draw_2d_graph.add_node_edge(
7878
graph::node::TONEMAPPING,
7979
graph::node::END_MAIN_PASS_POST_PROCESSING,
80-
);
81-
draw_2d_graph.add_node_edge(
82-
graph::node::END_MAIN_PASS_POST_PROCESSING,
8380
graph::node::UPSCALING,
84-
);
81+
]);
82+
8583
graph.add_sub_graph(graph::NAME, draw_2d_graph);
8684
}
8785
}

crates/bevy_core_pipeline/src/core_3d/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,9 @@ impl Plugin for Core3dPlugin {
9999
draw_3d_graph.add_node_edge(
100100
graph::node::TONEMAPPING,
101101
graph::node::END_MAIN_PASS_POST_PROCESSING,
102-
);
103-
draw_3d_graph.add_node_edge(
104-
graph::node::END_MAIN_PASS_POST_PROCESSING,
105102
graph::node::UPSCALING,
106-
);
103+
]);
104+
107105
graph.add_sub_graph(graph::NAME, draw_3d_graph);
108106
}
109107
}

crates/bevy_core_pipeline/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ pub fn add_node<T: Node + FromWorld>(
8686
let mut render_graph = render_app.world.resource_mut::<RenderGraph>();
8787

8888
let graph = render_graph.get_sub_graph_mut(sub_graph_name).unwrap();
89-
graph.add_node_with_edges(node_name, node, edges);
89+
graph.add_node(node_name, node);
90+
graph.add_node_edges(edges);
9091

9192
graph.add_slot_edge(graph.input_node().id, output_slot, node_name, input_slot);
9293
}

crates/bevy_render/src/render_graph/graph.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,24 +119,12 @@ impl RenderGraph {
119119
id
120120
}
121121

122-
/// Adds the `node` with the `name` to the graph.
123-
/// If the name is already present replaces it instead.
124-
/// Also adds `node_edge` based on the order of the given `edges`.
125-
pub fn add_node_with_edges<T>(
126-
&mut self,
127-
name: impl Into<Cow<'static, str>>,
128-
node: T,
129-
edges: &[&'static str],
130-
) -> NodeId
131-
where
132-
T: Node,
133-
{
134-
let id = self.add_node(name, node);
122+
/// Add `node_edge` based on the order of the given `edges` array.
123+
pub fn add_node_edges(&mut self, edges: &[&'static str]) {
135124
for window in edges.windows(2) {
136125
let [a, b] = window else { break; };
137126
self.add_node_edge(*a, *b);
138127
}
139-
id
140128
}
141129

142130
/// Removes the `node` with the `name` from the graph.
@@ -855,7 +843,7 @@ mod tests {
855843
}
856844

857845
#[test]
858-
fn test_add_node_with_edges() {
846+
fn test_add_node_edges() {
859847
struct SimpleNode;
860848
impl Node for SimpleNode {
861849
fn run(
@@ -875,10 +863,10 @@ mod tests {
875863

876864
let mut graph = RenderGraph::default();
877865
let a_id = graph.add_node("A", SimpleNode);
866+
let b_id = graph.add_node("B", SimpleNode);
878867
let c_id = graph.add_node("C", SimpleNode);
879868

880-
// A and C need to exist first
881-
let b_id = graph.add_node_with_edges("B", SimpleNode, &["A", "B", "C"]);
869+
graph.add_node_edges(&["A", "B", "C"]);
882870

883871
assert!(
884872
output_nodes("A", &graph) == HashSet::from_iter(vec![b_id]),

0 commit comments

Comments
 (0)