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
use super::super::super::super::box2d::collision::shapes::polygon_shape::*;
use super::super::super::super::box2d::common::math::*;
use super::super::super::super::box2d::common::settings::*;
pub struct VertexIterator<'a> {
poly: &'a mut PolygonShape,
vertex_count: Int32,
index: Int32
}
impl PolygonShape {
pub fn get_vertex_iterator(&mut self) -> VertexIterator {
let vc = self.get_vertex_count();
VertexIterator { poly: self, vertex_count: vc, index: 0 }
}
}
impl<'a> Iterator for VertexIterator<'a> {
type Item = Vec2;
fn next(&mut self) -> Option<Vec2> {
if self.index < self.vertex_count {
self.index += 1;
Some(self.poly.get_vertex(self.index - 1).clone())
} else {
None
}
}
}