1use nalgebra::Vector3;
4use std::fmt::Debug;
5
6pub type InnerShapeWrapper = dyn Shape + Send + Sync;
9
10impl Debug for &InnerShapeWrapper {
11 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
12 f.debug_struct("InnerShapeWrapper")
13 .field("shape_type", &self.get_shape_type())
14 .field("radius", &self.get_radius())
15 .field("half_extents", &self.get_half_extents())
16 .field("half_length", &self.get_half_length())
17 .finish()
18 }
19}
20
21impl PartialEq for &InnerShapeWrapper {
22 fn eq(&self, other: &Self) -> bool {
23 self.get_shape_type() == other.get_shape_type()
24 && self.get_radius() == other.get_radius()
25 && self.get_half_extents() == other.get_half_extents()
26 && self.get_half_length() == other.get_half_length()
27 }
28}
29
30pub type ShapeWrapper = Box<InnerShapeWrapper>;
32
33impl PartialEq for ShapeWrapper {
34 fn eq(&self, other: &Self) -> bool {
35 self.get_shape_type() == other.get_shape_type()
36 && self.get_radius() == other.get_radius()
37 && self.get_half_extents() == other.get_half_extents()
38 && self.get_half_length() == other.get_half_length()
39 }
40}
41
42pub trait Shape {
44 fn is_convex(&self) -> bool;
46
47 fn clone_box(&self) -> ShapeWrapper;
49
50 fn get_shape_type(&self) -> ShapeType;
52
53 fn get_radius(&self) -> Option<f32> {
55 None
56 }
57
58 fn get_half_extents(&self) -> Option<Vector3<f32>> {
60 None
61 }
62
63 fn get_half_length(&self) -> Option<f32> {
65 None
66 }
67
68 fn get_mesh_path(&self) -> Option<String> {
70 None
71 }
72}
73
74#[cfg_attr(feature = "python", pyo3::prelude::pyclass)]
75#[derive(Clone, Copy, Debug, PartialEq, Eq)]
76pub enum ShapeType {
77 Capsule,
78 Cone,
79 Cuboid,
80 Cylinder,
81 Sphere,
82 Mesh,
83}