split in twain
This commit is contained in:
parent
662ccc26bc
commit
1fca3fb3f4
@ -3,32 +3,46 @@ 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 Loader{
|
|
||||||
|
pub struct TextureLoader{
|
||||||
texture_paths:HashMap<PathBuf,TextureId>,
|
texture_paths:HashMap<PathBuf,TextureId>,
|
||||||
mesh_paths:HashMap<PathBuf,MeshId>,
|
|
||||||
}
|
}
|
||||||
impl Loader{
|
impl TextureLoader{
|
||||||
pub fn new()->Self{
|
|
||||||
Self{
|
|
||||||
texture_paths:HashMap::new(),
|
|
||||||
mesh_paths:HashMap::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//cannot fail atm
|
|
||||||
enum AcquireTextureError{}
|
|
||||||
enum AcquireMeshError{}
|
|
||||||
|
|
||||||
impl Loader{
|
|
||||||
pub fn acquire_texture_id(&mut self,name:&str)->TextureId{
|
pub fn acquire_texture_id(&mut self,name:&str)->TextureId{
|
||||||
let texture_id=TextureId::new(self.texture_paths.len() as u32);
|
let texture_id=TextureId::new(self.texture_paths.len() as u32);
|
||||||
*self.texture_paths.entry(name.into()).or_insert(texture_id)
|
*self.texture_paths.entry(name.into()).or_insert(texture_id)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
pub struct MeshLoader{
|
||||||
|
mesh_paths:HashMap<PathBuf,MeshId>,
|
||||||
|
}
|
||||||
|
impl MeshLoader{
|
||||||
pub fn acquire_mesh_id(&mut self,name:&str)->MeshId{
|
pub fn acquire_mesh_id(&mut self,name:&str)->MeshId{
|
||||||
let texture_id=MeshId::new(self.mesh_paths.len() as u32);
|
let texture_id=MeshId::new(self.mesh_paths.len() as u32);
|
||||||
*self.mesh_paths.entry(name.into()).or_insert(texture_id)
|
*self.mesh_paths.entry(name.into()).or_insert(texture_id)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Loader{
|
||||||
|
texture_loader:TextureLoader,
|
||||||
|
mesh_loader:MeshLoader,
|
||||||
|
}
|
||||||
|
impl Loader{
|
||||||
|
pub fn new()->Self{
|
||||||
|
Self{
|
||||||
|
texture_loader:TextureLoader{texture_paths:HashMap::new()},
|
||||||
|
mesh_loader:MeshLoader{mesh_paths:HashMap::new()},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn texture_mut(&self)->&mut TextureLoader{
|
||||||
|
&mut self.texture_loader
|
||||||
|
}
|
||||||
|
pub fn mesh_mut(&self)->&mut MeshLoader{
|
||||||
|
&mut self.mesh_loader
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Loader{
|
||||||
pub fn load_textures(&self)->Result<Textures,std::io::Error>{
|
pub fn load_textures(&self)->Result<Textures,std::io::Error>{
|
||||||
Ok(Textures::new(Vec::new()))
|
Ok(Textures::new(Vec::new()))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user