From ee03942e40a3fae0ada6bd4ab287d4c86a6744dc Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Sat, 11 Jan 2020 01:59:39 -0800 Subject: [PATCH] rustfmt examples --- examples/empty.rs | 6 +- examples/instancing.rs | 161 ++++++++++++++++++++++------------------- examples/load_model.rs | 6 +- examples/parenting.rs | 106 +++++++++++++++------------ examples/simple.rs | 75 +++++++++++-------- examples/ui.rs | 159 +++++++++++++++++++++------------------- 6 files changed, 279 insertions(+), 234 deletions(-) diff --git a/examples/empty.rs b/examples/empty.rs index 2884e24afc..b2f94e5436 100644 --- a/examples/empty.rs +++ b/examples/empty.rs @@ -1,7 +1,5 @@ use bevy::*; fn main() { - AppBuilder::new() - .add_defaults() - .run(); -} \ No newline at end of file + AppBuilder::new().add_defaults().run(); +} diff --git a/examples/instancing.rs b/examples/instancing.rs index b55ddc247a..69f81d92bb 100644 --- a/examples/instancing.rs +++ b/examples/instancing.rs @@ -1,6 +1,10 @@ -use bevy::*; -use bevy::{render::*, asset::{Asset, AssetStorage, Handle}, math::{Mat4, Vec3}, Schedulable}; -use rand::{rngs::StdRng, Rng, SeedableRng, random}; +use bevy::{ + asset::{Asset, AssetStorage, Handle}, + math::{Mat4, Vec3}, + render::*, + Schedulable, *, +}; +use rand::{random, rngs::StdRng, Rng, SeedableRng}; use std::collections::VecDeque; struct Person; @@ -21,16 +25,16 @@ struct Wander { } fn main() { - AppBuilder::new() - .add_defaults() - .setup(&setup) - .run(); + AppBuilder::new().add_defaults().setup(&setup).run(); } fn setup(world: &mut World, scheduler: &mut SystemScheduler) { let cube = Mesh::load(MeshType::Cube); let cube_handle = { - let mut mesh_storage = world.resources.get_mut::>().unwrap(); + let mut mesh_storage = world + .resources + .get_mut::>() + .unwrap(); mesh_storage.add(cube, "cube") }; @@ -41,54 +45,64 @@ fn setup(world: &mut World, scheduler: &mut SystemScheduler) { scheduler.add_system(AppStage::Update, build_move_system()); scheduler.add_system(AppStage::Update, build_print_status_system()); - world.insert((), vec![ - // lights - ( - Light { - color: wgpu::Color { - r: 0.8, - g: 0.8, - b: 0.5, - a: 1.0, + world.insert( + (), + vec![ + // lights + ( + Light { + color: wgpu::Color { + r: 0.8, + g: 0.8, + b: 0.5, + a: 1.0, + }, + fov: f32::to_radians(60.0), + depth: 0.1..50.0, + target_view: None, }, - fov: f32::to_radians(60.0), - depth: 0.1 .. 50.0, - target_view: None, - }, - Material::new(math::vec4(0.5, 0.3, 0.3, 1.0)), - LocalToWorld::identity(), - Translation::new(4.0, -4.0, 5.0), - Rotation::from_euler_angles(0.0, 0.0, 0.0) - ), - ]); + Material::new(math::vec4(0.5, 0.3, 0.3, 1.0)), + LocalToWorld::identity(), + Translation::new(4.0, -4.0, 5.0), + Rotation::from_euler_angles(0.0, 0.0, 0.0), + ), + ], + ); - world.insert((), vec![ - // camera - ( - Camera::new(CameraType::Projection { - fov: std::f32::consts::PI / 4.0, - near: 1.0, - far: 1000.0, - aspect_ratio: 1.0, - }), - ActiveCamera, - LocalToWorld(Mat4::look_at_rh( - Vec3::new(6.0, -40.0, 20.0), - Vec3::new(0.0, 0.0, 0.0), - Vec3::new(0.0, 0.0, 1.0),)), - ) - ]); + world.insert( + (), + vec![ + // camera + ( + Camera::new(CameraType::Projection { + fov: std::f32::consts::PI / 4.0, + near: 1.0, + far: 1000.0, + aspect_ratio: 1.0, + }), + ActiveCamera, + LocalToWorld(Mat4::look_at_rh( + Vec3::new(6.0, -40.0, 20.0), + Vec3::new(0.0, 0.0, 0.0), + Vec3::new(0.0, 0.0, 1.0), + )), + ), + ], + ); let mut rng = StdRng::from_entropy(); - for _ in 0 .. 70000 { - create_person(world, cube_handle.clone(), - Translation::new(rng.gen_range(-50.0, 50.0), 0.0, rng.gen_range(-50.0, 50.0))); + for _ in 0..70000 { + create_person( + world, + cube_handle.clone(), + Translation::new(rng.gen_range(-50.0, 50.0), 0.0, rng.gen_range(-50.0, 50.0)), + ); } } fn build_wander_system() -> Box { let mut rng = StdRng::from_entropy(); - + SystemBuilder::new("Wander") .read_resource::