debug brushes

This commit is contained in:
Quaternions 2025-02-26 10:55:11 -08:00
parent 71426c257f
commit 8b6f3620f8
7 changed files with 49 additions and 3 deletions
Cargo.lock
engine
physics/src
session/src
lib
bsp_loader/src
common
snf/src/newtypes

3
Cargo.lock generated

@ -1838,7 +1838,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"windows-targets 0.52.6", "windows-targets 0.48.5",
] ]
[[package]] [[package]]
@ -3732,6 +3732,7 @@ dependencies = [
"id", "id",
"linear_ops", "linear_ops",
"ratio_ops", "ratio_ops",
"vbsp",
] ]
[[package]] [[package]]

@ -933,6 +933,7 @@ pub struct PhysicsData{
modes:gameplay_modes::Modes, modes:gameplay_modes::Modes,
//cached calculations //cached calculations
hitbox_mesh:HitboxMesh, hitbox_mesh:HitboxMesh,
pub le_models:Vec<strafesnet_common::model::Model>,
} }
impl Default for PhysicsData{ impl Default for PhysicsData{
fn default()->Self{ fn default()->Self{
@ -941,6 +942,7 @@ impl Default for PhysicsData{
models:Default::default(), models:Default::default(),
modes:Default::default(), modes:Default::default(),
hitbox_mesh:StyleModifiers::default().calculate_mesh(), hitbox_mesh:StyleModifiers::default().calculate_mesh(),
le_models:Default::default(),
} }
} }
} }
@ -1142,6 +1144,7 @@ impl PhysicsData{
self.bvh=bvh; self.bvh=bvh;
self.models=models; self.models=models;
self.modes=modes; self.modes=modes;
self.le_models=map.models.clone();
//hitbox_mesh is unchanged //hitbox_mesh is unchanged
println!("Physics Objects: {}",model_count); println!("Physics Objects: {}",model_count);
} }

@ -209,6 +209,20 @@ impl Session{
if model_id!=self.last_ray_hit{ if model_id!=self.last_ray_hit{
println!("hit={model_id:?}"); println!("hit={model_id:?}");
self.last_ray_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}");
}
}
}
} }
} }
} }

@ -59,7 +59,7 @@ fn add_brush<'a>(
Ok(mesh_id)=>{ Ok(mesh_id)=>{
let mesh=model::MeshId::new(mesh_id); let mesh=model::MeshId::new(mesh_id);
world_models.push( world_models.push(
model::Model{mesh,attributes,transform,color} model::Model{mesh,attributes,transform,color,brush_info:model::BrushInfo::BUH}
); );
}, },
Err(e)=>{ Err(e)=>{
@ -70,7 +70,7 @@ fn add_brush<'a>(
_=>{ _=>{
let mesh=mesh_deferred_loader.acquire_mesh_id(model); let mesh=mesh_deferred_loader.acquire_mesh_id(model);
prop_models.push( 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()), valve_transform(prop.origin.into()),
), ),
color:glam::Vec4::ONE, color:glam::Vec4::ONE,
brush_info:model::BrushInfo::BUH,
} }
}).collect(); }).collect();
@ -207,6 +208,7 @@ pub fn convert<'a>(
attributes:ATTRIBUTE_DECORATION, attributes:ATTRIBUTE_DECORATION,
transform:integer::Planar64Affine3::IDENTITY, transform:integer::Planar64Affine3::IDENTITY,
color:glam::Vec4::W, color:glam::Vec4::W,
brush_info:model::BrushInfo::BUH,
}); });
// THE CUBE OF DESTINY // THE CUBE OF DESTINY
@ -442,6 +444,13 @@ pub fn convert<'a>(
Ok(mesh)=>{ Ok(mesh)=>{
let mesh_id=model::MeshId::new(world_meshes.len() as u32); let mesh_id=model::MeshId::new(world_meshes.len() as u32);
world_meshes.push(mesh); 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{ world_models.push(model::Model{
mesh:mesh_id, mesh:mesh_id,
attributes, attributes,
@ -450,6 +459,7 @@ pub fn convert<'a>(
integer::vec3::ZERO, integer::vec3::ZERO,
), ),
color:glam::Vec4::ONE, color:glam::Vec4::ONE,
brush_info:model::BrushInfo{flags:brush.flags,sides}
}); });
}, },
Err(e)=>println!("Brush mesh error: {e}"), Err(e)=>println!("Brush mesh error: {e}"),
@ -465,6 +475,7 @@ pub fn convert<'a>(
attributes:ATTRIBUTE_INTERSECT_DEFAULT, attributes:ATTRIBUTE_INTERSECT_DEFAULT,
transform:integer::Planar64Affine3::from_translation(valve_transform(spawn_point.into())), transform:integer::Planar64Affine3::from_translation(valve_transform(spawn_point.into())),
color:glam::Vec4::W, color:glam::Vec4::W,
brush_info:model::BrushInfo::BUH,
}); });
let first_stage=Stage::empty(model_id); let first_stage=Stage::empty(model_id);

@ -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" } ratio_ops = { version = "0.1.0", path = "../ratio_ops", registry = "strafesnet" }
glam = "0.30.0" glam = "0.30.0"
id = { version = "0.1.0", registry = "strafesnet" } id = { version = "0.1.0", registry = "strafesnet" }
vbsp = "0.8.0"

@ -208,9 +208,24 @@ impl MeshBuilder{
#[derive(Debug,Clone,Copy,Hash,id::Id,Eq,PartialEq)] #[derive(Debug,Clone,Copy,Hash,id::Id,Eq,PartialEq)]
pub struct ModelId(u32); pub struct ModelId(u32);
#[derive(Clone)]
pub struct Model{ pub struct Model{
pub mesh:MeshId, pub mesh:MeshId,
pub attributes:gameplay_attributes::CollisionAttributesId, pub attributes:gameplay_attributes::CollisionAttributesId,
pub color:Color4,//transparency is in here pub color:Color4,//transparency is in here
pub transform:Planar64Affine3, 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![],
};
} }

@ -250,6 +250,7 @@ impl Into<strafesnet_common::model::Model> for Model{
]), ]),
strafesnet_common::integer::vec3::raw_xyz(_9,_a,_b) strafesnet_common::integer::vec3::raw_xyz(_9,_a,_b)
), ),
brush_info:strafesnet_common::model::BrushInfo::BUH,
} }
} }
} }