diff --git a/src/bsp.rs b/src/bsp.rs index 7ed807c..5450768 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -4,16 +4,7 @@ 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)->model::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) - }, - } } diff --git a/src/lib.rs b/src/lib.rs index e06ee2d..ab2a34b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1 +1,16 @@ -pub mod bsp; \ No newline at end of file +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) +} \ No newline at end of file