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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use super::SegmentView;
use crate::math::{Real, Rot, Vect};
use rapier::parry::shape::Capsule;
pub struct CapsuleView<'a> {
pub raw: &'a Capsule,
}
macro_rules! impl_ref_methods(
($View: ident) => {
impl<'a> $View<'a> {
pub fn segment(&self) -> SegmentView {
SegmentView {
raw: &self.raw.segment,
}
}
pub fn radius(&self) -> Real {
self.raw.radius
}
pub fn height(&self) -> Real {
self.raw.height()
}
pub fn half_height(&self) -> Real {
self.raw.half_height()
}
pub fn center(&self) -> Vect {
self.raw.center().into()
}
pub fn canonical_transform(&self) -> (Vect, Rot) {
self.raw.canonical_transform().into()
}
#[cfg(feature = "dim2")]
pub fn rotation_wrt_y(&self) -> Rot {
self.raw.rotation_wrt_y().angle()
}
#[cfg(feature = "dim3")]
pub fn rotation_wrt_y(&self) -> Rot {
self.raw.rotation_wrt_y().into()
}
pub fn transform_wrt_y(&self) -> (Vect, Rot) {
self.raw.transform_wrt_y().into()
}
}
}
);
impl_ref_methods!(CapsuleView);
pub struct CapsuleViewMut<'a> {
pub raw: &'a mut Capsule,
}
impl_ref_methods!(CapsuleViewMut);
impl<'a> CapsuleViewMut<'a> {
pub fn set_segment(&mut self, a: Vect, b: Vect) {
self.raw.segment.a = a.into();
self.raw.segment.b = b.into();
}
pub fn set_radius(&mut self, radius: Real) {
self.raw.radius = radius;
}
}