spatialrust_scene/mesh.rs
1//! Triangle mesh storage for reconstructed surfaces.
2
3/// Indexed triangle mesh with interleaved XYZ positions.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct TriangleMesh {
6 /// Interleaved XYZ vertex positions.
7 pub positions: Vec<f32>,
8 /// Triangle indices (groups of three).
9 pub indices: Vec<u32>,
10}
11
12impl TriangleMesh {
13 /// Returns the vertex count.
14 #[must_use]
15 pub fn vertex_count(&self) -> usize {
16 self.positions.len() / 3
17 }
18
19 /// Returns the triangle count.
20 #[must_use]
21 pub fn triangle_count(&self) -> usize {
22 self.indices.len() / 3
23 }
24
25 /// Returns whether the mesh has no triangles.
26 #[must_use]
27 pub fn is_empty(&self) -> bool {
28 self.indices.is_empty()
29 }
30}