From b0df4915599e58a5c7e1b2d9e28e4f57b5d4e57e Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Sun, 19 Jan 2020 12:43:18 -0800 Subject: [PATCH] make legacy rendergraph optional (and off by default) --- examples/entity_builder_comparison.rs | 2 +- examples/instancing.rs | 2 +- examples/load_model.rs | 2 +- examples/parenting.rs | 2 +- examples/serializing.rs | 2 +- examples/shader_material.rs | 2 +- examples/simple.rs | 2 +- examples/texture.rs | 2 +- examples/ui.rs | 2 +- src/app/app.rs | 23 +++++--- src/app/app_builder.rs | 69 +++++++++++++---------- src/render/render_graph_2/render_graph.rs | 37 +----------- src/render/render_graph_2/renderer.rs | 8 ++- 13 files changed, 73 insertions(+), 82 deletions(-) diff --git a/examples/entity_builder_comparison.rs b/examples/entity_builder_comparison.rs index 50a15cf1d0..651a0680ff 100644 --- a/examples/entity_builder_comparison.rs +++ b/examples/entity_builder_comparison.rs @@ -1,7 +1,7 @@ use bevy::prelude::*; fn main() { - AppBuilder::new().add_defaults().setup_world(setup).run(); + AppBuilder::new().add_defaults_legacy().setup_world(setup).run(); } #[allow(dead_code)] diff --git a/examples/instancing.rs b/examples/instancing.rs index b4f5a1080b..0336a09fd4 100644 --- a/examples/instancing.rs +++ b/examples/instancing.rs @@ -21,7 +21,7 @@ struct Wander { fn main() { AppBuilder::new() - .add_defaults() + .add_defaults_legacy() .setup_world(setup) .add_system(build_wander_system()) .add_system(build_navigate_system()) diff --git a/examples/load_model.rs b/examples/load_model.rs index 5384d5a72a..0ccc3ab137 100644 --- a/examples/load_model.rs +++ b/examples/load_model.rs @@ -2,5 +2,5 @@ use bevy::{asset, prelude::*}; fn main() { asset::load_gltf("examples/assets/Box.gltf").unwrap(); - AppBuilder::new().add_defaults().run(); + AppBuilder::new().add_defaults_legacy().run(); } diff --git a/examples/parenting.rs b/examples/parenting.rs index 6da5ab5b28..1dca75b192 100644 --- a/examples/parenting.rs +++ b/examples/parenting.rs @@ -4,7 +4,7 @@ struct Rotator; fn main() { AppBuilder::new() - .add_defaults() + .add_defaults_legacy() .setup_world(setup) .add_system(build_rotator_system()) .run(); diff --git a/examples/serializing.rs b/examples/serializing.rs index 3f1af2febb..e6a19949c7 100644 --- a/examples/serializing.rs +++ b/examples/serializing.rs @@ -2,7 +2,7 @@ use bevy::{prelude::*, serialization::*}; use serde::{Deserialize, Serialize}; use type_uuid::TypeUuid; fn main() { - let app = AppBuilder::new().add_defaults().setup_world(setup).build(); + let app = AppBuilder::new().add_defaults_legacy().setup_world(setup).build(); let comp_registrations = [ComponentRegistration::of::()]; diff --git a/examples/shader_material.rs b/examples/shader_material.rs index 0e8eb518a1..bbe0644e0c 100644 --- a/examples/shader_material.rs +++ b/examples/shader_material.rs @@ -1,7 +1,7 @@ use bevy::{prelude::*, asset, render::{Albedo, render_graph_2::{StandardMaterial, ShaderMaterials, ShaderMaterial, ShaderValue}}}; fn main() { - AppBuilder::new().add_defaults().setup_world(setup).run(); + AppBuilder::new().add_defaults_legacy().setup_world(setup).run(); } fn setup(world: &mut World) { diff --git a/examples/simple.rs b/examples/simple.rs index 42220a3929..0a22908cc0 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -1,7 +1,7 @@ use bevy::prelude::*; fn main() { - AppBuilder::new().add_defaults().setup_world(setup).run(); + AppBuilder::new().add_defaults_legacy().setup_world(setup).run(); } fn setup(world: &mut World) { diff --git a/examples/texture.rs b/examples/texture.rs index ac24f47f76..231ba59847 100644 --- a/examples/texture.rs +++ b/examples/texture.rs @@ -1,7 +1,7 @@ use bevy::{asset, prelude::*}; fn main() { - AppBuilder::new().add_defaults().setup_world(setup).run(); + AppBuilder::new().add_defaults_legacy().setup_world(setup).run(); } fn setup(world: &mut World) { diff --git a/examples/ui.rs b/examples/ui.rs index 7afb424024..6eb01f3a5c 100644 --- a/examples/ui.rs +++ b/examples/ui.rs @@ -1,7 +1,7 @@ use bevy::prelude::*; fn main() { - AppBuilder::new().add_defaults().setup_world(setup).run(); + AppBuilder::new().add_defaults_legacy().setup_world(setup).run(); } fn setup(world: &mut World) { diff --git a/src/app/app.rs b/src/app/app.rs index b9e087b174..2cb333233a 100644 --- a/src/app/app.rs +++ b/src/app/app.rs @@ -11,7 +11,7 @@ use crate::{core::Time, render::*, app::AppBuilder}; pub struct App { pub universe: Universe, pub world: World, - pub render_graph: RenderGraph, + pub legacy_render_graph: Option, pub schedule: Schedule, } @@ -20,13 +20,13 @@ impl App { universe: Universe, world: World, schedule: Schedule, - render_graph: RenderGraph, + legacy_render_graph: Option, ) -> App { App { universe, world, schedule: schedule, - render_graph, + legacy_render_graph: legacy_render_graph, } } @@ -39,7 +39,12 @@ impl App { time.start(); } self.schedule.execute(&mut self.world); - self.render_graph.render(&mut self.world); + + // TODO: remove me + if let Some(ref mut render_graph) = self.legacy_render_graph { + render_graph.render(&mut self.world); + } + if let Some(mut time) = self.world.resources.get_mut::