Skip to content

Commit

Permalink
no_default_set > add_default_set
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-blackbird committed Jan 24, 2023
1 parent fdd5a59 commit c6a7539
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/scheduling/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl IntoSystemSetConfig for SystemSetConfig {
}

fn no_default_set(mut self) -> SystemSetConfig {
self.graph_info.no_default_set = true;
self.graph_info.add_default_set = false;
self
}

Expand Down Expand Up @@ -368,7 +368,7 @@ impl IntoSystemConfig<()> for SystemConfig {
}

fn no_default_set(mut self) -> SystemConfig {
self.graph_info.no_default_set = true;
self.graph_info.add_default_set = false;
self
}

Expand Down
15 changes: 13 additions & 2 deletions crates/bevy_ecs/src/scheduling/graph_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,23 @@ pub(crate) enum Ambiguity {
IgnoreAll,
}

#[derive(Clone, Default)]
#[derive(Clone)]
pub(crate) struct GraphInfo {
pub(crate) sets: Vec<BoxedSystemSet>,
pub(crate) dependencies: Vec<Dependency>,
pub(crate) ambiguous_with: Ambiguity,
pub(crate) no_default_set: bool,
pub(crate) add_default_set: bool,
}

impl Default for GraphInfo {
fn default() -> Self {
GraphInfo {
sets: Vec::new(),
dependencies: Vec::new(),
ambiguous_with: Ambiguity::default(),
add_default_set: true,
}
}
}

/// Converts 2D row-major pair of indices into a 1D array index.
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/scheduling/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl ScheduleGraph {
let id = NodeId::System(self.systems.len());

if let [single_set] = graph_info.sets.as_slice() {
if single_set.is_system_type() && !graph_info.no_default_set {
if single_set.is_system_type() && graph_info.add_default_set {
if let Some(default) = self.default_set.as_ref() {
graph_info.sets.push(default.dyn_clone());
}
Expand Down Expand Up @@ -434,7 +434,7 @@ impl ScheduleGraph {

// a system set can be configured multiple times, so this "default check"
// should only happen the first time `configure_set` is called on it
if !already_configured && graph_info.sets.is_empty() && !graph_info.no_default_set {
if !already_configured && graph_info.sets.is_empty() && graph_info.add_default_set {
if let Some(default) = self.default_set.as_ref() {
info!("adding system set `{:?}` to default: `{:?}`", set, default);
graph_info.sets.push(default.dyn_clone());
Expand Down

0 comments on commit c6a7539

Please sign in to comment.