diff --git a/src/bsp.rs b/src/bsp.rs index deb51ef..5df6131 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -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=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{