vox_geometry_rust/
intersection_query_engine2.rs1use crate::vector2::Vector2D;
10use crate::ray2::Ray2D;
11use crate::bounding_box2::BoundingBox2D;
12
13pub struct ClosestIntersectionQueryResult2<T> {
15 pub item: Option<T>,
16 pub distance: f64,
17}
18
19impl<T> ClosestIntersectionQueryResult2<T> {
20 pub fn new() -> ClosestIntersectionQueryResult2<T> {
21 return ClosestIntersectionQueryResult2 {
22 item: None,
23 distance: f64::MAX,
24 };
25 }
26}
27
28pub trait ClosestIntersectionDistanceFunc2<T>: FnMut(&T, &Vector2D) -> f64 {}
30
31impl<T, Super: FnMut(&T, &Vector2D) -> f64> ClosestIntersectionDistanceFunc2<T> for Super {}
32
33pub trait BoxIntersectionTestFunc2<T>: FnMut(&T, &BoundingBox2D) -> bool {}
35
36impl<T, Super: FnMut(&T, &BoundingBox2D) -> bool> BoxIntersectionTestFunc2<T> for Super {}
37
38pub trait RayIntersectionTestFunc2<T>: FnMut(&T, &Ray2D) -> bool {}
40
41impl<T, Super: FnMut(&T, &Ray2D) -> bool> RayIntersectionTestFunc2<T> for Super {}
42
43pub trait GetRayIntersectionFunc2<T>: FnMut(&T, &Ray2D) -> f64 {}
45
46impl<T, Super: FnMut(&T, &Ray2D) -> f64> GetRayIntersectionFunc2<T> for Super {}
47
48pub trait IntersectionVisitorFunc2<T>: FnMut(&T) {}
50
51impl<T, Super: FnMut(&T)> IntersectionVisitorFunc2<T> for Super {}
52
53pub trait IntersectionQueryEngine2<T> {
55 fn intersects_aabb<Callback>(&self, aabb: &BoundingBox2D,
57 test_func: &mut Callback) -> bool
58 where Callback: BoxIntersectionTestFunc2<T>;
59
60 fn intersects_ray<Callback>(&self, ray: &Ray2D,
62 test_func: &mut Callback) -> bool
63 where Callback: RayIntersectionTestFunc2<T>;
64
65 fn for_each_intersecting_item_aabb<Callback, Visitor>(&self, aabb: &BoundingBox2D,
67 test_func: &mut Callback,
68 visitor_func: &mut Visitor)
69 where Callback: BoxIntersectionTestFunc2<T>,
70 Visitor: IntersectionVisitorFunc2<T>;
71
72 fn for_each_intersecting_item_ray<Callback, Visitor>(&self, ray: &Ray2D,
74 test_func: &mut Callback,
75 visitor_func: &mut Visitor)
76 where Callback: RayIntersectionTestFunc2<T>,
77 Visitor: IntersectionVisitorFunc2<T>;
78
79 fn closest_intersection<Callback>(&self, ray: &Ray2D,
81 test_func: &mut Callback) -> ClosestIntersectionQueryResult2<T>
82 where Callback: GetRayIntersectionFunc2<T>;
83}