use std::sync::{LockResult, Mutex, MutexGuard};
use glam::{Isometry3, Vec3};
use once_cell::sync::Lazy;
#[derive(Clone, Debug, Default)]
pub struct ContactDebugContext {
pub count: usize,
pub insight_pairs: [InsightPair; 4],
}
#[derive(Clone, Debug, Default)]
pub struct InsightPair {
pub value: [ManifoldInsight; 2],
}
#[derive(Clone, Debug, PartialEq)]
pub enum ManifoldInsight {
Sphere {
radius: f32,
center: Vec3,
},
Box {
half_extents: Vec3,
center: Vec3,
rotation: glam::Quat,
},
Capsule {
radius: f32,
half_height: f32,
center: Vec3,
rotation: glam::Quat,
},
Plane {
normal: Vec3,
distance: f32,
},
MeshInsight {
highlight_triangles: TriangleListWithHighlight,
},
}
impl Default for ManifoldInsight {
fn default() -> Self {
ManifoldInsight::Sphere {
radius: Default::default(),
center: Vec3::default(),
}
}
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct TriangleListWithHighlight {
pub transform: Isometry3,
pub points_id: u32,
pub face_vertex_indices: Vec<u32>,
pub face_indices_start: Vec<u32>,
}
static CONTACT_DEBUG_DATA: Lazy<Mutex<Vec<ContactDebugContext>>> =
Lazy::new(|| Mutex::new(Vec::new()));
pub fn get_or_init() -> LockResult<MutexGuard<'static, Vec<ContactDebugContext>>> {
CONTACT_DEBUG_DATA.lock()
}