Skip to content

Commit

Permalink
Merge pull request #45102 from nekomatata/fix-update-shape-data
Browse files Browse the repository at this point in the history
Fix collision shape update when changing shape properties
  • Loading branch information
akien-mga authored Jan 13, 2021
2 parents d214869 + 4b43cd1 commit 7f8ab37
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions scene/2d/collision_polygon_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -208,6 +209,7 @@ void CollisionPolygon2D::set_build_mode(BuildMode p_mode) {
build_mode = p_mode;
if (parent) {
_build_polygon();
_update_in_shape_owner();
}
}

Expand Down
4 changes: 4 additions & 0 deletions scene/2d/collision_shape_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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()) {
Expand Down
4 changes: 3 additions & 1 deletion scene/3d/collision_shape_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 7f8ab37

Please sign in to comment.