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
use frustum::Frustum;
#[derive(Copy, Clone, Debug)]
pub struct FrustumQueryObject {
pub x: f32,
pub y: f32,
pub z: f32,
pub r: f32,
}
#[allow(unused)]
pub struct FrustumQuery {
objects: Vec<FrustumQueryObject>,
}
#[allow(unused)]
impl FrustumQuery {
pub fn new(objects: Vec<FrustumQueryObject>) -> FrustumQuery {
FrustumQuery { objects: objects }
}
pub fn execute(&self, frustum: &Frustum, result: &mut Vec<bool>) {
for i in 0 .. self.objects.len() {
let o = &self.objects[i];
result[i] = frustum.sphere_intersecting(&o.x, &o.y, &o.z, &o.r);
}
}
#[cfg(feature = "multithreaded_rayon")]
pub fn execute_parallel_rayon(&self, frustum: &Frustum, result: &mut Vec<bool>) {
use rayon::prelude::*;
self.objects.par_iter().map(|&o| {
frustum.sphere_intersecting(&o.x, &o.y, &o.z, &o.r)
}).collect_into(result);
}
}