#[derive(Debug, Clone)]
pub struct SilhouetteConfig {
pub color: [f32; 3],
pub width: f32,
pub depth_threshold: f32,
pub normal_threshold: f32,
pub enabled: bool,
}
impl Default for SilhouetteConfig {
fn default() -> Self {
Self {
color: [0.0, 0.0, 0.0],
width: 1.5,
depth_threshold: 0.001,
normal_threshold: 0.5,
enabled: false,
}
}
}
impl SilhouetteConfig {
pub fn new() -> Self {
Self { enabled: true, ..Default::default() }
}
pub fn with_color(mut self, r: f32, g: f32, b: f32) -> Self {
self.color = [r, g, b];
self
}
pub fn with_width(mut self, width: f32) -> Self {
self.width = width;
self
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default_config() {
let c = SilhouetteConfig::default();
assert!(!c.enabled);
assert_eq!(c.color, [0.0, 0.0, 0.0]);
}
#[test]
fn builder() {
let c = SilhouetteConfig::new().with_color(1.0, 0.0, 0.0).with_width(2.0);
assert!(c.enabled);
assert_eq!(c.color, [1.0, 0.0, 0.0]);
assert_eq!(c.width, 2.0);
}
}