summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2021-01-13 09:18:15 +0100
committerGitHub <noreply@github.com>2021-01-13 09:18:15 +0100
commit7f8ab378e9840ce5ea80b4bad9dcd3094cd0e0bc (patch)
tree2159e93fc98313d62236208cc2cd92f4ee4e2d3f
parentd2148692bc5433a5d866bf59138b718c0fa6cae5 (diff)
parent4b43cd17c5412f4cc4c67b6bb8de8717e7b2aff4 (diff)
Merge pull request #45102 from nekomatata/fix-update-shape-data
Fix collision shape update when changing shape properties
-rw-r--r--scene/2d/collision_polygon_2d.cpp2
-rw-r--r--scene/2d/collision_shape_2d.cpp4
-rw-r--r--scene/3d/collision_shape_3d.cpp4
3 files changed, 9 insertions, 1 deletions
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp
index e032f0aafa..851e40cda6 100644
--- a/scene/2d/collision_polygon_2d.cpp
+++ b/scene/2d/collision_polygon_2d.cpp
@@ -194,6 +194,7 @@ void CollisionPolygon2D::set_polygon(const Vector<Point2> &p_polygon) {
if (parent) {
_build_polygon();
+ _update_in_shape_owner();
}
update();
update_configuration_warning();
@@ -208,6 +209,7 @@ void CollisionPolygon2D::set_build_mode(BuildMode p_mode) {
build_mode = p_mode;
if (parent) {
_build_polygon();
+ _update_in_shape_owner();
}
}
diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp
index acdde96df0..37bed577ac 100644
--- a/scene/2d/collision_shape_2d.cpp
+++ b/scene/2d/collision_shape_2d.cpp
@@ -141,6 +141,9 @@ void CollisionShape2D::_notification(int p_what) {
}
void CollisionShape2D::set_shape(const Ref<Shape2D> &p_shape) {
+ if (p_shape == shape) {
+ return;
+ }
if (shape.is_valid()) {
shape->disconnect("changed", callable_mp(this, &CollisionShape2D::_shape_changed));
}
@@ -151,6 +154,7 @@ void CollisionShape2D::set_shape(const Ref<Shape2D> &p_shape) {
if (shape.is_valid()) {
parent->shape_owner_add_shape(owner_id, shape);
}
+ _update_in_shape_owner();
}
if (shape.is_valid()) {
diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp
index 47966c772b..503d1be104 100644
--- a/scene/3d/collision_shape_3d.cpp
+++ b/scene/3d/collision_shape_3d.cpp
@@ -93,7 +93,6 @@ void CollisionShape3D::_notification(int p_what) {
if (shape.is_valid()) {
parent->shape_owner_add_shape(owner_id, shape);
}
- _update_in_shape_owner();
}
} break;
case NOTIFICATION_ENTER_TREE: {
@@ -170,6 +169,9 @@ void CollisionShape3D::_bind_methods() {
}
void CollisionShape3D::set_shape(const Ref<Shape3D> &p_shape) {
+ if (p_shape == shape) {
+ return;
+ }
if (!shape.is_null()) {
shape->unregister_owner(this);
shape->disconnect("changed", callable_mp(this, &CollisionShape3D::_shape_changed));