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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
use bevy::prelude::Entity;
use rapier::geometry::InteractionGroups;
use rapier::pipeline::QueryFilterFlags;
#[derive(Copy, Clone, Default)]
pub struct QueryFilter<'a> {
pub flags: QueryFilterFlags,
pub groups: Option<InteractionGroups>,
pub exclude_collider: Option<Entity>,
pub exclude_rigid_body: Option<Entity>,
pub predicate: Option<&'a dyn Fn(Entity) -> bool>,
}
impl<'a> From<QueryFilterFlags> for QueryFilter<'a> {
fn from(flags: QueryFilterFlags) -> Self {
Self {
flags,
..QueryFilter::default()
}
}
}
impl<'a> From<InteractionGroups> for QueryFilter<'a> {
fn from(groups: InteractionGroups) -> Self {
Self {
groups: Some(groups),
..QueryFilter::default()
}
}
}
impl<'a> QueryFilter<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn exclude_fixed() -> Self {
QueryFilterFlags::EXCLUDE_FIXED.into()
}
pub fn exclude_kinematic() -> Self {
QueryFilterFlags::EXCLUDE_KINEMATIC.into()
}
pub fn exclude_dynamic(self) -> Self {
QueryFilterFlags::EXCLUDE_DYNAMIC.into()
}
pub fn only_dynamic() -> Self {
QueryFilterFlags::ONLY_DYNAMIC.into()
}
pub fn only_kinematic() -> Self {
QueryFilterFlags::ONLY_KINEMATIC.into()
}
pub fn only_fixed() -> Self {
QueryFilterFlags::ONLY_FIXED.into()
}
pub fn exclude_sensors(mut self) -> Self {
self.flags |= QueryFilterFlags::EXCLUDE_SENSORS;
self
}
pub fn exclude_solids(mut self) -> Self {
self.flags |= QueryFilterFlags::EXCLUDE_SOLIDS;
self
}
pub fn groups(mut self, groups: InteractionGroups) -> Self {
self.groups = Some(groups);
self
}
pub fn exclude_collider(mut self, collider: Entity) -> Self {
self.exclude_collider = Some(collider);
self
}
pub fn exclude_rigid_body(mut self, rigid_body: Entity) -> Self {
self.exclude_rigid_body = Some(rigid_body);
self
}
pub fn predicate(mut self, predicate: &'a impl Fn(Entity) -> bool) -> Self {
self.predicate = Some(predicate);
self
}
}