cargo fmt

This commit is contained in:
Carter Anderson 2020-01-11 15:21:31 -08:00
parent 133cbe7846
commit 9c3c92f39a
12 changed files with 15 additions and 51 deletions

View File

@ -41,10 +41,7 @@ fn main() {
fn setup(world: &mut World) {
let cube = Mesh::load(MeshType::Cube);
let cube_handle = {
let mut mesh_storage = world
.resources
.get_mut::<AssetStorage<Mesh>>()
.unwrap();
let mut mesh_storage = world.resources.get_mut::<AssetStorage<Mesh>>().unwrap();
mesh_storage.add(cube)
};

View File

@ -31,14 +31,8 @@ fn setup(world: &mut World) {
let plane = Mesh::load(MeshType::Plane { size: 10.0 });
let (cube_handle, plane_handle) = {
let mut mesh_storage = world
.resources
.get_mut::<AssetStorage<Mesh>>()
.unwrap();
(
mesh_storage.add(cube),
mesh_storage.add(plane),
)
let mut mesh_storage = world.resources.get_mut::<AssetStorage<Mesh>>().unwrap();
(mesh_storage.add(cube), mesh_storage.add(plane))
};
// plane

View File

@ -14,14 +14,8 @@ fn setup(world: &mut World) {
let plane = Mesh::load(MeshType::Plane { size: 10.0 });
let (cube_handle, plane_handle) = {
let mut mesh_storage = world
.resources
.get_mut::<AssetStorage<Mesh>>()
.unwrap();
(
mesh_storage.add(cube),
mesh_storage.add(plane),
)
let mut mesh_storage = world.resources.get_mut::<AssetStorage<Mesh>>().unwrap();
(mesh_storage.add(cube), mesh_storage.add(plane))
};
// plane

View File

@ -12,10 +12,7 @@ fn main() {
fn setup(world: &mut World) {
let cube = Mesh::load(MeshType::Cube);
let cube_handle = {
let mut mesh_storage = world
.resources
.get_mut::<AssetStorage<Mesh>>()
.unwrap();
let mut mesh_storage = world.resources.get_mut::<AssetStorage<Mesh>>().unwrap();
mesh_storage.add(cube)
};

View File

@ -22,15 +22,13 @@ pub trait Asset<D> {
fn load(descriptor: D) -> Self;
}
pub struct AssetStorage<T>
{
pub struct AssetStorage<T> {
assets: HashMap<usize, T>,
names: HashMap<String, usize>,
current_index: usize,
}
impl<T> AssetStorage<T>
{
impl<T> AssetStorage<T> {
pub fn new() -> AssetStorage<T> {
AssetStorage {
assets: HashMap::new(),

View File

@ -9,7 +9,7 @@ pub use app::{App, AppBuilder};
pub use glam as math;
pub use legion;
pub use legion::prelude::*;
pub use legion::schedule::{Schedulable, Builder};
pub use legion::schedule::{Builder, Schedulable};
pub use legion_transform;
pub use legion_transform::prelude::*;
pub use legion_transform::transform_system_bundle;

View File

@ -129,6 +129,6 @@ pub fn create_plane(size: f32) -> (Vec<Vertex>, Vec<u16>) {
vec2(-size_over_2, size_over_2),
vec2(size_over_2, size_over_2),
vec2(-size_over_2, -size_over_2),
vec2(size_over_2, -size_over_2)
vec2(size_over_2, -size_over_2),
)
}

View File

@ -135,10 +135,7 @@ impl Pipeline for ForwardPipeline {
) {
pass.set_bind_group(0, self.bind_group.as_ref().unwrap(), &[]);
let mut mesh_storage = world
.resources
.get_mut::<AssetStorage<Mesh>>()
.unwrap();
let mut mesh_storage = world.resources.get_mut::<AssetStorage<Mesh>>().unwrap();
let mut last_mesh_id = None;
let mesh_query =
<(Read<Material>, Read<Handle<Mesh>>)>::query().filter(!component::<Instanced>());

View File

@ -82,7 +82,6 @@ impl ForwardInstancedPipeline {
);
}
instance_buffer_infos.push(InstanceBufferInfo {
mesh_id: mesh_id,
buffer: temp_buf_data.finish(),

View File

@ -169,10 +169,7 @@ impl Pipeline for ForwardShadowPassNew {
let mesh_query = <(Read<Material>, Read<Handle<Mesh>>)>::query();
pass.set_bind_group(0, self.bind_group.as_ref().unwrap(), &[]);
let mut mesh_storage = world
.resources
.get_mut::<AssetStorage<Mesh>>()
.unwrap();
let mut mesh_storage = world.resources.get_mut::<AssetStorage<Mesh>>().unwrap();
for (material, mesh) in mesh_query.iter(world) {
if let Some(mesh_asset) = mesh_storage.get(mesh.id) {
mesh_asset.setup_buffers(&render_graph.device);

View File

@ -157,10 +157,7 @@ impl Pipeline for ShadowPipeline {
<(Read<Material>, Read<Handle<Mesh>>)>::query().filter(!component::<Instanced>());
pass.set_bind_group(0, self.bind_group.as_ref().unwrap(), &[]);
let mut mesh_storage = world
.resources
.get_mut::<AssetStorage<Mesh>>()
.unwrap();
let mut mesh_storage = world.resources.get_mut::<AssetStorage<Mesh>>().unwrap();
for (material, mesh) in mesh_query.iter(world) {
if let Some(mesh_asset) = mesh_storage.get(mesh.id) {
mesh_asset.setup_buffers(&render_graph.device);

View File

@ -112,10 +112,7 @@ impl Pipeline for UiPipeline {
});
{
let mut mesh_storage = world
.resources
.get_mut::<AssetStorage<Mesh>>()
.unwrap();
let mut mesh_storage = world.resources.get_mut::<AssetStorage<Mesh>>().unwrap();
let quad = Mesh::load(MeshType::Quad {
north_west: math::vec2(-0.5, 0.5),
@ -218,10 +215,7 @@ impl Pipeline for UiPipeline {
let instance_buffer_infos = Some(self.create_rect_buffers(&render_graph.device, world));
pass.set_bind_group(0, self.bind_group.as_ref().unwrap(), &[]);
let mut mesh_storage = world
.resources
.get_mut::<AssetStorage<Mesh>>()
.unwrap();
let mut mesh_storage = world.resources.get_mut::<AssetStorage<Mesh>>().unwrap();
for instance_buffer_info in instance_buffer_infos.as_ref().unwrap().iter() {
if let Some(mesh_asset) = mesh_storage.get(instance_buffer_info.mesh_id) {
mesh_asset.setup_buffers(&render_graph.device);