minor cleanup

This commit is contained in:
Robin Appelman 2022-03-17 22:08:18 +01:00
commit 3113c03fbd
2 changed files with 7 additions and 9 deletions

View file

@ -46,9 +46,8 @@ impl Model {
model
.meshes
.iter()
.map(move |mesh| (mesh, model.vertex_offset))
})
.map(|(mesh, offset)| (mesh.vertex_offset + offset) as usize);
.map(move |mesh| (mesh.vertex_offset + model.vertex_offset) as usize)
});
let vtx_meshes = self
.vtx
@ -69,10 +68,9 @@ impl Model {
.flat_map(|(strip_group, mesh_vertex_offset)| {
let group_indices = &strip_group.indices;
let vertices = &strip_group.vertices;
strip_group.strips.iter().cloned().map(move |strip| {
strip_group.strips.iter().map(move |strip| {
strip
.indices()
.flat_map(|i| i)
.map(move |index| group_indices[index] as usize)
.map(move |index| {
vertices[index].original_mesh_vertex_id as usize + mesh_vertex_offset

View file

@ -151,16 +151,16 @@ impl Strip {
self.vertices.clone()
}
pub fn indices(&self) -> impl Iterator<Item = [usize; 3]> + 'static {
pub fn indices(&self) -> impl Iterator<Item = usize> + 'static {
if self.flags.contains(StripFlags::IS_TRI_STRIP) {
let offset = self.indices.start;
Either::Left((0..self.indices.len()).map(move |i| {
Either::Left((0..self.indices.len()).flat_map(move |i| {
let cw = i & 1;
let idx = offset + i;
[idx, idx + 1 - cw, idx + 2 - cw]
[idx, idx + 1 - cw, idx + 2 - cw].into_iter()
}))
} else {
Either::Right(self.indices.clone().step_by(3).map(|i| [i, i + 1, i + 2]))
Either::Right(self.indices.clone())
}
}
}