summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/navigation_polygon.cpp2
-rw-r--r--scene/2d/ray_cast_2d.cpp18
-rw-r--r--scene/2d/ray_cast_2d.h3
3 files changed, 22 insertions, 1 deletions
diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp
index 35f94bff59..c53241e985 100644
--- a/scene/2d/navigation_polygon.cpp
+++ b/scene/2d/navigation_polygon.cpp
@@ -452,7 +452,7 @@ String NavigationPolygonInstance::get_configuration_warning() const {
return String();
}
- c = Object::cast_to<Node2D>(get_parent());
+ c = Object::cast_to<Node2D>(c->get_parent());
}
return TTR("NavigationPolygonInstance must be a child or grandchild to a Navigation2D node. It only provides navigation data.");
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index fa656bdcd3..ff23b3183b 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -61,6 +61,21 @@ void RayCast2D::set_type_mask(uint32_t p_mask) {
type_mask = p_mask;
}
+void RayCast2D::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 RayCast2D::get_collision_mask_bit(int p_bit) const {
+
+ return get_collision_mask() & (1 << p_bit);
+}
+
uint32_t RayCast2D::get_type_mask() const {
return type_mask;
@@ -279,6 +294,9 @@ void RayCast2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &RayCast2D::set_collision_mask);
ClassDB::bind_method(D_METHOD("get_collision_mask"), &RayCast2D::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &RayCast2D::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &RayCast2D::get_collision_mask_bit);
+
ClassDB::bind_method(D_METHOD("set_type_mask", "mask"), &RayCast2D::set_type_mask);
ClassDB::bind_method(D_METHOD("get_type_mask"), &RayCast2D::get_type_mask);
diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h
index da1be84307..c13ddfdc58 100644
--- a/scene/2d/ray_cast_2d.h
+++ b/scene/2d/ray_cast_2d.h
@@ -64,6 +64,9 @@ public:
void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_mask() const;
+ void set_collision_mask_bit(int p_bit, bool p_value);
+ bool get_collision_mask_bit(int p_bit) const;
+
void set_type_mask(uint32_t p_mask);
uint32_t get_type_mask() const;