collider_shape/
cylinder.rs1use crate::shape::Shape;
2
3#[derive(PartialEq, Debug, Copy, Clone)]
7pub struct Cylinder {
8 pub radius: f32,
10 pub half_length: f32,
12}
13
14impl Cylinder {
15 pub fn new(radius: f32, half_length: f32) -> Self {
22 Cylinder {
23 radius,
24 half_length,
25 }
26 }
27}
28
29impl Shape for Cylinder {
30 fn is_convex(&self) -> bool {
31 true
32 }
33
34 fn clone_box(&self) -> Box<dyn Shape + Send + Sync> {
35 Box::new(*self)
36 }
37
38 fn get_shape_type(&self) -> crate::shape::ShapeType {
39 crate::shape::ShapeType::Cylinder
40 }
41
42 fn get_radius(&self) -> Option<f32> {
43 Some(self.radius)
44 }
45
46 fn get_half_length(&self) -> Option<f32> {
47 Some(self.half_length)
48 }
49}