indices is already a polygon list

This commit is contained in:
Quaternions 2024-02-17 19:33:00 -08:00
parent f91de2d669
commit 3cab9afa32

View File

@ -77,7 +77,7 @@ where
let normal=face.normal();
let normal_idx=spam_normal.len() as u32;
spam_normal.push(valve_transform(<[f32;3]>::from(normal)));
let indices:Vec<model::VertexId>=face.vertex_positions().map(|vertex_position|{
let mut polygon_iter=face.vertex_positions().map(|vertex_position|{
let vertex_xyz=<[f32;3]>::from(vertex_position);
let pos=glam::Vec3A::from_array(vertex_xyz);
let pos_idx=spam_pos.len();
@ -96,6 +96,13 @@ where
color:model::ColorId::new(0),
});
vertex_id
});
let polygon_list=std::iter::from_fn(move||{
match (polygon_iter.next(),polygon_iter.next(),polygon_iter.next()){
(Some(v1),Some(v2),Some(v3))=>Some(vec![v1,v2,v3]),
//ignore extra vertices, not sure what to do in this case, failing the whole conversion could be appropriate
_=>None,
}
}).collect();
if face.is_visible(){
//TODO: deduplicate graphics groups by render id
@ -105,7 +112,7 @@ where
})
}
physics_group.groups.push(polygon_group_id);
model::PolygonGroup::PolygonList(model::PolygonList::new(vec![indices]))
model::PolygonGroup::PolygonList(model::PolygonList::new(polygon_list))
}).collect();
(
model::Mesh{