diff --git a/Cargo.lock b/Cargo.lock index 44c9085..3f8d249 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1838,7 +1838,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -3732,6 +3732,7 @@ dependencies = [ "id", "linear_ops", "ratio_ops", + "vbsp", ] [[package]] diff --git a/engine/physics/src/physics.rs b/engine/physics/src/physics.rs index 26782e8..e71a79b 100644 --- a/engine/physics/src/physics.rs +++ b/engine/physics/src/physics.rs @@ -933,6 +933,7 @@ pub struct PhysicsData{ modes:gameplay_modes::Modes, //cached calculations hitbox_mesh:HitboxMesh, + pub le_models:Vec<strafesnet_common::model::Model>, } impl Default for PhysicsData{ fn default()->Self{ @@ -941,6 +942,7 @@ impl Default for PhysicsData{ models:Default::default(), modes:Default::default(), hitbox_mesh:StyleModifiers::default().calculate_mesh(), + le_models:Default::default(), } } } @@ -1142,6 +1144,7 @@ impl PhysicsData{ self.bvh=bvh; self.models=models; self.modes=modes; + self.le_models=map.models.clone(); //hitbox_mesh is unchanged println!("Physics Objects: {}",model_count); } diff --git a/engine/session/src/session.rs b/engine/session/src/session.rs index 5b453c8..78b5c7c 100644 --- a/engine/session/src/session.rs +++ b/engine/session/src/session.rs @@ -209,6 +209,20 @@ impl Session{ if model_id!=self.last_ray_hit{ println!("hit={model_id:?}"); self.last_ray_hit=model_id; + if let Some(model_id)=model_id{ + if let Some(model)=self.geometry_shared.le_models.get(model_id.get() as usize){ + let noice=model.brush_info.flags.iter_names().filter_map(|(name,flags)|{ + (flags.bits()!=0).then(||name) + }).collect::<Vec<&str>>().join("|"); + println!("brush_info.flags={noice}"); + for (i,side) in model.brush_info.sides.iter().enumerate(){ + let noice_string=side.iter_names().filter_map(|(name,flags)|{ + (flags.bits()!=0).then(||name) + }).collect::<Vec<&str>>().join("|"); + println!("brush_info.sides[{i}]={noice_string}"); + } + } + } } } } diff --git a/lib/bsp_loader/src/bsp.rs b/lib/bsp_loader/src/bsp.rs index 38fb404..b22dfc7 100644 --- a/lib/bsp_loader/src/bsp.rs +++ b/lib/bsp_loader/src/bsp.rs @@ -59,7 +59,7 @@ fn add_brush<'a>( Ok(mesh_id)=>{ let mesh=model::MeshId::new(mesh_id); world_models.push( - model::Model{mesh,attributes,transform,color} + model::Model{mesh,attributes,transform,color,brush_info:model::BrushInfo::BUH} ); }, Err(e)=>{ @@ -70,7 +70,7 @@ fn add_brush<'a>( _=>{ let mesh=mesh_deferred_loader.acquire_mesh_id(model); prop_models.push( - model::Model{mesh,attributes,transform,color} + model::Model{mesh,attributes,transform,color,brush_info:model::BrushInfo::BUH} ); } } @@ -139,6 +139,7 @@ pub fn convert<'a>( valve_transform(prop.origin.into()), ), color:glam::Vec4::ONE, + brush_info:model::BrushInfo::BUH, } }).collect(); @@ -207,6 +208,7 @@ pub fn convert<'a>( attributes:ATTRIBUTE_DECORATION, transform:integer::Planar64Affine3::IDENTITY, color:glam::Vec4::W, + brush_info:model::BrushInfo::BUH, }); // THE CUBE OF DESTINY @@ -442,6 +444,13 @@ pub fn convert<'a>( Ok(mesh)=>{ let mesh_id=model::MeshId::new(world_meshes.len() as u32); world_meshes.push(mesh); + let sides={ + let brush_start_idx=brush.brush_side as usize; + let sides_range=brush_start_idx..brush_start_idx+brush.num_brush_sides as usize; + bsp.brush_sides[sides_range].iter().filter_map(|side|bsp.texture_info(side.texture_info as usize)).map(|texture_info|{ + texture_info.flags + }).collect() + }; world_models.push(model::Model{ mesh:mesh_id, attributes, @@ -450,6 +459,7 @@ pub fn convert<'a>( integer::vec3::ZERO, ), color:glam::Vec4::ONE, + brush_info:model::BrushInfo{flags:brush.flags,sides} }); }, Err(e)=>println!("Brush mesh error: {e}"), @@ -465,6 +475,7 @@ pub fn convert<'a>( attributes:ATTRIBUTE_INTERSECT_DEFAULT, transform:integer::Planar64Affine3::from_translation(valve_transform(spawn_point.into())), color:glam::Vec4::W, + brush_info:model::BrushInfo::BUH, }); let first_stage=Stage::empty(model_id); diff --git a/lib/common/Cargo.toml b/lib/common/Cargo.toml index c4ed365..0f16aab 100644 --- a/lib/common/Cargo.toml +++ b/lib/common/Cargo.toml @@ -17,3 +17,4 @@ linear_ops = { version = "0.1.0", path = "../linear_ops", registry = "strafesnet ratio_ops = { version = "0.1.0", path = "../ratio_ops", registry = "strafesnet" } glam = "0.30.0" id = { version = "0.1.0", registry = "strafesnet" } +vbsp = "0.8.0" diff --git a/lib/common/src/model.rs b/lib/common/src/model.rs index 41d981e..51b924c 100644 --- a/lib/common/src/model.rs +++ b/lib/common/src/model.rs @@ -208,9 +208,24 @@ impl MeshBuilder{ #[derive(Debug,Clone,Copy,Hash,id::Id,Eq,PartialEq)] pub struct ModelId(u32); +#[derive(Clone)] pub struct Model{ pub mesh:MeshId, pub attributes:gameplay_attributes::CollisionAttributesId, pub color:Color4,//transparency is in here pub transform:Planar64Affine3, + pub brush_info:BrushInfo, +} + + +#[derive(Debug,Clone)] +pub struct BrushInfo{ + pub flags:vbsp::BrushFlags, + pub sides:Vec<vbsp::TextureFlags>, +} +impl BrushInfo{ + pub const BUH:Self=BrushInfo{ + flags:vbsp::BrushFlags::empty(), + sides:vec![], + }; } diff --git a/lib/snf/src/newtypes/model.rs b/lib/snf/src/newtypes/model.rs index 6d3ce51..26e5585 100644 --- a/lib/snf/src/newtypes/model.rs +++ b/lib/snf/src/newtypes/model.rs @@ -250,6 +250,7 @@ impl Into<strafesnet_common::model::Model> for Model{ ]), strafesnet_common::integer::vec3::raw_xyz(_9,_a,_b) ), + brush_info:strafesnet_common::model::BrushInfo::BUH, } } }