cargo fmt
This commit is contained in:
parent
133cbe7846
commit
9c3c92f39a
@ -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)
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
};
|
||||
|
||||
|
@ -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(),
|
||||
|
@ -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;
|
||||
|
@ -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),
|
||||
)
|
||||
}
|
||||
|
@ -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>());
|
||||
|
@ -82,7 +82,6 @@ impl ForwardInstancedPipeline {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
instance_buffer_infos.push(InstanceBufferInfo {
|
||||
mesh_id: mesh_id,
|
||||
buffer: temp_buf_data.finish(),
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user