This commit is contained in:
Quaternions 2024-02-13 21:06:31 -08:00
parent 42b4589fb3
commit 3d57af0dfd

@ -26,17 +26,17 @@ where
//the generated MeshIds in here will collide with the Loader Mesh Ids
//but I can't think of a good workaround other than just remapping one later.
let (mut meshes,mut models):(Vec<model::Mesh>,Vec<model::Model>)=bsp.models().enumerate().map(|(i,world_model)|{
let (meshes,models):(Vec<model::Mesh>,Vec<model::Model>)=bsp.models().enumerate().map(|(mesh_id,world_model)|{
let mesh_id=model::MeshId::new(mesh_id as u32);
//non-deduplicated
let mut spam_pos=Vec::new();
let mut spam_tex=Vec::new();
let mut spam_normal=Vec::new();
let mut spam_vertices=Vec::new();
let mut polygon_groups=Vec::new();
let mut graphics_groups=Vec::new();
let mut physics_group=model::IndexedPhysicsGroup::default();
let groups=world_model.faces()
.map(|face|{
let polygon_groups=world_model.faces().enumerate().map(|(polygon_group_id,face)|{
let polygon_group_id=model::PolygonGroupId::new(polygon_group_id as u32);
let face_texture=face.texture();
let face_texture_data=face_texture.texture_data();
let (texture_u,texture_v)=(glam::Vec3A::from_slice(&face_texture.texture_transforms_u[0..3]),glam::Vec3A::from_slice(&face_texture.texture_transforms_v[0..3]));
@ -67,18 +67,16 @@ where
let tex_idx=spam_tex.len() as u32;
spam_tex.push(tex);
let i=spam_vertices.len() as u32;
let vertex_id=model::VertexId::new(spam_vertices.len() as u32);
spam_vertices.push(model::IndexedVertex{
pos:model::PositionId::new(pos_idx as u32),
tex:model::TextureCoordinateId::new(tex_idx as u32),
normal:model::NormalId::new(normal_idx),
color:model::ColorId::new(0),
});
model::VertexId::new(i)
vertex_id
}).collect();
indices.reverse();
let polygon_group_id=model::PolygonGroupId::new(polygon_groups.len() as u32);
polygon_groups.push(model::PolygonGroup::PolygonList(model::PolygonList::new(vec![indices])));
if face.is_visible(){
graphics_groups.push(model::IndexedGraphicsGroup{
render:render_id,
@ -86,6 +84,7 @@ where
})
}
physics_group.groups.push(polygon_group_id);
model::PolygonGroup::PolygonList(model::PolygonList::new(vec![indices]))
}).collect();
(
model::Mesh{
@ -99,7 +98,7 @@ where
physics_groups:vec![physics_group],
},
model::Model{
mesh:model::MeshId::new(i as u32),
mesh:mesh_id,
attributes:TEMP_TOUCH_ME_ATTRIBUTE,
transform:integer::Planar64Affine3::new(
integer::Planar64Mat3::default(),