1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//! Adaptive tree construction settings.

use crate::clone;
use arctk_attr::load;

/// Tree construction settings.
#[load]
pub struct TreeSettings {
    /// Target maximum number of triangles per cell.
    tar_tris: usize,
    /// Maximum mesh depth.
    max_depth: u32,
    /// Collision detection padding.
    padding: f64,
}

impl TreeSettings {
    clone!(tar_tris, usize);
    clone!(max_depth, u32);
    clone!(padding, f64);

    /// Construct a new instance.
    #[inline]
    #[must_use]
    pub fn new(tar_tris: usize, max_depth: u32, padding: f64) -> Self {
        debug_assert!(tar_tris > 0);
        debug_assert!(max_depth >= 1);
        debug_assert!(padding >= 0.0);

        Self {
            tar_tris,
            max_depth,
            padding,
        }
    }
}