summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/shape_cast_2d.cpp13
-rw-r--r--scene/2d/shape_cast_2d.h2
-rw-r--r--scene/3d/shape_cast_3d.cpp6
3 files changed, 13 insertions, 8 deletions
diff --git a/scene/2d/shape_cast_2d.cpp b/scene/2d/shape_cast_2d.cpp
index bafb83361a..5b743e0b31 100644
--- a/scene/2d/shape_cast_2d.cpp
+++ b/scene/2d/shape_cast_2d.cpp
@@ -151,11 +151,18 @@ bool ShapeCast2D::is_enabled() const {
}
void ShapeCast2D::set_shape(const Ref<Shape2D> &p_shape) {
+ if (p_shape == shape) {
+ return;
+ }
+ if (shape.is_valid()) {
+ shape->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &ShapeCast2D::_shape_changed));
+ }
shape = p_shape;
- if (p_shape.is_valid()) {
- shape->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &ShapeCast2D::_redraw_shape));
+ if (shape.is_valid()) {
+ shape->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &ShapeCast2D::_shape_changed));
shape_rid = shape->get_rid();
}
+
update_configuration_warnings();
queue_redraw();
}
@@ -186,7 +193,7 @@ bool ShapeCast2D::get_exclude_parent_body() const {
return exclude_parent_body;
}
-void ShapeCast2D::_redraw_shape() {
+void ShapeCast2D::_shape_changed() {
queue_redraw();
}
diff --git a/scene/2d/shape_cast_2d.h b/scene/2d/shape_cast_2d.h
index 8a62b799f8..a577c351fd 100644
--- a/scene/2d/shape_cast_2d.h
+++ b/scene/2d/shape_cast_2d.h
@@ -61,7 +61,7 @@ class ShapeCast2D : public Node2D {
real_t collision_unsafe_fraction = 1.0;
Array _get_collision_result() const;
- void _redraw_shape();
+ void _shape_changed();
protected:
void _notification(int p_what);
diff --git a/scene/3d/shape_cast_3d.cpp b/scene/3d/shape_cast_3d.cpp
index d880e422f0..602eb664dd 100644
--- a/scene/3d/shape_cast_3d.cpp
+++ b/scene/3d/shape_cast_3d.cpp
@@ -331,16 +331,14 @@ void ShapeCast3D::set_shape(const Ref<Shape3D> &p_shape) {
if (p_shape == shape) {
return;
}
- if (!shape.is_null()) {
+ if (shape.is_valid()) {
shape->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &ShapeCast3D::_shape_changed));
shape->unregister_owner(this);
}
shape = p_shape;
- if (!shape.is_null()) {
+ if (shape.is_valid()) {
shape->register_owner(this);
shape->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &ShapeCast3D::_shape_changed));
- }
- if (p_shape.is_valid()) {
shape_rid = shape->get_rid();
}