switch to read-convert style
This commit is contained in:
parent
91f11f20d0
commit
64bf5b73a5
19
src/bsp.rs
19
src/bsp.rs
@ -1,19 +1,10 @@
|
||||
use strafesnet_common::{model,integer,gameplay_attributes};
|
||||
use strafesnet_common::{map,model,integer,gameplay_attributes};
|
||||
|
||||
const VALVE_SCALE:f32=1.0/16.0;
|
||||
fn valve_transform(v:[f32;3])->integer::Planar64Vec3{
|
||||
integer::Planar64Vec3::try_from([v[0]*VALVE_SCALE,v[2]*VALVE_SCALE,-v[1]*VALVE_SCALE]).unwrap()
|
||||
}
|
||||
pub fn generate_indexed_models<R:std::io::Read+std::io::Seek>(input:&mut R)->Result<model::MeshInstances,vbsp::BspError>{
|
||||
let mut s=Vec::new();
|
||||
|
||||
match input.read_to_end(&mut s){
|
||||
Ok(_)=>(),
|
||||
Err(e)=>println!("load_bsp::generate_indexed_models read_to_end failed: {:?}",e),
|
||||
}
|
||||
|
||||
match vbsp::Bsp::read(s.as_slice()){
|
||||
Ok(bsp)=>{
|
||||
pub fn convert<F:FnMut(&str)->Option<model::TextureId>>(bsp:vbsp::Bsp,mut acquire_id:F)->map::CompleteMap{
|
||||
let mut spawn_point=integer::Planar64Vec3::ZERO;
|
||||
|
||||
let vertices: Vec<_> = bsp
|
||||
@ -227,10 +218,4 @@ pub fn generate_indexed_models<R:std::io::Read+std::io::Seek>(input:&mut R)->Res
|
||||
spawn_point,
|
||||
modes:Vec::new(),
|
||||
})
|
||||
},
|
||||
Err(e)=>{
|
||||
println!("rotten {:?}",e);
|
||||
Err(e)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
17
src/lib.rs
17
src/lib.rs
@ -1 +1,16 @@
|
||||
pub mod bsp;
|
||||
mod bsp;
|
||||
|
||||
pub fn read<R:std::io::Read>(mut input:R)->vbsp::BspResult<vbsp::Bsp>{
|
||||
let mut s=Vec::new();
|
||||
|
||||
match input.read_to_end(&mut s){
|
||||
Ok(_)=>(),
|
||||
Err(e)=>println!("load_bsp::convert read_to_end failed: {:?}",e),
|
||||
}
|
||||
|
||||
vbsp::Bsp::read(s.as_slice())
|
||||
}
|
||||
|
||||
pub fn convert<F:FnMut(&str)->Option<strafesnet_common::model::TextureId>>(bsp:&vbsp::Bsp,acquire_id:F)->strafesnet_common::map::CompleteMap{
|
||||
bsp::convert(bsp,acquire_id)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user