summaryrefslogtreecommitdiff
path: root/scene/3d/ray_cast.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-10-23 14:49:47 +0200
committerGitHub <noreply@github.com>2017-10-23 14:49:47 +0200
commit804cab31de3691a3d33f02878f45fa5c8e46cdb2 (patch)
treed8ca3a117bea94150e094e774a0ee263c5d6278c /scene/3d/ray_cast.cpp
parenteda5f168212b7e99bb0efcb80b935b2c2b90b12d (diff)
parent8f054d519fe4c7b503922bfcd6d2770c2a83ff01 (diff)
Merge pull request #12350 from kubecz3k/ray-mask-bit
missing set/get_collision_mask_bit() for RayCast [ci skip]
Diffstat (limited to 'scene/3d/ray_cast.cpp')
-rw-r--r--scene/3d/ray_cast.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp
index 296bddf0a3..9f61cc64ea 100644
--- a/scene/3d/ray_cast.cpp
+++ b/scene/3d/ray_cast.cpp
@@ -63,6 +63,21 @@ void RayCast::set_type_mask(uint32_t p_mask) {
type_mask = p_mask;
}
+void RayCast::set_collision_mask_bit(int p_bit, bool p_value) {
+
+ uint32_t mask = get_collision_mask();
+ if (p_value)
+ mask |= 1 << p_bit;
+ else
+ mask &= ~(1 << p_bit);
+ set_collision_mask(mask);
+}
+
+bool RayCast::get_collision_mask_bit(int p_bit) const {
+
+ return get_collision_mask() & (1 << p_bit);
+}
+
uint32_t RayCast::get_type_mask() const {
return type_mask;
@@ -248,6 +263,9 @@ void RayCast::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &RayCast::set_collision_mask);
ClassDB::bind_method(D_METHOD("get_collision_mask"), &RayCast::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &RayCast::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &RayCast::get_collision_mask_bit);
+
ClassDB::bind_method(D_METHOD("set_type_mask", "mask"), &RayCast::set_type_mask);
ClassDB::bind_method(D_METHOD("get_type_mask"), &RayCast::get_type_mask);