From 151675a5efd9598c4ca7ff698d86b3fe17cad30f Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Sat, 11 Jan 2020 03:31:36 -0800 Subject: [PATCH] upgrade legion. refactor system and world construction --- Cargo.toml | 2 +- examples/instancing.rs | 27 +++++----- examples/parenting.rs | 14 ++--- examples/simple.rs | 7 +-- examples/ui.rs | 7 +-- src/app/app_builder.rs | 51 +++++++++++++------ src/app/app_stage.rs | 18 ------- src/app/mod.rs | 10 ++-- src/lib.rs | 4 +- src/render/passes/forward/forward_pipeline.rs | 4 +- src/render/passes/forward_instanced/mod.rs | 12 ++--- src/render/passes/forward_shadow/mod.rs | 4 +- src/render/passes/shadow/shadow_pass.rs | 6 +-- src/render/passes/shadow/shadow_pipeline.rs | 4 +- src/render/passes/ui/mod.rs | 6 +-- .../global_2d_resource_manager.rs | 2 +- .../global_resource_manager.rs | 4 +- .../light_resource_manager.rs | 2 +- .../material_resource_manager.rs | 10 ++-- src/transform/Cargo.toml | 2 +- .../src/hierarchy_maintenance_system.rs | 2 +- .../src/local_to_world_propagate_system.rs | 4 +- src/transform/src/local_to_world_system.rs | 2 +- 23 files changed, 100 insertions(+), 104 deletions(-) delete mode 100644 src/app/app_stage.rs diff --git a/Cargo.toml b/Cargo.toml index c737fed958..763d52d4bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Carter Anderson "] edition = "2018" [dependencies] -legion = { git = "https://github.com/TomGillen/legion.git", rev = "8628b227bcbe57582fffb5e80e73c634ec4eebd9" } +legion = { git = "https://github.com/TomGillen/legion.git", rev = "940ef3bfcb77e5d074ee3184b776ff1600da228d" } legion_transform = { path = "src/transform" } wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "44fa1bc2fa208fa92f80944253e0da56cb7ac1fe"} glam = "0.8.4" diff --git a/examples/instancing.rs b/examples/instancing.rs index 69f81d92bb..5caa58adb5 100644 --- a/examples/instancing.rs +++ b/examples/instancing.rs @@ -25,10 +25,20 @@ struct Wander { } fn main() { - AppBuilder::new().add_defaults().setup(&setup).run(); + AppBuilder::new() + .add_defaults() + .setup_world(setup) + .setup_systems(|builder| { + builder + .add_system(build_wander_system()) + .add_system(build_navigate_system()) + .add_system(build_move_system()) + .add_system(build_print_status_system()) + }) + .run(); } -fn setup(world: &mut World, scheduler: &mut SystemScheduler) { +fn setup(world: &mut World) { let cube = Mesh::load(MeshType::Cube); let cube_handle = { let mut mesh_storage = world @@ -38,13 +48,6 @@ fn setup(world: &mut World, scheduler: &mut SystemScheduler) { mesh_storage.add(cube, "cube") }; - let transform_system_bundle = transform_system_bundle::build(world); - scheduler.add_systems(AppStage::Update, transform_system_bundle); - scheduler.add_system(AppStage::Update, build_wander_system()); - scheduler.add_system(AppStage::Update, build_navigate_system()); - scheduler.add_system(AppStage::Update, build_move_system()); - scheduler.add_system(AppStage::Update, build_print_status_system()); - world.insert( (), vec![ @@ -112,7 +115,7 @@ fn build_wander_system() -> Box { Write, )>::query()) .build(move |_, world, time, person_query| { - for (_, translation, mut wander, mut navigation_point) in person_query.iter(world) { + for (_, translation, mut wander, mut navigation_point) in person_query.iter_mut(world) { wander.elapsed += time.delta_seconds; if wander.elapsed >= wander.duration { let direction = math::vec3( @@ -141,7 +144,7 @@ fn build_navigate_system() -> Box { Write, )>::query()) .build(move |_, world, _, person_query| { - for (_, translation, mut velocity, navigation_point) in person_query.iter(world) { + for (_, translation, mut velocity, navigation_point) in person_query.iter_mut(world) { let distance = navigation_point.target - translation.0; if distance.length() > 0.01 { let direction = distance.normalize(); @@ -158,7 +161,7 @@ fn build_move_system() -> Box { .read_resource::