use boxed str
This commit is contained in:
parent
f58cf4ec2a
commit
f3174cd191
@ -1,11 +1,10 @@
|
|||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crate::texture::{Texture,Textures};
|
use crate::texture::{Texture,Textures};
|
||||||
use strafesnet_common::model::{MeshId,TextureId};
|
use strafesnet_common::model::{MeshId,TextureId};
|
||||||
|
|
||||||
pub struct TextureLoader{
|
pub struct TextureLoader{
|
||||||
texture_paths:HashMap<PathBuf,TextureId>,
|
texture_paths:HashMap<Box<str>,TextureId>,
|
||||||
}
|
}
|
||||||
impl TextureLoader{
|
impl TextureLoader{
|
||||||
pub fn acquire_texture_id(&mut self,name:&str)->TextureId{
|
pub fn acquire_texture_id(&mut self,name:&str)->TextureId{
|
||||||
@ -14,7 +13,7 @@ impl TextureLoader{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub struct MeshLoader{
|
pub struct MeshLoader{
|
||||||
mesh_paths:HashMap<PathBuf,MeshId>,
|
mesh_paths:HashMap<Box<str>,MeshId>,
|
||||||
}
|
}
|
||||||
impl MeshLoader{
|
impl MeshLoader{
|
||||||
pub fn acquire_mesh_id(&mut self,name:&str)->MeshId{
|
pub fn acquire_mesh_id(&mut self,name:&str)->MeshId{
|
||||||
@ -43,7 +42,7 @@ impl Loader{
|
|||||||
pub fn load_textures(&self)->Result<Textures,std::io::Error>{
|
pub fn load_textures(&self)->Result<Textures,std::io::Error>{
|
||||||
let mut texture_data=vec![Vec::<u8>::new();self.texture_loader.texture_paths.len()];
|
let mut texture_data=vec![Vec::<u8>::new();self.texture_loader.texture_paths.len()];
|
||||||
for (texture_path,texture_id) in &self.texture_loader.texture_paths{
|
for (texture_path,texture_id) in &self.texture_loader.texture_paths{
|
||||||
let path=std::path::PathBuf::from(format!("textures/{}.dds",texture_path.display()));
|
let path=std::path::PathBuf::from(format!("textures/{}.dds",texture_path));
|
||||||
if let Ok(mut file)=std::fs::File::open(path){
|
if let Ok(mut file)=std::fs::File::open(path){
|
||||||
//TODO: parallel
|
//TODO: parallel
|
||||||
file.read_to_end(texture_data.get_mut(texture_id.get() as usize).unwrap())?;
|
file.read_to_end(texture_data.get_mut(texture_id.get() as usize).unwrap())?;
|
||||||
|
Loading…
Reference in New Issue
Block a user