summaryrefslogtreecommitdiff
path: root/scene/2d/shape_cast_2d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d/shape_cast_2d.cpp')
-rw-r--r--scene/2d/shape_cast_2d.cpp13
1 files changed, 10 insertions, 3 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();
}