cargo fmt
This commit is contained in:
		
							parent
							
								
									5cbf606ef7
								
							
						
					
					
						commit
						ef8c85f0c7
					
				| @ -1,7 +1,10 @@ | |||||||
| use bevy::prelude::*; | use bevy::prelude::*; | ||||||
| 
 | 
 | ||||||
| fn main() { | fn main() { | ||||||
|     App::build().add_default_plugins().add_setup_system(setup_system()).run(); |     App::build() | ||||||
|  |         .add_default_plugins() | ||||||
|  |         .add_setup_system(setup_system()) | ||||||
|  |         .run(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn setup_system() -> Box<dyn Schedulable> { | pub fn setup_system() -> Box<dyn Schedulable> { | ||||||
|  | |||||||
| @ -5,9 +5,9 @@ use crate::{ | |||||||
|     }, |     }, | ||||||
|     core::{CorePlugin, Events}, |     core::{CorePlugin, Events}, | ||||||
|     legion::prelude::{Resources, Runnable, Schedulable, Schedule, Universe, World}, |     legion::prelude::{Resources, Runnable, Schedulable, Schedule, Universe, World}, | ||||||
|     window::WindowPlugin, |  | ||||||
|     render::RenderPlugin, |     render::RenderPlugin, | ||||||
|     ui::UiPlugin, |     ui::UiPlugin, | ||||||
|  |     window::WindowPlugin, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| use std::collections::HashMap; | use std::collections::HashMap; | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| mod app; | mod app; | ||||||
| mod app_builder; | mod app_builder; | ||||||
| pub mod system_stage; |  | ||||||
| pub mod plugin; | pub mod plugin; | ||||||
| pub mod schedule_runner; | pub mod schedule_runner; | ||||||
|  | pub mod system_stage; | ||||||
| 
 | 
 | ||||||
| pub use app::App; | pub use app::App; | ||||||
| pub use app_builder::AppBuilder; | pub use app_builder::AppBuilder; | ||||||
|  | |||||||
| @ -6,17 +6,13 @@ use std::{thread, time::Duration}; | |||||||
| 
 | 
 | ||||||
| #[derive(Copy, Clone, Debug)] | #[derive(Copy, Clone, Debug)] | ||||||
| pub enum RunMode { | pub enum RunMode { | ||||||
|     Loop { |     Loop { wait: Option<Duration> }, | ||||||
|         wait: Option<Duration>, |  | ||||||
|     }, |  | ||||||
|     Once, |     Once, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl Default for RunMode { | impl Default for RunMode { | ||||||
|     fn default() -> Self { |     fn default() -> Self { | ||||||
|         RunMode::Loop { |         RunMode::Loop { wait: None } | ||||||
|             wait: None, |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -23,7 +23,10 @@ impl<T> Handle<T> { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pub fn from_untyped(untyped_handle: HandleUntyped) -> Option<Handle<T>> where T: 'static { |     pub fn from_untyped(untyped_handle: HandleUntyped) -> Option<Handle<T>> | ||||||
|  |     where | ||||||
|  |         T: 'static, | ||||||
|  |     { | ||||||
|         if TypeId::of::<T>() == untyped_handle.type_id { |         if TypeId::of::<T>() == untyped_handle.type_id { | ||||||
|             Some(Handle::new(untyped_handle.id)) |             Some(Handle::new(untyped_handle.id)) | ||||||
|         } else { |         } else { | ||||||
| @ -96,7 +99,8 @@ where | |||||||
|     T: 'static, |     T: 'static, | ||||||
| { | { | ||||||
|     fn from(handle: HandleUntyped) -> Self { |     fn from(handle: HandleUntyped) -> Self { | ||||||
|         Handle::from_untyped(handle).expect("attempted to convert untyped handle to incorrect typed handle") |         Handle::from_untyped(handle) | ||||||
|  |             .expect("attempted to convert untyped handle to incorrect typed handle") | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
|  | use super::Time; | ||||||
| use crate::app::{plugin::AppPlugin, AppBuilder}; | use crate::app::{plugin::AppPlugin, AppBuilder}; | ||||||
| use bevy_transform::transform_system_bundle; | use bevy_transform::transform_system_bundle; | ||||||
| use super::Time; |  | ||||||
| 
 | 
 | ||||||
| #[derive(Default)] | #[derive(Default)] | ||||||
| pub struct CorePlugin; | pub struct CorePlugin; | ||||||
| @ -11,8 +11,7 @@ impl AppPlugin for CorePlugin { | |||||||
|             app = app.add_system(transform_system); |             app = app.add_system(transform_system); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         app |         app.add_resource(Time::new()) | ||||||
|             .add_resource(Time::new()) |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn name(&self) -> &'static str { |     fn name(&self) -> &'static str { | ||||||
|  | |||||||
| @ -1,9 +1,9 @@ | |||||||
| pub mod bytes; | pub mod bytes; | ||||||
| mod time; |  | ||||||
| mod core_plugin; | mod core_plugin; | ||||||
| pub mod event; | pub mod event; | ||||||
|  | mod time; | ||||||
| 
 | 
 | ||||||
| pub use bytes::*; | pub use bytes::*; | ||||||
| pub use time::*; |  | ||||||
| pub use core_plugin::*; | pub use core_plugin::*; | ||||||
| pub use event::*; | pub use event::*; | ||||||
|  | pub use time::*; | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ use super::{ | |||||||
|     diagnostics::{frame_time_diagnostic_system, print_diagnostics_system}, |     diagnostics::{frame_time_diagnostic_system, print_diagnostics_system}, | ||||||
|     Diagnostics, |     Diagnostics, | ||||||
| }; | }; | ||||||
| use crate::{app::AppBuilder, app::plugin::AppPlugin}; | use crate::app::{plugin::AppPlugin, AppBuilder}; | ||||||
| use std::time::Duration; | use std::time::Duration; | ||||||
| 
 | 
 | ||||||
| pub struct DiagnosticsPlugin { | pub struct DiagnosticsPlugin { | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| pub mod diagnostics; |  | ||||||
| mod diagnostic_plugin; | mod diagnostic_plugin; | ||||||
|  | pub mod diagnostics; | ||||||
| pub use diagnostic_plugin::*; | pub use diagnostic_plugin::*; | ||||||
| 
 | 
 | ||||||
| use std::{ | use std::{ | ||||||
| @ -36,10 +36,8 @@ impl Diagnostic { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         self.sum += value; |         self.sum += value; | ||||||
|         self.history.push_front(DiagnosticMeasurement { |         self.history | ||||||
|             time, |             .push_front(DiagnosticMeasurement { time, value }); | ||||||
|             value, |  | ||||||
|         }); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pub fn new(id: DiagnosticId, name: &str, max_history_length: usize) -> Diagnostic { |     pub fn new(id: DiagnosticId, name: &str, max_history_length: usize) -> Diagnostic { | ||||||
| @ -74,22 +72,21 @@ impl Diagnostic { | |||||||
| 
 | 
 | ||||||
|     pub fn duration(&self) -> Option<Duration> { |     pub fn duration(&self) -> Option<Duration> { | ||||||
|         if self.history.len() < 2 { |         if self.history.len() < 2 { | ||||||
|             return None |             return None; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if let Some(oldest) = self.history.back() { |         if let Some(oldest) = self.history.back() { | ||||||
|             if let Some(newest) = self.history.front() { |             if let Some(newest) = self.history.front() { | ||||||
|                 return newest.time.duration_since(oldest.time).ok() |                 return newest.time.duration_since(oldest.time).ok(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return None |         return None; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pub fn get_max_history_length(&self) -> usize { |     pub fn get_max_history_length(&self) -> usize { | ||||||
|         self.max_history_length |         self.max_history_length | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[derive(Default)] | #[derive(Default)] | ||||||
| @ -111,7 +108,9 @@ impl Diagnostics { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pub fn get_measurement(&self, id: DiagnosticId) -> Option<&DiagnosticMeasurement> { |     pub fn get_measurement(&self, id: DiagnosticId) -> Option<&DiagnosticMeasurement> { | ||||||
|         self.diagnostics.get(&id).and_then(|diagnostic| diagnostic.history.front()) |         self.diagnostics | ||||||
|  |             .get(&id) | ||||||
|  |             .and_then(|diagnostic| diagnostic.history.front()) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pub fn add_measurement(&mut self, id: DiagnosticId, value: f64) { |     pub fn add_measurement(&mut self, id: DiagnosticId, value: f64) { | ||||||
|  | |||||||
| @ -1,8 +1,7 @@ | |||||||
| pub use crate::{ | pub use crate::{ | ||||||
|     app::{plugin::AppPlugin, App, AppBuilder}, |     app::{plugin::AppPlugin, App, AppBuilder}, | ||||||
|     asset::{Asset, AssetStorage, Handle}, |     asset::{Asset, AssetStorage, Handle}, | ||||||
|     window::{Window, Windows, WindowDescriptor, WindowPlugin}, |     core::{EventReader, Events, GetEventReader, Time}, | ||||||
|     core::{Events, EventReader, GetEventReader, Time}, |  | ||||||
|     diagnostic::DiagnosticsPlugin, |     diagnostic::DiagnosticsPlugin, | ||||||
|     ecs, |     ecs, | ||||||
|     ecs::{ |     ecs::{ | ||||||
| @ -21,6 +20,7 @@ pub use crate::{ | |||||||
|         ActiveCamera, ActiveCamera2d, Camera, CameraType, Color, ColorSource, Light, Renderable, |         ActiveCamera, ActiveCamera2d, Camera, CameraType, Color, ColorSource, Light, Renderable, | ||||||
|     }, |     }, | ||||||
|     ui::{Anchors, Margins, Node}, |     ui::{Anchors, Margins, Node}, | ||||||
|  |     window::{Window, WindowDescriptor, WindowPlugin, Windows}, | ||||||
| }; | }; | ||||||
| pub use bevy_derive::*; | pub use bevy_derive::*; | ||||||
| pub use bevy_transform::prelude::*; | pub use bevy_transform::prelude::*; | ||||||
|  | |||||||
| @ -76,24 +76,33 @@ impl DrawTarget for AssignedBatchesDrawTarget { | |||||||
|         let mut global_render_resource_assignments = |         let mut global_render_resource_assignments = | ||||||
|             resources.get_mut::<RenderResourceAssignments>().unwrap(); |             resources.get_mut::<RenderResourceAssignments>().unwrap(); | ||||||
| 
 | 
 | ||||||
|         log::debug!("setting up batch bind groups for pipeline: {:?}", pipeline_handle); |         log::debug!( | ||||||
|  |             "setting up batch bind groups for pipeline: {:?}", | ||||||
|  |             pipeline_handle | ||||||
|  |         ); | ||||||
|         log::trace!("setting up global bind groups"); |         log::trace!("setting up global bind groups"); | ||||||
|         renderer.setup_bind_groups(&mut global_render_resource_assignments, pipeline_descriptor); |         renderer.setup_bind_groups(&mut global_render_resource_assignments, pipeline_descriptor); | ||||||
| 
 | 
 | ||||||
|         for batch in asset_batches.get_batches_mut() { |         for batch in asset_batches.get_batches_mut() { | ||||||
|             log::debug!("setting up batch bind groups: {:?}", batch.render_resource_assignments.id); |             log::debug!( | ||||||
|             log::trace!("{:#?}", batch); |                 "setting up batch bind groups: {:?}", | ||||||
|             renderer.setup_bind_groups( |                 batch.render_resource_assignments.id | ||||||
|                 &mut batch.render_resource_assignments, |  | ||||||
|                 pipeline_descriptor, |  | ||||||
|             ); |             ); | ||||||
|  |             log::trace!("{:#?}", batch); | ||||||
|  |             renderer.setup_bind_groups(&mut batch.render_resource_assignments, pipeline_descriptor); | ||||||
|             for batched_entity in batch.entities.iter() { |             for batched_entity in batch.entities.iter() { | ||||||
|                 let mut renderable = world.get_component_mut::<Renderable>(*batched_entity).unwrap(); |                 let mut renderable = world | ||||||
|  |                     .get_component_mut::<Renderable>(*batched_entity) | ||||||
|  |                     .unwrap(); | ||||||
|                 if !renderable.is_visible || renderable.is_instanced { |                 if !renderable.is_visible || renderable.is_instanced { | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 log::trace!("setting up entity bind group {:?} for batch {:?}", batched_entity, batch.render_resource_assignments.id); |                 log::trace!( | ||||||
|  |                     "setting up entity bind group {:?} for batch {:?}", | ||||||
|  |                     batched_entity, | ||||||
|  |                     batch.render_resource_assignments.id | ||||||
|  |                 ); | ||||||
|                 renderer.setup_bind_groups( |                 renderer.setup_bind_groups( | ||||||
|                     &mut renderable.render_resource_assignments, |                     &mut renderable.render_resource_assignments, | ||||||
|                     pipeline_descriptor, |                     pipeline_descriptor, | ||||||
|  | |||||||
| @ -2,12 +2,8 @@ use crate::{asset::Asset, math::*, render::Vertex}; | |||||||
| 
 | 
 | ||||||
| pub enum MeshType { | pub enum MeshType { | ||||||
|     Cube, |     Cube, | ||||||
|     Plane { |     Plane { size: f32 }, | ||||||
|         size: f32, |     Quad { size: Vec2 }, | ||||||
|     }, |  | ||||||
|     Quad { |  | ||||||
|         size: Vec2, |  | ||||||
|     }, |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub struct Mesh { | pub struct Mesh { | ||||||
| @ -20,9 +16,7 @@ impl Asset<MeshType> for Mesh { | |||||||
|         let (vertices, indices) = match descriptor { |         let (vertices, indices) = match descriptor { | ||||||
|             MeshType::Cube => create_cube(), |             MeshType::Cube => create_cube(), | ||||||
|             MeshType::Plane { size } => create_plane(size), |             MeshType::Plane { size } => create_plane(size), | ||||||
|             MeshType::Quad { |             MeshType::Quad { size } => create_quad(size), | ||||||
|                 size |  | ||||||
|             } => create_quad(size), |  | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         Mesh { vertices, indices } |         Mesh { vertices, indices } | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| mod camera; | mod camera; | ||||||
| pub mod mesh; | pub mod mesh; | ||||||
| pub mod render_graph; | pub mod render_graph; | ||||||
| pub mod shader; |  | ||||||
| mod render_plugin; | mod render_plugin; | ||||||
|  | pub mod shader; | ||||||
| 
 | 
 | ||||||
| mod color; | mod color; | ||||||
| mod light; | mod light; | ||||||
| @ -11,8 +11,8 @@ mod vertex; | |||||||
| pub use camera::*; | pub use camera::*; | ||||||
| pub use color::*; | pub use color::*; | ||||||
| pub use light::*; | pub use light::*; | ||||||
| pub use renderable::*; |  | ||||||
| pub use render_plugin::*; | pub use render_plugin::*; | ||||||
|  | pub use renderable::*; | ||||||
| 
 | 
 | ||||||
| pub use vertex::Vertex; | pub use vertex::Vertex; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| use super::UniformProperty; | use super::UniformProperty; | ||||||
| use crate::render::texture::{TextureComponentType, TextureViewDimension, TextureFormat}; | use crate::render::texture::{TextureComponentType, TextureFormat, TextureViewDimension}; | ||||||
| 
 | 
 | ||||||
| #[derive(Hash, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] | #[derive(Hash, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] | ||||||
| pub struct BindingDescriptor { | pub struct BindingDescriptor { | ||||||
|  | |||||||
| @ -236,7 +236,11 @@ impl ShaderPipelineAssignments { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // TODO: make this a system
 | // TODO: make this a system
 | ||||||
| pub fn update_shader_assignments(world: &mut World, resources: &mut Resources, renderer: &dyn Renderer) { | pub fn update_shader_assignments( | ||||||
|  |     world: &mut World, | ||||||
|  |     resources: &mut Resources, | ||||||
|  |     renderer: &dyn Renderer, | ||||||
|  | ) { | ||||||
|     // PERF: this seems like a lot of work for things that don't change that often.
 |     // PERF: this seems like a lot of work for things that don't change that often.
 | ||||||
|     // lots of string + hashset allocations. sees uniform_resource_provider for more context
 |     // lots of string + hashset allocations. sees uniform_resource_provider for more context
 | ||||||
|     { |     { | ||||||
|  | |||||||
| @ -251,10 +251,9 @@ mod tests { | |||||||
|         ]; |         ]; | ||||||
|         expected_batches.sort_by(|a, b| a.0.cmp(&b.0)); |         expected_batches.sort_by(|a, b| a.0.cmp(&b.0)); | ||||||
|         // copy ignored fields
 |         // copy ignored fields
 | ||||||
|         batches |         batches.iter().zip(expected_batches.iter_mut()).for_each( | ||||||
|             .iter() |             |((_, ref actual), (_, ref mut expected))| copy_ignored_fields(actual, expected), | ||||||
|             .zip(expected_batches.iter_mut()) |         ); | ||||||
|             .for_each(|((_, ref actual), (_, ref mut expected))| copy_ignored_fields(actual, expected)); |  | ||||||
|         assert_eq!( |         assert_eq!( | ||||||
|             batches, |             batches, | ||||||
|             expected_batches |             expected_batches | ||||||
|  | |||||||
| @ -27,7 +27,10 @@ impl Batch { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pub fn get_handle<T>(&self) -> Option<Handle<T>> where T: 'static { |     pub fn get_handle<T>(&self) -> Option<Handle<T>> | ||||||
|  |     where | ||||||
|  |         T: 'static, | ||||||
|  |     { | ||||||
|         self.handles |         self.handles | ||||||
|             .iter() |             .iter() | ||||||
|             .map(|h| Handle::from_untyped(*h)) |             .map(|h| Handle::from_untyped(*h)) | ||||||
|  | |||||||
| @ -1,5 +1,4 @@ | |||||||
| use crate::{ | use crate::{ | ||||||
|     window::WindowResized, |  | ||||||
|     prelude::*, |     prelude::*, | ||||||
|     render::{ |     render::{ | ||||||
|         render_resource::{ |         render_resource::{ | ||||||
| @ -7,6 +6,7 @@ use crate::{ | |||||||
|         }, |         }, | ||||||
|         renderer::Renderer, |         renderer::Renderer, | ||||||
|     }, |     }, | ||||||
|  |     window::WindowResized, | ||||||
| }; | }; | ||||||
| use zerocopy::AsBytes; | use zerocopy::AsBytes; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,5 +1,4 @@ | |||||||
| use crate::{ | use crate::{ | ||||||
|     window::WindowResized, |  | ||||||
|     prelude::*, |     prelude::*, | ||||||
|     render::{ |     render::{ | ||||||
|         render_resource::{ |         render_resource::{ | ||||||
| @ -9,6 +8,7 @@ use crate::{ | |||||||
|         renderer::Renderer, |         renderer::Renderer, | ||||||
|         ActiveCamera, Camera, |         ActiveCamera, Camera, | ||||||
|     }, |     }, | ||||||
|  |     window::WindowResized, | ||||||
| }; | }; | ||||||
| use zerocopy::AsBytes; | use zerocopy::AsBytes; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| use crate::{ | use crate::{ | ||||||
|     window::Windows, |  | ||||||
|     prelude::World, |     prelude::World, | ||||||
|     render::{ |     render::{ | ||||||
|         render_resource::{RenderResourceAssignments, ResourceProvider}, |         render_resource::{RenderResourceAssignments, ResourceProvider}, | ||||||
|         renderer::Renderer, |         renderer::Renderer, | ||||||
|         texture::TextureDescriptor, |         texture::TextureDescriptor, | ||||||
|     }, |     }, | ||||||
|  |     window::Windows, | ||||||
| }; | }; | ||||||
| use legion::prelude::Resources; | use legion::prelude::Resources; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -42,12 +42,22 @@ impl MeshResourceProvider { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn setup_mesh_resources(renderer: &mut dyn Renderer, mesh_storage: &mut AssetStorage<Mesh>, handle: Handle<Mesh>, render_resource_assignments: &mut RenderResourceAssignments) { |     fn setup_mesh_resources( | ||||||
|  |         renderer: &mut dyn Renderer, | ||||||
|  |         mesh_storage: &mut AssetStorage<Mesh>, | ||||||
|  |         handle: Handle<Mesh>, | ||||||
|  |         render_resource_assignments: &mut RenderResourceAssignments, | ||||||
|  |     ) { | ||||||
|         let (vertex_buffer, index_buffer) = if let Some(vertex_buffer) = renderer |         let (vertex_buffer, index_buffer) = if let Some(vertex_buffer) = renderer | ||||||
|             .get_render_resources() |             .get_render_resources() | ||||||
|             .get_mesh_vertices_resource(handle) |             .get_mesh_vertices_resource(handle) | ||||||
|         { |         { | ||||||
|             (vertex_buffer, renderer.get_render_resources().get_mesh_indices_resource(handle)) |             ( | ||||||
|  |                 vertex_buffer, | ||||||
|  |                 renderer | ||||||
|  |                     .get_render_resources() | ||||||
|  |                     .get_mesh_indices_resource(handle), | ||||||
|  |             ) | ||||||
|         } else { |         } else { | ||||||
|             let mesh_asset = mesh_storage.get(&handle).unwrap(); |             let mesh_asset = mesh_storage.get(&handle).unwrap(); | ||||||
|             let vertex_buffer = renderer.create_buffer_with_data( |             let vertex_buffer = renderer.create_buffer_with_data( | ||||||
| @ -109,7 +119,12 @@ impl ResourceProvider for MeshResourceProvider { | |||||||
|                 for batch in batches { |                 for batch in batches { | ||||||
|                     let handle = batch.get_handle::<Mesh>().unwrap(); |                     let handle = batch.get_handle::<Mesh>().unwrap(); | ||||||
|                     log::trace!("setup mesh for {:?}", batch.render_resource_assignments.id); |                     log::trace!("setup mesh for {:?}", batch.render_resource_assignments.id); | ||||||
|                     Self::setup_mesh_resources(renderer, &mut mesh_storage, handle, &mut batch.render_resource_assignments); |                     Self::setup_mesh_resources( | ||||||
|  |                         renderer, | ||||||
|  |                         &mut mesh_storage, | ||||||
|  |                         handle, | ||||||
|  |                         &mut batch.render_resource_assignments, | ||||||
|  |                     ); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         }; |         }; | ||||||
|  | |||||||
| @ -10,7 +10,8 @@ pub use wgpu_resources::*; | |||||||
| use crate::{ | use crate::{ | ||||||
|     app::{plugin::AppPlugin, system_stage, AppBuilder}, |     app::{plugin::AppPlugin, system_stage, AppBuilder}, | ||||||
|     core::Events, |     core::Events, | ||||||
|     render::renderer::Renderer, window::{WindowCreated, WindowResized}, |     render::renderer::Renderer, | ||||||
|  |     window::{WindowCreated, WindowResized}, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| use legion::prelude::*; | use legion::prelude::*; | ||||||
|  | |||||||
| @ -15,8 +15,7 @@ pub struct UiPlugin; | |||||||
| 
 | 
 | ||||||
| impl AppPlugin for UiPlugin { | impl AppPlugin for UiPlugin { | ||||||
|     fn build(&self, app: AppBuilder) -> AppBuilder { |     fn build(&self, app: AppBuilder) -> AppBuilder { | ||||||
|         app |         app.add_system(ui_update_system()) | ||||||
|             .add_system(ui_update_system()) |  | ||||||
|     } |     } | ||||||
|     fn name(&self) -> &'static str { |     fn name(&self) -> &'static str { | ||||||
|         "UI" |         "UI" | ||||||
|  | |||||||
| @ -1,12 +1,12 @@ | |||||||
|  | mod events; | ||||||
|  | mod window_plugin; | ||||||
|  | mod windows; | ||||||
| #[cfg(feature = "winit")] | #[cfg(feature = "winit")] | ||||||
| pub mod winit; | pub mod winit; | ||||||
| mod events; |  | ||||||
| mod windows; |  | ||||||
| mod window_plugin; |  | ||||||
| 
 | 
 | ||||||
| pub use events::*; | pub use events::*; | ||||||
| pub use windows::*; |  | ||||||
| pub use window_plugin::*; | pub use window_plugin::*; | ||||||
|  | pub use windows::*; | ||||||
| 
 | 
 | ||||||
| use uuid::Uuid; | use uuid::Uuid; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,5 +1,8 @@ | |||||||
| use super::{CreateWindow, WindowCreated, WindowResized, Windows, WindowDescriptor}; | use super::{CreateWindow, WindowCreated, WindowDescriptor, WindowResized, Windows}; | ||||||
| use crate::{core::Events, app::{plugin::AppPlugin, AppBuilder}}; | use crate::{ | ||||||
|  |     app::{plugin::AppPlugin, AppBuilder}, | ||||||
|  |     core::Events, | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| pub struct WindowPlugin { | pub struct WindowPlugin { | ||||||
|     pub primary_window: Option<WindowDescriptor>, |     pub primary_window: Option<WindowDescriptor>, | ||||||
| @ -15,7 +18,8 @@ impl Default for WindowPlugin { | |||||||
| 
 | 
 | ||||||
| impl AppPlugin for WindowPlugin { | impl AppPlugin for WindowPlugin { | ||||||
|     fn build(&self, mut app: AppBuilder) -> AppBuilder { |     fn build(&self, mut app: AppBuilder) -> AppBuilder { | ||||||
|         app = app.add_event::<WindowResized>() |         app = app | ||||||
|  |             .add_event::<WindowResized>() | ||||||
|             .add_event::<CreateWindow>() |             .add_event::<CreateWindow>() | ||||||
|             .add_event::<WindowCreated>() |             .add_event::<WindowCreated>() | ||||||
|             .add_resource(Windows::default()); |             .add_resource(Windows::default()); | ||||||
|  | |||||||
| @ -109,7 +109,13 @@ fn handle_create_window_events( | |||||||
|         winit_windows.create_window(event_loop, &window); |         winit_windows.create_window(event_loop, &window); | ||||||
|         let window_id = window.id; |         let window_id = window.id; | ||||||
|         windows.add(window); |         windows.add(window); | ||||||
|         let is_primary = windows.get_primary().map(|primary| primary.id == window_id).unwrap_or(false); |         let is_primary = windows | ||||||
|         window_created_events.send(WindowCreated { id: window_id, is_primary }); |             .get_primary() | ||||||
|  |             .map(|primary| primary.id == window_id) | ||||||
|  |             .unwrap_or(false); | ||||||
|  |         window_created_events.send(WindowCreated { | ||||||
|  |             id: window_id, | ||||||
|  |             is_primary, | ||||||
|  |         }); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| use crate::{window::WindowId, prelude::*}; | use crate::{prelude::*, window::WindowId}; | ||||||
| use std::collections::HashMap; | use std::collections::HashMap; | ||||||
| 
 | 
 | ||||||
| #[derive(Default)] | #[derive(Default)] | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Carter Anderson
						Carter Anderson