cargo fmt

This commit is contained in:
Carter Anderson 2020-07-16 17:23:50 -07:00
parent 1db77b2435
commit 196bde64e3
31 changed files with 55 additions and 43 deletions

View File

@ -1,5 +1,5 @@
use super::AppBuilder; use super::AppBuilder;
use bevy_ecs::{Resources, Schedule, World, ParallelExecutor}; use bevy_ecs::{ParallelExecutor, Resources, Schedule, World};
#[derive(Default)] #[derive(Default)]
pub struct App { pub struct App {
@ -19,12 +19,17 @@ impl App {
pub fn update(&mut self) { pub fn update(&mut self) {
self.schedule.initialize(&mut self.resources); self.schedule.initialize(&mut self.resources);
self.executor.run(&mut self.schedule, &mut self.world, &mut self.resources); self.executor
.run(&mut self.schedule, &mut self.world, &mut self.resources);
} }
pub fn run(mut self) { pub fn run(mut self) {
self.startup_schedule.initialize(&mut self.resources); self.startup_schedule.initialize(&mut self.resources);
self.startup_executor.run(&mut self.startup_schedule, &mut self.world, &mut self.resources); self.startup_executor.run(
&mut self.startup_schedule,
&mut self.world,
&mut self.resources,
);
if let Some(run) = self.runner.take() { if let Some(run) = self.runner.take() {
run(self) run(self)
} }

View File

@ -1,6 +1,6 @@
use anyhow::Result; use anyhow::Result;
use bevy_asset::AssetLoader; use bevy_asset::AssetLoader;
use std::{sync::Arc, path::Path}; use std::{path::Path, sync::Arc};
#[derive(Clone)] #[derive(Clone)]
pub struct AudioSource { pub struct AudioSource {
@ -18,7 +18,9 @@ pub struct Mp3Loader;
impl AssetLoader<AudioSource> for Mp3Loader { impl AssetLoader<AudioSource> for Mp3Loader {
fn from_bytes(&self, _asset_path: &Path, bytes: Vec<u8>) -> Result<AudioSource> { fn from_bytes(&self, _asset_path: &Path, bytes: Vec<u8>) -> Result<AudioSource> {
Ok(AudioSource { bytes: Arc::new(bytes) }) Ok(AudioSource {
bytes: Arc::new(bytes),
})
} }
fn extensions(&self) -> &[&str] { fn extensions(&self) -> &[&str] {
static EXTENSIONS: &[&str] = &["mp3"]; static EXTENSIONS: &[&str] = &["mp3"];

View File

@ -4,9 +4,9 @@ pub mod time;
use bevy_app::{stage, AppBuilder, AppPlugin}; use bevy_app::{stage, AppBuilder, AppPlugin};
use bevy_ecs::IntoQuerySystem; use bevy_ecs::IntoQuerySystem;
use bevy_math::{Mat3, Mat4, Quat, Vec2, Vec3};
use bevy_type_registry::RegisterType; use bevy_type_registry::RegisterType;
use time::{time_system, timer_system, Time, Timer}; use time::{time_system, timer_system, Time, Timer};
use bevy_math::{Vec3, Vec2, Mat3, Mat4, Quat};
#[derive(Default)] #[derive(Default)]
pub struct CorePlugin; pub struct CorePlugin;

View File

@ -47,7 +47,7 @@ pub fn get_modules(attributes: &[Attribute]) -> Modules {
if attribute.path.get_ident().as_ref().unwrap().to_string() == AS_CRATE_ATTRIBUTE_NAME { if attribute.path.get_ident().as_ref().unwrap().to_string() == AS_CRATE_ATTRIBUTE_NAME {
let value = attribute.tokens.to_string(); let value = attribute.tokens.to_string();
if &value[1..value.len() - 1] == modules.bevy_render { if &value[1..value.len() - 1] == modules.bevy_render {
modules.bevy_render = "crate".to_string(); modules.bevy_render = "crate".to_string();
} }
} }
} }

View File

@ -49,7 +49,7 @@ where
fn archetype_access(&self) -> &ArchetypeAccess { fn archetype_access(&self) -> &ArchetypeAccess {
&self.archetype_access &self.archetype_access
} }
fn resource_access(&self) -> &TypeAccess { fn resource_access(&self) -> &TypeAccess {
&self.resource_access &self.resource_access
} }

View File

@ -1,8 +1,8 @@
pub use hecs::{Query as HecsQuery, *}; pub use hecs::{Query as HecsQuery, *};
mod commands; mod commands;
mod parallel_executor;
mod into_system; mod into_system;
mod parallel_executor;
#[cfg(feature = "profiler")] #[cfg(feature = "profiler")]
pub mod profiler; pub mod profiler;
pub mod resource_query; pub mod resource_query;
@ -13,9 +13,9 @@ mod world_builder;
pub use commands::{Commands, CommandsInternal}; pub use commands::{Commands, CommandsInternal};
pub use into_system::{IntoForEachSystem, IntoQuerySystem, IntoThreadLocalSystem, Query}; pub use into_system::{IntoForEachSystem, IntoQuerySystem, IntoThreadLocalSystem, Query};
pub use parallel_executor::ParallelExecutor;
pub use resource_query::{FetchResource, Local, Res, ResMut, ResourceQuery}; pub use resource_query::{FetchResource, Local, Res, ResMut, ResourceQuery};
pub use resources::{FromResources, Resource, Resources}; pub use resources::{FromResources, Resource, Resources};
pub use schedule::Schedule; pub use schedule::Schedule;
pub use parallel_executor::ParallelExecutor; pub use system::{ArchetypeAccess, System, SystemId, TypeAccess};
pub use system::{System, SystemId, TypeAccess, ArchetypeAccess};
pub use world_builder::{WorldBuilder, WorldBuilderSource}; pub use world_builder::{WorldBuilder, WorldBuilderSource};

View File

@ -29,7 +29,8 @@ impl ParallelExecutor {
if schedule_changed { if schedule_changed {
self.stages.clear(); self.stages.clear();
self.stages.resize_with(schedule.stage_order.len(), || ExecutorStage::default()); self.stages
.resize_with(schedule.stage_order.len(), || ExecutorStage::default());
} }
for (stage_index, stage_name) in schedule.stage_order.iter().enumerate() { for (stage_index, stage_name) in schedule.stage_order.iter().enumerate() {

View File

@ -1,4 +1,8 @@
use crate::{resources::FromResources, system::{TypeAccess, SystemId}, Archetype, Component, Resources}; use crate::{
resources::FromResources,
system::{SystemId, TypeAccess},
Archetype, Component, Resources,
};
use core::{ use core::{
any::TypeId, any::TypeId,
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},

View File

@ -4,7 +4,8 @@ use crate::{
}; };
use std::{ use std::{
borrow::Cow, borrow::Cow,
collections::{HashMap, HashSet}, sync::{Mutex, Arc}, collections::{HashMap, HashSet},
sync::{Arc, Mutex},
}; };
#[derive(Default)] #[derive(Default)]
@ -151,4 +152,4 @@ impl Schedule {
pub fn generation(&self) -> usize { pub fn generation(&self) -> usize {
self.generation self.generation
} }
} }

View File

@ -99,9 +99,9 @@ impl TypeAccess {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{TypeAccess, ArchetypeAccess}; use super::{ArchetypeAccess, TypeAccess};
use crate::{FetchResource, Res, ResMut, ResourceQuery};
use hecs::World; use hecs::World;
use crate::{ResourceQuery, FetchResource, Res, ResMut};
use std::any::TypeId; use std::any::TypeId;
struct A; struct A;
@ -136,7 +136,8 @@ mod tests {
#[test] #[test]
fn resource_query_access() { fn resource_query_access() {
let access = <<(Res<A>, ResMut<B>, Res<C>) as ResourceQuery>::Fetch as FetchResource>::access(); let access =
<<(Res<A>, ResMut<B>, Res<C>) as ResourceQuery>::Fetch as FetchResource>::access();
let mut expected_access = TypeAccess::default(); let mut expected_access = TypeAccess::default();
expected_access.immutable.insert(TypeId::of::<A>()); expected_access.immutable.insert(TypeId::of::<A>());
expected_access.immutable.insert(TypeId::of::<C>()); expected_access.immutable.insert(TypeId::of::<C>());

View File

@ -1,4 +1,4 @@
mod face_toward; mod face_toward;
pub use face_toward::*; pub use face_toward::*;
pub use glam::*; pub use glam::*;

View File

@ -1,8 +1,8 @@
use bevy_core::bytes::Byteable; use bevy_core::bytes::Byteable;
use bevy_math::Mat4;
use bevy_property::Properties; use bevy_property::Properties;
use bevy_render::{CameraProjection, Color, PerspectiveProjection}; use bevy_render::{CameraProjection, Color, PerspectiveProjection};
use bevy_transform::components::Translation; use bevy_transform::components::Translation;
use bevy_math::Mat4;
use std::ops::Range; use std::ops::Range;
#[derive(Properties)] #[derive(Properties)]

View File

@ -1,9 +1,9 @@
use crate::CameraProjection; use crate::CameraProjection;
use bevy_app::{EventReader, Events}; use bevy_app::{EventReader, Events};
use bevy_ecs::{Component, Local, Query, Res}; use bevy_ecs::{Component, Local, Query, Res};
use bevy_math::Mat4;
use bevy_property::Properties; use bevy_property::Properties;
use bevy_window::{WindowCreated, WindowReference, WindowResized, Windows}; use bevy_window::{WindowCreated, WindowReference, WindowResized, Windows};
use bevy_math::Mat4;
#[derive(Default, Debug, Properties)] #[derive(Default, Debug, Properties)]
pub struct Camera { pub struct Camera {

View File

@ -1,5 +1,5 @@
use bevy_property::{Properties, Property};
use bevy_math::Mat4; use bevy_math::Mat4;
use bevy_property::{Properties, Property};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub trait CameraProjection { pub trait CameraProjection {

View File

@ -5,8 +5,8 @@ use crate::{
}; };
use bevy_asset::Handle; use bevy_asset::Handle;
use bevy_core::bytes::{Byteable, Bytes}; use bevy_core::bytes::{Byteable, Bytes};
use bevy_property::Property;
use bevy_math::Vec4; use bevy_math::Vec4;
use bevy_property::Property;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::ops::{Add, AddAssign}; use std::ops::{Add, AddAssign};

View File

@ -1,7 +1,7 @@
use crate::{Rect, TextureAtlas}; use crate::{Rect, TextureAtlas};
use bevy_asset::{Assets, Handle}; use bevy_asset::{Assets, Handle};
use bevy_render::texture::Texture;
use bevy_math::Vec2; use bevy_math::Vec2;
use bevy_render::texture::Texture;
use guillotiere::{size2, AllocId, Allocation, AtlasAllocator}; use guillotiere::{size2, AllocId, Allocation, AtlasAllocator};
use std::collections::HashMap; use std::collections::HashMap;

View File

@ -19,12 +19,12 @@ pub use texture_atlas_builder::*;
use bevy_app::{stage, AppBuilder, AppPlugin}; use bevy_app::{stage, AppBuilder, AppPlugin};
use bevy_asset::{AddAsset, Assets, Handle}; use bevy_asset::{AddAsset, Assets, Handle};
use bevy_ecs::IntoQuerySystem; use bevy_ecs::IntoQuerySystem;
use bevy_math::Vec2;
use bevy_render::{ use bevy_render::{
mesh::{shape, Mesh}, mesh::{shape, Mesh},
render_graph::RenderGraph, render_graph::RenderGraph,
shader::asset_shader_defs_system, shader::asset_shader_defs_system,
}; };
use bevy_math::Vec2;
use sprite::sprite_system; use sprite::sprite_system;
#[derive(Default)] #[derive(Default)]

View File

@ -2,11 +2,11 @@ use crate::ColorMaterial;
use bevy_asset::{Assets, Handle}; use bevy_asset::{Assets, Handle};
use bevy_core::bytes::Byteable; use bevy_core::bytes::Byteable;
use bevy_ecs::{Query, Res}; use bevy_ecs::{Query, Res};
use bevy_math::Vec2;
use bevy_render::{ use bevy_render::{
render_resource::{RenderResource, RenderResources}, render_resource::{RenderResource, RenderResources},
texture::Texture, texture::Texture,
}; };
use bevy_math::Vec2;
#[repr(C)] #[repr(C)]
#[derive(Default, RenderResources, RenderResource)] #[derive(Default, RenderResources, RenderResource)]

View File

@ -1,12 +1,12 @@
use crate::Rect; use crate::Rect;
use bevy_asset::Handle; use bevy_asset::Handle;
use bevy_core::bytes::Bytes; use bevy_core::bytes::Bytes;
use bevy_math::Vec2;
use bevy_render::{ use bevy_render::{
render_resource::{RenderResource, RenderResources}, render_resource::{RenderResource, RenderResources},
texture::Texture, texture::Texture,
Color, Color,
}; };
use bevy_math::Vec2;
use std::collections::HashMap; use std::collections::HashMap;
#[derive(RenderResources)] #[derive(RenderResources)]

View File

@ -1,7 +1,7 @@
use crate::{Rect, TextureAtlas}; use crate::{Rect, TextureAtlas};
use bevy_asset::{Assets, Handle}; use bevy_asset::{Assets, Handle};
use bevy_render::texture::Texture;
use bevy_math::Vec2; use bevy_math::Vec2;
use bevy_render::texture::Texture;
use rectangle_pack::{ use rectangle_pack::{
contains_smallest_box, pack_rects, volume_heuristic, GroupedRectsToPlace, PackedLocation, contains_smallest_box, pack_rects, volume_heuristic, GroupedRectsToPlace, PackedLocation,
RectToInsert, TargetBin, RectToInsert, TargetBin,

View File

@ -1,6 +1,7 @@
use crate::{Font, FontAtlasSet}; use crate::{Font, FontAtlasSet};
use ab_glyph::{Glyph, PxScale, ScaleFont}; use ab_glyph::{Glyph, PxScale, ScaleFont};
use bevy_asset::Assets; use bevy_asset::Assets;
use bevy_math::{Mat4, Vec3};
use bevy_render::{ use bevy_render::{
draw::{Draw, DrawContext, DrawError, Drawable}, draw::{Draw, DrawContext, DrawError, Drawable},
mesh, mesh,
@ -12,7 +13,6 @@ use bevy_render::{
Color, Color,
}; };
use bevy_sprite::{TextureAtlas, TextureAtlasSprite}; use bevy_sprite::{TextureAtlas, TextureAtlasSprite};
use bevy_math::{Mat4, Vec3};
pub struct TextStyle { pub struct TextStyle {
pub font_size: f32, pub font_size: f32,

View File

@ -1,6 +1,6 @@
use ab_glyph::{FontVec, Glyph, InvalidFont, OutlinedGlyph, Point, PxScale, ScaleFont}; use ab_glyph::{FontVec, Glyph, InvalidFont, OutlinedGlyph, Point, PxScale, ScaleFont};
use bevy_render::{texture::Texture, Color};
use bevy_math::Vec2; use bevy_math::Vec2;
use bevy_render::{texture::Texture, Color};
pub struct Font { pub struct Font {
pub font: FontVec, pub font: FontVec,

View File

@ -1,7 +1,7 @@
use bevy_asset::{Assets, Handle}; use bevy_asset::{Assets, Handle};
use bevy_math::Vec2;
use bevy_render::texture::Texture; use bevy_render::texture::Texture;
use bevy_sprite::{DynamicTextureAtlasBuilder, TextureAtlas}; use bevy_sprite::{DynamicTextureAtlasBuilder, TextureAtlas};
use bevy_math::Vec2;
use std::collections::HashMap; use std::collections::HashMap;
pub struct FontAtlas { pub struct FontAtlas {

View File

@ -2,9 +2,9 @@ use crate::{Font, FontAtlas};
use ab_glyph::ScaleFont; use ab_glyph::ScaleFont;
use bevy_asset::{Assets, Handle}; use bevy_asset::{Assets, Handle};
use bevy_core::float_ord::FloatOrd; use bevy_core::float_ord::FloatOrd;
use bevy_math::Vec2;
use bevy_render::texture::Texture; use bevy_render::texture::Texture;
use bevy_sprite::TextureAtlas; use bevy_sprite::TextureAtlas;
use bevy_math::Vec2;
use std::collections::HashMap; use std::collections::HashMap;
// work around rust's f32 order/hash limitations // work around rust's f32 order/hash limitations

View File

@ -6,4 +6,4 @@ mod world_child_builder;
pub use child_builder::*; pub use child_builder::*;
pub use hierarchy::*; pub use hierarchy::*;
pub use hierarchy_maintenance_system::*; pub use hierarchy_maintenance_system::*;
pub use world_child_builder::*; pub use world_child_builder::*;

View File

@ -2,7 +2,7 @@
use crate::components::*; use crate::components::*;
use bevy_ecs::{IntoQuerySystem, Query, System, Without}; use bevy_ecs::{IntoQuerySystem, Query, System, Without};
use bevy_math::{Vec3, Mat4, Quat}; use bevy_math::{Mat4, Quat, Vec3};
// TODO: "on changed" for all of these systems // TODO: "on changed" for all of these systems
pub fn local_transform_translation_system( pub fn local_transform_translation_system(
@ -178,8 +178,8 @@ pub fn local_transform_systems() -> Vec<Box<dyn System>> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use bevy_math::{Mat4, Quat, Vec3};
use bevy_ecs::{Resources, Schedule, World}; use bevy_ecs::{Resources, Schedule, World};
use bevy_math::{Mat4, Quat, Vec3};
#[test] #[test]
fn correct_local_transformation() { fn correct_local_transformation() {

View File

@ -1,7 +1,7 @@
use super::{Anchors, Margins}; use super::{Anchors, Margins};
use bevy_math::{Vec2, Vec3};
use bevy_render::render_resource::RenderResources; use bevy_render::render_resource::RenderResources;
use bevy_transform::prelude::Translation; use bevy_transform::prelude::Translation;
use bevy_math::{Vec2, Vec3};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
enum MarginGrowDirection { enum MarginGrowDirection {

View File

@ -1,11 +1,11 @@
use super::Node; use super::Node;
use bevy_ecs::{Entity, Query, Res, Without}; use bevy_ecs::{Entity, Query, Res, Without};
use bevy_math::Vec2;
use bevy_transform::{ use bevy_transform::{
hierarchy, hierarchy,
prelude::{Children, Parent, Translation}, prelude::{Children, Parent, Translation},
}; };
use bevy_window::Windows; use bevy_window::Windows;
use bevy_math::Vec2;
pub const UI_Z_STEP: f32 = 0.001; pub const UI_Z_STEP: f32 = 0.001;

View File

@ -10,7 +10,7 @@ pub use wgpu_renderer::*;
pub use wgpu_resources::*; pub use wgpu_resources::*;
use bevy_app::{AppBuilder, AppPlugin}; use bevy_app::{AppBuilder, AppPlugin};
use bevy_ecs::{IntoQuerySystem, Resources, IntoThreadLocalSystem, World}; use bevy_ecs::{IntoQuerySystem, IntoThreadLocalSystem, Resources, World};
use bevy_render::{ use bevy_render::{
render_resource::{free_shared_buffers_system, SharedBuffers}, render_resource::{free_shared_buffers_system, SharedBuffers},
renderer::RenderResourceContext, renderer::RenderResourceContext,

View File

@ -9,10 +9,10 @@ use bevy_input::{
use bevy_app::{App, AppBuilder, AppExit, AppPlugin, EventReader, Events}; use bevy_app::{App, AppBuilder, AppExit, AppPlugin, EventReader, Events};
use bevy_ecs::Resources; use bevy_ecs::Resources;
use bevy_math::Vec2;
use bevy_window::{ use bevy_window::{
CreateWindow, CursorMoved, Window, WindowCloseRequested, WindowCreated, WindowResized, Windows, CreateWindow, CursorMoved, Window, WindowCloseRequested, WindowCreated, WindowResized, Windows,
}; };
use bevy_math::Vec2;
use winit::{ use winit::{
event, event,
event::{DeviceEvent, WindowEvent}, event::{DeviceEvent, WindowEvent},

View File

@ -5,9 +5,7 @@ pub use crate::{
}, },
asset::{AddAsset, AssetEvent, AssetServer, Assets, Handle}, asset::{AddAsset, AssetEvent, AssetServer, Assets, Handle},
audio::{AudioOutput, AudioSource}, audio::{AudioOutput, AudioSource},
core::{ core::time::{Time, Timer},
time::{Time, Timer},
},
diagnostic::DiagnosticsPlugin, diagnostic::DiagnosticsPlugin,
ecs::{ ecs::{
Bundle, Commands, Component, Entity, FromResources, IntoForEachSystem, IntoQuerySystem, Bundle, Commands, Component, Entity, FromResources, IntoForEachSystem, IntoQuerySystem,
@ -15,7 +13,7 @@ pub use crate::{
World, WorldBuilderSource, World, WorldBuilderSource,
}, },
input::{keyboard::KeyCode, mouse::MouseButton, Input}, input::{keyboard::KeyCode, mouse::MouseButton, Input},
math::{self, Mat3, Mat4, Quat, Vec2, Vec3, Vec4, FaceToward}, math::{self, FaceToward, Mat3, Mat4, Quat, Vec2, Vec3, Vec4},
pbr::{entity::*, light::Light, material::StandardMaterial}, pbr::{entity::*, light::Light, material::StandardMaterial},
property::{DynamicProperties, Properties, PropertiesVal, Property, PropertyVal}, property::{DynamicProperties, Properties, PropertiesVal, Property, PropertyVal},
render::{ render::{