cargo fmt main crate

This commit is contained in:
mars 2022-05-16 18:57:54 -06:00
parent 96f7d10e36
commit e6cdb5ebe8
6 changed files with 27 additions and 19 deletions

View File

@ -226,7 +226,7 @@ impl Flycam {
pub fn get_camera(&self) -> Camera { pub fn get_camera(&self) -> Camera {
Camera { Camera {
eye: self.get_eye(), eye: self.get_eye(),
vp: self.get_vp() vp: self.get_vp(),
} }
} }

View File

@ -1,5 +1,5 @@
use super::*; use super::*;
use crate::scene::{DebugIndex as Index, DebugVertex as Vertex, DebugDrawList}; use crate::scene::{DebugDrawList, DebugIndex as Index, DebugVertex as Vertex};
use crate::storage::GpuVec; use crate::storage::GpuVec;
use crate::viewport::ViewportInfo; use crate::viewport::ViewportInfo;
use crate::RenderLayouts; use crate::RenderLayouts;

View File

@ -49,7 +49,7 @@ pub struct Attributes {
impl Attributes { impl Attributes {
pub fn new(attr_store: impl AsRef<AttrStore>) -> Self { pub fn new(attr_store: impl AsRef<AttrStore>) -> Self {
Self { Self {
vertex: attr_store.as_ref().get_type::<Vertex>(), vertex: attr_store.as_ref().get_type::<Vertex>(),
index: attr_store.as_ref().add(AttrInfo { index: attr_store.as_ref().add(AttrInfo {
layout: AttrLayout { layout: AttrLayout {
@ -57,7 +57,7 @@ impl Attributes {
}, },
usages: wgpu::BufferUsages::INDEX, usages: wgpu::BufferUsages::INDEX,
default_pool_size: 1_000_000, default_pool_size: 1_000_000,
}) }),
} }
} }
} }
@ -275,7 +275,7 @@ impl MeshPass {
&self.mesh_pool &self.mesh_pool
} }
pub fn get_attributes(&self) -> &Attributes{ pub fn get_attributes(&self) -> &Attributes {
&self.attributes &self.attributes
} }
@ -322,11 +322,9 @@ impl RenderPass for MeshPass {
let mut transformed_meshes_lock = self.transformed_meshes.write(); let mut transformed_meshes_lock = self.transformed_meshes.write();
let mesh_bindings = self let mesh_bindings = self
.mesh_pool .mesh_pool
.iter_meshes( .iter_meshes(self.mesh_layout_id, transformed_meshes_lock.iter(), |i| {
self.mesh_layout_id, &i.mesh
transformed_meshes_lock.iter(), })
|i| &i.mesh,
)
.unwrap(); .unwrap();
let mut skinned_cursor = 0; let mut skinned_cursor = 0;
@ -384,8 +382,16 @@ impl RenderPass for MeshPass {
}; };
for (mesh, infos) in instances { for (mesh, infos) in instances {
let vertices = infos.iter().find(|i| i.0 == self.attributes.vertex).unwrap().1; let vertices = infos
let indices = infos.iter().find(|i| i.0 == self.attributes.index).unwrap().1; .iter()
.find(|i| i.0 == self.attributes.vertex)
.unwrap()
.1;
let indices = infos
.iter()
.find(|i| i.0 == self.attributes.index)
.unwrap()
.1;
group.meshes.push(MeshCommand { group.meshes.push(MeshCommand {
vertex_offset: vertices.offset, vertex_offset: vertices.offset,

View File

@ -4,9 +4,9 @@
//! TODO: use wgpu::util::StagingBelt? //! TODO: use wgpu::util::StagingBelt?
//! TODO: pass access to a wgpu::Queue for write_buffer, staging belt recall, or command encoding //! TODO: pass access to a wgpu::Queue for write_buffer, staging belt recall, or command encoding
use parking_lot::Mutex;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::sync::Arc; use std::sync::Arc;
use parking_lot::Mutex;
pub struct StagingPool<T> { pub struct StagingPool<T> {
device: Arc<wgpu::Device>, device: Arc<wgpu::Device>,

View File

@ -1,10 +1,10 @@
use crate::staging::*; use crate::staging::*;
use parking_lot::{RwLock, RwLockReadGuard};
use slab::Slab; use slab::Slab;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::any::TypeId; use std::any::TypeId;
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use parking_lot::{RwLock, RwLockReadGuard};
/// An error that can be returned when allocating a mesh. /// An error that can be returned when allocating a mesh.
#[derive(Debug)] #[derive(Debug)]

View File

@ -92,9 +92,11 @@ impl WinitViewport {
pub fn acquire(&mut self) -> Result<(), wgpu::SurfaceError> { pub fn acquire(&mut self) -> Result<(), wgpu::SurfaceError> {
if self.output_view.is_none() { if self.output_view.is_none() {
let surface_texture = self.surface.get_current_texture()?; let surface_texture = self.surface.get_current_texture()?;
self.output_view = Some(surface_texture self.output_view = Some(
.texture surface_texture
.create_view(&wgpu::TextureViewDescriptor::default())); .texture
.create_view(&wgpu::TextureViewDescriptor::default()),
);
self.surface_texture = Some(surface_texture); self.surface_texture = Some(surface_texture);
} }
@ -156,9 +158,9 @@ impl Viewport for WinitViewport {
fn get_views(&self) -> ViewportViews { fn get_views(&self) -> ViewportViews {
let output = self.output_view.as_ref().unwrap(); let output = self.output_view.as_ref().unwrap();
ViewportViews { ViewportViews {
output, output,
depth: &self.depth_texture_view depth: &self.depth_texture_view,
} }
} }
} }