aboutsummaryrefslogtreecommitdiff
path: root/src/pipeline/debug_render_pipeline/outlines.rs
blob: cd0b6ed66ada86f39c14b50e59e1bfabb6075afe (plain)
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
37
use crate::geometry::{Ball, Cuboid};
#[cfg(feature = "dim3")]
use crate::geometry::{Cone, Cylinder};
use crate::math::{Point, Real, Vector};
use std::any::TypeId;
use std::collections::HashMap;

#[cfg(feature = "dim2")]
pub fn instances(nsubdivs: u32) -> HashMap<TypeId, Vec<Point<Real>>> {
    let mut result = HashMap::new();
    result.insert(
        TypeId::of::<Cuboid>(),
        Cuboid::new(Vector::repeat(0.5)).to_polyline(),
    );
    result.insert(TypeId::of::<Ball>(), Ball::new(0.5).to_polyline(nsubdivs));
    result
}

#[cfg(feature = "dim3")]
#[allow(clippy::type_complexity)]
pub fn instances(nsubdivs: u32) -> HashMap<TypeId, (Vec<Point<Real>>, Vec<[u32; 2]>)> {
    let mut result = HashMap::new();
    result.insert(
        TypeId::of::<Cuboid>(),
        Cuboid::new(Vector::repeat(0.5)).to_outline(),
    );
    result.insert(TypeId::of::<Ball>(), Ball::new(0.5).to_outline(nsubdivs));
    result.insert(
        TypeId::of::<Cone>(),
        Cone::new(0.5, 0.5).to_outline(nsubdivs),
    );
    result.insert(
        TypeId::of::<Cylinder>(),
        Cylinder::new(0.5, 0.5).to_outline(nsubdivs),
    );
    result
}