mirror of
https://codeberg.org/icewind/vmdl.git
synced 2026-06-04 00:54:14 +02:00
minor cleanup
This commit is contained in:
parent
14e006e988
commit
3113c03fbd
2 changed files with 7 additions and 9 deletions
|
|
@ -46,9 +46,8 @@ impl Model {
|
||||||
model
|
model
|
||||||
.meshes
|
.meshes
|
||||||
.iter()
|
.iter()
|
||||||
.map(move |mesh| (mesh, model.vertex_offset))
|
.map(move |mesh| (mesh.vertex_offset + model.vertex_offset) as usize)
|
||||||
})
|
});
|
||||||
.map(|(mesh, offset)| (mesh.vertex_offset + offset) as usize);
|
|
||||||
|
|
||||||
let vtx_meshes = self
|
let vtx_meshes = self
|
||||||
.vtx
|
.vtx
|
||||||
|
|
@ -69,10 +68,9 @@ impl Model {
|
||||||
.flat_map(|(strip_group, mesh_vertex_offset)| {
|
.flat_map(|(strip_group, mesh_vertex_offset)| {
|
||||||
let group_indices = &strip_group.indices;
|
let group_indices = &strip_group.indices;
|
||||||
let vertices = &strip_group.vertices;
|
let vertices = &strip_group.vertices;
|
||||||
strip_group.strips.iter().cloned().map(move |strip| {
|
strip_group.strips.iter().map(move |strip| {
|
||||||
strip
|
strip
|
||||||
.indices()
|
.indices()
|
||||||
.flat_map(|i| i)
|
|
||||||
.map(move |index| group_indices[index] as usize)
|
.map(move |index| group_indices[index] as usize)
|
||||||
.map(move |index| {
|
.map(move |index| {
|
||||||
vertices[index].original_mesh_vertex_id as usize + mesh_vertex_offset
|
vertices[index].original_mesh_vertex_id as usize + mesh_vertex_offset
|
||||||
|
|
|
||||||
|
|
@ -151,16 +151,16 @@ impl Strip {
|
||||||
self.vertices.clone()
|
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) {
|
if self.flags.contains(StripFlags::IS_TRI_STRIP) {
|
||||||
let offset = self.indices.start;
|
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 cw = i & 1;
|
||||||
let idx = offset + i;
|
let idx = offset + i;
|
||||||
[idx, idx + 1 - cw, idx + 2 - cw]
|
[idx, idx + 1 - cw, idx + 2 - cw].into_iter()
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
Either::Right(self.indices.clone().step_by(3).map(|i| [i, i + 1, i + 2]))
|
Either::Right(self.indices.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue