Skip to content

Commit

Permalink
Replace EdgeExistence with booleans
Browse files Browse the repository at this point in the history
  • Loading branch information
myreprise1 committed Feb 11, 2023
1 parent 8da24b3 commit 177326f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
6 changes: 0 additions & 6 deletions crates/bevy_render/src/render_graph/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,3 @@ impl Edge {
}
}
}

#[derive(PartialEq, Eq)]
pub enum EdgeExistence {
Exists,
DoesNotExist,
}
24 changes: 11 additions & 13 deletions crates/bevy_render/src/render_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use bevy_ecs::{prelude::World, system::Resource};
use bevy_utils::HashMap;
use std::{borrow::Cow, fmt::Debug};

use super::EdgeExistence;

/// The render graph configures the modular, parallel and re-usable render logic.
/// It is a retained and stateless (nodes themselves may have their own internal state) structure,
/// which can not be modified while it is executed by the graph runner.
Expand Down Expand Up @@ -263,7 +261,7 @@ impl RenderGraph {
input_index,
};

self.validate_edge(&edge, EdgeExistence::DoesNotExist)?;
self.validate_edge(&edge, false)?;

{
let output_node = self.get_node_state_mut(output_node_id)?;
Expand Down Expand Up @@ -328,7 +326,7 @@ impl RenderGraph {
input_index,
};

self.validate_edge(&edge, EdgeExistence::Exists)?;
self.validate_edge(&edge, true)?;

{
let output_node = self.get_node_state_mut(output_node_id)?;
Expand Down Expand Up @@ -361,7 +359,7 @@ impl RenderGraph {
input_node: input_node_id,
};

self.validate_edge(&edge, EdgeExistence::DoesNotExist)?;
self.validate_edge(&edge, false)?;

{
let output_node = self.get_node_state_mut(output_node_id)?;
Expand Down Expand Up @@ -406,7 +404,7 @@ impl RenderGraph {
input_node: input_node_id,
};

self.validate_edge(&edge, EdgeExistence::Exists)?;
self.validate_edge(&edge, true)?;

{
let output_node = self.get_node_state_mut(output_node_id)?;
Expand All @@ -423,13 +421,13 @@ impl RenderGraph {
pub fn validate_edge(
&mut self,
edge: &Edge,
should_exist: EdgeExistence,
should_exist: bool,
) -> Result<(), RenderGraphError> {
if should_exist == EdgeExistence::Exists && !self.has_edge(edge) {
return Err(RenderGraphError::EdgeDoesNotExist(edge.clone()));
} else if should_exist == EdgeExistence::DoesNotExist && self.has_edge(edge) {
return Err(RenderGraphError::EdgeAlreadyExists(edge.clone()));
}
match (should_exist, self.has_edge(edge)) {
(true, false) => return Err(RenderGraphError::EdgeDoesNotExist(edge.clone())),
(false, true) => return Err(RenderGraphError::EdgeAlreadyExists(edge.clone())),
_ => {}
};

match *edge {
Edge::SlotEdge {
Expand Down Expand Up @@ -465,7 +463,7 @@ impl RenderGraph {
false
}
}) {
if should_exist == EdgeExistence::DoesNotExist {
if should_exist == false {
return Err(RenderGraphError::NodeInputSlotAlreadyOccupied {
node: input_node,
input_slot: input_index,
Expand Down

0 comments on commit 177326f

Please sign in to comment.