lol idk #1

Open
Quaternions wants to merge 99 commits from StrafesNET/strafe-client:master into master
Showing only changes of commit 3be9730b52 - Show all commits

View File

@ -149,8 +149,8 @@ impl GraphicsState{
} }
pub fn generate_models(&mut self,device:&wgpu::Device,queue:&wgpu::Queue,map:&map::CompleteMap,textures:strafesnet_texture_loader::texture_loader::Textures){ pub fn generate_models(&mut self,device:&wgpu::Device,queue:&wgpu::Queue,map:&map::CompleteMap,textures:strafesnet_texture_loader::texture_loader::Textures){
//generate texture view per texture //generate texture view per texture
let texture_views:Vec<wgpu::TextureView>=textures.into_iter().map(|(texture_id,texture_data)|{ let texture_views:HashMap<strafesnet_common::model::TextureId,wgpu::TextureView>=textures.into_iter().filter_map(|(texture_id,texture_data)|{
let image=ddsfile::Dds::read(std::io::Cursor::new(texture_data)).unwrap(); let image=ddsfile::Dds::read(std::io::Cursor::new(texture_data)).ok()?;
let (mut width,mut height)=(image.get_width(),image.get_height()); let (mut width,mut height)=(image.get_width(),image.get_height());
@ -192,11 +192,11 @@ impl GraphicsState{
wgpu::util::TextureDataOrder::LayerMajor, wgpu::util::TextureDataOrder::LayerMajor,
&image.data, &image.data,
); );
texture.create_view(&wgpu::TextureViewDescriptor{ Some((texture_id,texture.create_view(&wgpu::TextureViewDescriptor{
label:Some(format!("Texture{} View",texture_id.get()).as_str()), label:Some(format!("Texture{} View",texture_id.get()).as_str()),
dimension:Some(wgpu::TextureViewDimension::D2), dimension:Some(wgpu::TextureViewDimension::D2),
..wgpu::TextureViewDescriptor::default() ..wgpu::TextureViewDescriptor::default()
}) })))
}).collect(); }).collect();
let num_textures=texture_views.len(); let num_textures=texture_views.len();
@ -488,10 +488,9 @@ impl GraphicsState{
usage:wgpu::BufferUsages::UNIFORM|wgpu::BufferUsages::COPY_DST, usage:wgpu::BufferUsages::UNIFORM|wgpu::BufferUsages::COPY_DST,
}); });
let render_config=&map.render_configs[model.render_config.get() as usize]; let render_config=&map.render_configs[model.render_config.get() as usize];
let texture_view=match render_config.texture{ let texture_view=render_config.texture.and_then(|texture_id|
Some(texture_id)=>&texture_views[texture_id.get() as usize], texture_views.get(&texture_id)
None=>&self.temp_squid_texture_view, ).unwrap_or(&self.temp_squid_texture_view);
};
let bind_group=device.create_bind_group(&wgpu::BindGroupDescriptor{ let bind_group=device.create_bind_group(&wgpu::BindGroupDescriptor{
layout:&self.bind_group_layouts.model, layout:&self.bind_group_layouts.model,
entries:&[ entries:&[