switch to read-convert style
This commit is contained in:
parent
91f11f20d0
commit
05f466727c
27
src/bsp.rs
27
src/bsp.rs
@ -1,19 +1,18 @@
|
|||||||
use strafesnet_common::{model,integer,gameplay_attributes};
|
use strafesnet_common::{map,model,integer,gameplay_attributes};
|
||||||
|
|
||||||
const VALVE_SCALE:f32=1.0/16.0;
|
const VALVE_SCALE:f32=1.0/16.0;
|
||||||
fn valve_transform(v:[f32;3])->integer::Planar64Vec3{
|
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()
|
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>{
|
pub fn convert<AcquireTextureId,AcquireMeshId>(
|
||||||
let mut s=Vec::new();
|
bsp:&vbsp::Bsp,
|
||||||
|
mut acquire_texture_id:AcquireTextureId,
|
||||||
match input.read_to_end(&mut s){
|
mut acquire_mesh_id:AcquireMeshId
|
||||||
Ok(_)=>(),
|
)->strafesnet_common::map::CompleteMap
|
||||||
Err(e)=>println!("load_bsp::generate_indexed_models read_to_end failed: {:?}",e),
|
where
|
||||||
}
|
AcquireTextureId:FnMut(&str)->model::TextureId,
|
||||||
|
AcquireMeshId:FnMut(&str)->model::MeshId,
|
||||||
match vbsp::Bsp::read(s.as_slice()){
|
{
|
||||||
Ok(bsp)=>{
|
|
||||||
let mut spawn_point=integer::Planar64Vec3::ZERO;
|
let mut spawn_point=integer::Planar64Vec3::ZERO;
|
||||||
|
|
||||||
let vertices: Vec<_> = bsp
|
let vertices: Vec<_> = bsp
|
||||||
@ -227,10 +226,4 @@ pub fn generate_indexed_models<R:std::io::Read+std::io::Seek>(input:&mut R)->Res
|
|||||||
spawn_point,
|
spawn_point,
|
||||||
modes:Vec::new(),
|
modes:Vec::new(),
|
||||||
})
|
})
|
||||||
},
|
|
||||||
Err(e)=>{
|
|
||||||
println!("rotten {:?}",e);
|
|
||||||
Err(e)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
25
src/lib.rs
25
src/lib.rs
@ -1 +1,24 @@
|
|||||||
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<AcquireTextureId,AcquireMeshId>(
|
||||||
|
bsp:&vbsp::Bsp,
|
||||||
|
acquire_texture_id:AcquireTextureId,
|
||||||
|
acquire_mesh_id:AcquireMeshId
|
||||||
|
)->strafesnet_common::map::CompleteMap
|
||||||
|
where
|
||||||
|
AcquireTextureId:FnMut(&str)->strafesnet_common::model::TextureId,
|
||||||
|
AcquireMeshId:FnMut(&str)->strafesnet_common::model::MeshId,
|
||||||
|
{
|
||||||
|
bsp::convert(bsp,acquire_texture_id,acquire_mesh_id)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user