parry3d/transformation/vhacd/parameters.rs
1use crate::math::Real;
2use crate::transformation::voxelization::FillMode;
3
4/// Parameters controlling the VHACD convex decomposition.
5///
6/// See <https://github.com/Unity-Technologies/VHACD#parameters> for details.
7#[derive(Debug, Clone, Copy, PartialEq)]
8pub struct VHACDParameters {
9 /// Maximum concavity.
10 ///
11 /// Default: 0.1 (in 2D), 0.01 (in 3D).
12 /// Valid range `[0.0, 1.0]`.
13 pub concavity: Real,
14 /// Controls the bias toward clipping along symmetry planes.
15 ///
16 /// Default: 0.05.
17 /// Valid Range: `[0.0, 1.0]`.
18 pub alpha: Real,
19 /// Controls the bias toward clipping along revolution planes.
20 ///
21 /// Default: 0.05.
22 /// Valid Range: `[0.0, 1.0]`.
23 pub beta: Real,
24 /// Resolution used during the voxelization stage.
25 ///
26 /// Default: 256 (in 2D), 64 (in 3D).
27 pub resolution: u32,
28 /// Controls the granularity of the search for the best
29 /// clipping plane during the decomposition.
30 ///
31 /// Default: 4
32 pub plane_downsampling: u32,
33 /// Controls the precision of the convex-hull generation
34 /// process during the clipping plane selection stage.
35 ///
36 /// Default: 4
37 pub convex_hull_downsampling: u32,
38 /// Controls the way the input mesh or polyline is being
39 /// voxelized.
40 ///
41 /// Default: `FillMode::FloodFill { detect_cavities: false, detect_self_intersections: false }`
42 pub fill_mode: FillMode,
43 /// Controls whether the convex-hull should be approximated during the decomposition stage.
44 /// Setting this to `true` increases performances with a slight degradation of the decomposition
45 /// quality.
46 ///
47 /// Default: true
48 pub convex_hull_approximation: bool,
49 /// Controls the max number of convex-hull generated by the convex decomposition.
50 ///
51 /// Default: 1024
52 pub max_convex_hulls: u32,
53}
54
55impl Default for VHACDParameters {
56 fn default() -> Self {
57 Self {
58 #[cfg(feature = "dim3")]
59 resolution: 64,
60 #[cfg(feature = "dim3")]
61 concavity: 0.01,
62 #[cfg(feature = "dim2")]
63 resolution: 256,
64 #[cfg(feature = "dim2")]
65 concavity: 0.1,
66 plane_downsampling: 4,
67 convex_hull_downsampling: 4,
68 alpha: 0.05,
69 beta: 0.05,
70 convex_hull_approximation: true,
71 max_convex_hulls: 1024,
72 fill_mode: FillMode::FloodFill {
73 detect_cavities: false,
74 #[cfg(feature = "dim2")]
75 detect_self_intersections: false,
76 },
77 }
78 }
79}