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
use crate::math::Vect;
use rapier::parry::shape::Polyline;
pub struct PolylineView<'a> {
pub raw: &'a Polyline,
}
macro_rules! impl_ref_methods(
($View: ident) => {
impl<'a> $View<'a> {
pub fn num_segments(&self) -> usize {
self.raw.num_segments()
}
pub fn segments(&self) -> impl ExactSizeIterator<Item = (Vect, Vect)> + '_ {
self.raw.segments().map(|seg| (seg.a.into(), seg.b.into()))
}
pub fn segment(&self, i: u32) -> (Vect, Vect) {
let seg = self.raw.segment(i);
(seg.a.into(), seg.b.into())
}
pub fn vertices(&self) -> impl ExactSizeIterator<Item = Vect> + '_ {
self.raw.vertices().iter().map(|v| (*v).into())
}
pub fn indices(&self) -> &[[u32; 2]] {
self.raw.indices()
}
}
}
);
impl_ref_methods!(PolylineView);
pub struct PolylineViewMut<'a> {
pub raw: &'a mut Polyline,
}
impl_ref_methods!(PolylineViewMut);
impl<'a> PolylineViewMut<'a> {
pub fn reverse(&mut self) {
self.raw.reverse()
}
}