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
use na::RealField;
use crate::bounding_volume::{BoundingVolume, AABB};
use crate::math::Isometry;
use crate::pipeline::broad_phase::{BroadPhase, BroadPhaseProxyHandle, DBVTBroadPhase};
use crate::pipeline::narrow_phase::{
CollisionObjectGraphIndex, DefaultContactDispatcher, DefaultProximityDispatcher,
InteractionGraph, NarrowPhase,
};
use crate::pipeline::object::{CollisionObjectHandle, GeometricQueryType};
use crate::shape::Shape;
pub fn create_proxies<'a, N: RealField, Handle: CollisionObjectHandle>(
handle: Handle,
broad_phase: &mut (impl BroadPhase<N, AABB<N>, Handle> + ?Sized),
interactions: &mut InteractionGraph<N, Handle>,
position: &Isometry<N>,
shape: &(impl Shape<N> + ?Sized),
query_type: GeometricQueryType<N>,
) -> (BroadPhaseProxyHandle, CollisionObjectGraphIndex) {
let mut aabb = shape.aabb(position);
aabb.loosen(query_type.query_limit());
let proxy_handle = broad_phase.create_proxy(aabb, handle);
let graph_index = interactions.add_node(handle);
(proxy_handle, graph_index)
}
#[must_use = "The graph index of the collision object returned by this method has been changed to the returned graph index."]
pub fn remove_proxies<'a, N: RealField, Handle: CollisionObjectHandle>(
broad_phase: &mut (impl BroadPhase<N, AABB<N>, Handle> + ?Sized),
interactions: &mut InteractionGraph<N, Handle>,
proxy_handle: BroadPhaseProxyHandle,
graph_index: CollisionObjectGraphIndex,
) -> Option<(Handle, CollisionObjectGraphIndex)> {
broad_phase.remove(&[proxy_handle], &mut |_, _| {});
interactions
.remove_node(graph_index)
.map(|h| (h, graph_index))
}
pub fn default_narrow_phase<N: RealField, Handle: CollisionObjectHandle>() -> NarrowPhase<N, Handle>
{
let coll_dispatcher = Box::new(DefaultContactDispatcher::new());
let prox_dispatcher = Box::new(DefaultProximityDispatcher::new());
NarrowPhase::new(coll_dispatcher, prox_dispatcher)
}
pub fn default_broad_phase<N: RealField, Handle: CollisionObjectHandle>(
) -> DBVTBroadPhase<N, AABB<N>, Handle> {
let default_margin = 0.01f64;
DBVTBroadPhase::new(na::convert(default_margin))
}
pub fn default_interaction_graph<N: RealField, Handle: CollisionObjectHandle>(
) -> InteractionGraph<N, Handle> {
InteractionGraph::new()
}