parry3d/transformation/to_outline/
round_cylinder_to_outline.rs1use crate::math::Real;
2use crate::shape::RoundCylinder;
3use crate::transformation::utils;
4use alloc::{vec, vec::Vec};
5use na::{self, Point3};
6
7impl RoundCylinder {
8 pub fn to_outline(
10 &self,
11 nsubdiv: u32,
12 border_nsubdiv: u32,
13 ) -> (Vec<Point3<Real>>, Vec<[u32; 2]>) {
14 let r = self.inner_shape.radius;
15 let br = self.border_radius;
16 let he = self.inner_shape.half_height;
17
18 let mut out_vtx = vec![];
19 let mut out_idx = vec![];
20
21 let center_ab = Point3::new(-r, -he, 0.0);
23 let center_cd = Point3::new(-r, he, 0.0);
24 let a = Point3::new(-r, -he - br, 0.0);
25 let b = Point3::new(-r - br, -he, 0.0);
26 let c = Point3::new(-r - br, he, 0.0);
27 let d = Point3::new(-r, he + br, 0.0);
28
29 out_vtx.push(a);
30 utils::push_arc(center_ab, a, b, border_nsubdiv, &mut out_vtx);
31 out_vtx.push(b);
32 out_vtx.push(c);
33 utils::push_arc(center_cd, c, d, border_nsubdiv, &mut out_vtx);
34 out_vtx.push(d);
35
36 let circles = [
37 0..1,
38 border_nsubdiv..border_nsubdiv + 2,
39 border_nsubdiv * 2 + 1..border_nsubdiv * 2 + 2,
40 ];
41 utils::apply_revolution(false, false, &circles, nsubdiv, &mut out_vtx, &mut out_idx);
42 (out_vtx, out_idx)
43 }
44}