1use meshoptimizer_rs::{
2 build_meshlets, compute_meshlet_bounds_with_positions, BoundsPositions, Error, MeshletSettings,
3 Positions, Workspace,
4};
5
6fn main() -> Result<(), Error> {
7 let positions = [[0., 0., 0.], [1., 0., 0.], [0., 1., 0.], [1., 1., 0.]];
8 let indices = [0, 1, 2, 2, 1, 3];
9 let view = Positions::from_packed(&positions);
10 let mut workspace = Workspace::default();
11 let built = build_meshlets(
12 &indices,
13 view,
14 MeshletSettings::default(),
15 0.25,
16 &mut workspace,
17 )?;
18 let positions = BoundsPositions::new(view);
19 for m in &built.meshlets {
20 let v = m.vertex_offset as usize;
21 let t = m.triangle_offset as usize;
22 let bounds = compute_meshlet_bounds_with_positions(
23 &built.vertices[v..v + m.vertex_count as usize],
24 &built.triangles[t..t + m.triangle_count as usize * 3],
25 positions,
26 &mut workspace,
27 )?;
28 println!("center {:?}, radius {}", bounds.center, bounds.radius);
29 }
30 Ok(())
31}