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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#![macro_use]
pub const STATIC_GROUP_ID: usize = 29;
pub const SENSOR_GROUP_ID: usize = 28;
macro_rules! collision_groups_wrapper_impl(
($t: ident) => (
impl $t {
#[inline]
pub fn max_group_id() -> usize {
27
}
#[inline]
pub fn as_collision_groups(&self) -> &CollisionGroups {
&self.collision_groups
}
#[inline]
pub fn modify_membership(&mut self, group_id: usize, add: bool) {
assert!(group_id != STATIC_GROUP_ID, "The static group {} is reserved.", STATIC_GROUP_ID);
assert!(group_id != SENSOR_GROUP_ID, "The sensor group {} is reserved.", SENSOR_GROUP_ID);
self.collision_groups.modify_membership(group_id, add);
}
#[inline]
pub fn modify_whitelist(&mut self, group_id: usize, add: bool) {
assert!(group_id != STATIC_GROUP_ID, "The static group {} is reserved.", STATIC_GROUP_ID);
assert!(group_id != SENSOR_GROUP_ID, "The sensor group {} is reserved.", SENSOR_GROUP_ID);
self.collision_groups.modify_whitelist(group_id, add);
}
#[inline]
pub fn modify_blacklist(&mut self, group_id: usize, add: bool) {
assert!(group_id != STATIC_GROUP_ID, "The static group {} is reserved.", STATIC_GROUP_ID);
assert!(group_id != SENSOR_GROUP_ID, "The sensor group {} is reserved.", SENSOR_GROUP_ID);
self.collision_groups.modify_blacklist(group_id, add);
}
#[inline]
pub fn set_membership(&mut self, groups: &[usize]) {
assert!(!groups.contains(&STATIC_GROUP_ID), "The static group {} is reserved.", STATIC_GROUP_ID);
assert!(!groups.contains(&SENSOR_GROUP_ID), "The sensor group {} is reserved.", SENSOR_GROUP_ID);
let is_dynamic = self.is_dynamic();
self.collision_groups.set_membership(groups);
self.configure_reserved_flags(is_dynamic);
}
#[inline]
pub fn set_whitelist(&mut self, groups: &[usize]) {
assert!(!groups.contains(&STATIC_GROUP_ID), "The static group {} is reserved.", STATIC_GROUP_ID);
assert!(!groups.contains(&SENSOR_GROUP_ID), "The sensor group {} is reserved.", SENSOR_GROUP_ID);
let is_dynamic = self.is_dynamic();
self.collision_groups.set_whitelist(groups);
self.configure_reserved_flags(is_dynamic);
}
#[inline]
pub fn set_blacklist(&mut self, groups: &[usize]) {
assert!(!groups.contains(&STATIC_GROUP_ID), "The static group {} is reserved.", STATIC_GROUP_ID);
assert!(!groups.contains(&SENSOR_GROUP_ID), "The sensor group {} is reserved.", SENSOR_GROUP_ID);
let is_dynamic = self.is_dynamic();
self.collision_groups.set_blacklist(groups);
self.configure_reserved_flags(is_dynamic);
}
#[inline]
pub fn copy_membership(&mut self, other: &$t) {
let is_dynamic = self.is_dynamic();
self.collision_groups.copy_membership(other.as_collision_groups());
self.configure_reserved_flags(is_dynamic);
}
#[inline]
pub fn copy_whitelist(&mut self, other: &$t) {
let is_dynamic = self.is_dynamic();
self.collision_groups.copy_whitelist(other.as_collision_groups());
self.configure_reserved_flags(is_dynamic);
}
#[inline]
pub fn copy_blacklist(&mut self, other: &$t) {
let is_dynamic = self.is_dynamic();
self.collision_groups.copy_blacklist(other.as_collision_groups());
self.configure_reserved_flags(is_dynamic);
}
pub fn enable_interaction_with_static(&mut self) {
self.collision_groups.modify_blacklist(STATIC_GROUP_ID, false);
self.collision_groups.modify_whitelist(STATIC_GROUP_ID, true);
}
pub fn disable_interaction_with_static(&mut self) {
self.collision_groups.modify_blacklist(STATIC_GROUP_ID, true);
self.collision_groups.modify_whitelist(STATIC_GROUP_ID, false);
}
pub fn enable_interaction_with_sensors(&mut self) {
self.collision_groups.modify_blacklist(SENSOR_GROUP_ID, false);
self.collision_groups.modify_whitelist(SENSOR_GROUP_ID, true);
}
pub fn disable_interaction_with_sensors(&mut self) {
self.collision_groups.modify_blacklist(SENSOR_GROUP_ID, true);
self.collision_groups.modify_whitelist(SENSOR_GROUP_ID, false);
}
#[inline]
pub fn enable_self_interaction(&mut self) {
self.collision_groups.enable_self_interaction();
}
#[inline]
pub fn disable_self_interaction(&mut self) {
self.collision_groups.disable_self_interaction();
}
#[inline]
pub fn is_member_of(&self, group_id: usize) -> bool {
self.collision_groups.is_member_of(group_id)
}
#[inline]
pub fn is_group_whitelisted(&self, group_id: usize) -> bool {
self.collision_groups.is_group_whitelisted(group_id)
}
#[inline]
pub fn is_group_blacklisted(&self, group_id: usize) -> bool {
self.collision_groups.is_group_blacklisted(group_id)
}
#[inline]
pub fn can_interact_with(&self, group_id: usize) -> bool {
self.collision_groups.can_interact_with(group_id)
}
#[inline]
pub fn can_interact_with_groups(&self, other: &CollisionGroups) -> bool {
self.collision_groups.can_interact_with_groups(other)
}
#[inline]
pub fn can_interact_with_self(&self) -> bool {
self.collision_groups.can_interact_with_self()
}
}
)
);