diff --git a/examples/simple.rs b/examples/simple.rs index 92b69f9b35..b95ebe4643 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -9,6 +9,9 @@ use bevy::{render::*, asset::{Asset, AssetStorage}, math}; fn main() { let universe = Universe::new(); let mut world = universe.create_world(); + let mut scheduler = SystemScheduler::::new(); + let transform_system_bundle = transform_system_bundle::build(&mut world); + scheduler.add_systems(ApplicationStage::Update, transform_system_bundle); // Create a query which finds all `Position` and `Velocity` components // let mut query = Read::::query(); let cube = Mesh::load(MeshType::Cube); @@ -25,21 +28,21 @@ fn main() { ( Material::new(math::vec4(0.1, 0.2, 0.1, 1.0)), plane_handle.clone(), - LocalToWorld(math::translation(&math::vec3(0.0, 0.0, 0.0))), + LocalToWorld::identity(), Translation::new(0.0, 0.0, 0.0) ), // cubes ( Material::new(math::vec4(0.1, 0.1, 0.6, 1.0)), mesh_handle.clone(), - LocalToWorld(math::translation(&math::vec3(1.5, 0.0, 1.0))), - Translation::new(0.0, 0.0, 0.0) + LocalToWorld::identity(), + Translation::new(1.5, 0.0, 1.0) ), ( Material::new(math::vec4(0.6, 0.1, 0.1, 1.0)), mesh_handle, - LocalToWorld(math::translation(&math::vec3(-1.5, 0.0, 1.0))), - Translation::new(0.0, 0.0, 0.0) + LocalToWorld::identity(), + Translation::new(-1.5, 0.0, 1.0) ), ]); world.insert((), vec![ @@ -57,8 +60,8 @@ fn main() { depth: 1.0 .. 20.0, target_view: None, }, - LocalToWorld(math::translation(&math::vec3(7.0, -5.0, 10.0))), - Translation::new(0.0, 0.0, 0.0) + LocalToWorld::identity(), + Translation::new(7.0, -5.0, 10.0) ), ( Light { @@ -73,8 +76,8 @@ fn main() { depth: 1.0 .. 20.0, target_view: None, }, - LocalToWorld(math::translation(&math::vec3(-1.5, 0.0, 1.0))), - Translation::new(0.0, 0.0, 0.0) + LocalToWorld::identity(), + Translation::new(-5.0, 7.0, 10.0) ), ]); world.insert((), vec![ @@ -86,13 +89,13 @@ fn main() { far: 20.0, aspect_ratio: 1.0, }), - LocalToWorld(math::look_at_rh(&math::vec3(3.0, -10.0, 6.0), - &math::vec3(0.0, 0.0, 0.0), - &math::vec3(0.0, 0.0, 1.0),)), - Translation::new(0.0, 0.0, 0.0) + LocalToWorld(math::look_at_rh( + &math::vec3(3.0, -10.0, 6.0), + &math::vec3(0.0, 0.0, 0.0), + &math::vec3(0.0, 0.0, 1.0),)), + // Translation::new(0.0, 0.0, 0.0), ) ]); - // let transform_system_bundle = transform_system_bundle::build(&mut world); - Application::run(universe, world); + Application::run(universe, world, scheduler); } \ No newline at end of file diff --git a/src/application.rs b/src/application.rs index 56114598c8..bf1d48d403 100644 --- a/src/application.rs +++ b/src/application.rs @@ -194,7 +194,7 @@ impl Application { } #[allow(dead_code)] - pub fn run(universe: Universe, world: World) { + pub fn run(universe: Universe, world: World, system_scheduler: SystemScheduler) { env_logger::init(); let event_loop = EventLoop::new(); log::info!("Initializing the window..."); @@ -242,7 +242,7 @@ impl Application { queue, swap_chain, swap_chain_descriptor, - scheduler: SystemScheduler::new(), + scheduler: system_scheduler, render_passes: Vec::new(), }; diff --git a/src/render/camera.rs b/src/render/camera.rs index 2f64b04a8f..fd324da68a 100644 --- a/src/render/camera.rs +++ b/src/render/camera.rs @@ -24,9 +24,9 @@ impl Camera { pub fn update(&mut self, width: u32, height: u32) { match &mut self.camera_type { - CameraType::Projection { mut aspect_ratio, fov, near, far } => { - aspect_ratio = width as f32 / height as f32; - self.view_matrix = get_projection_matrix(aspect_ratio, *fov, *near, *far) + CameraType::Projection { aspect_ratio, fov, near, far } => { + *aspect_ratio = width as f32 / height as f32; + self.view_matrix = get_projection_matrix(*fov, *aspect_ratio, *near, *far) } } }