Fix collision shape update when changing shape properties
This change does two things: 1. Properly update the internal shape data using _update_in_shape_owner when updating a shape (in 2D it was resetting one way collision) 2. Avoid unnecessary updates when calling set_shape with the same shape, which happens each time a shape property is modified (e.g shape.extents.x = ...) Fixes #45090
This commit is contained in:
parent
c26510359a
commit
4b43cd17c5
@ -194,6 +194,7 @@ void CollisionPolygon2D::set_polygon(const Vector<Point2> &p_polygon) {
|
|||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
_build_polygon();
|
_build_polygon();
|
||||||
|
_update_in_shape_owner();
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
update_configuration_warning();
|
update_configuration_warning();
|
||||||
@ -208,6 +209,7 @@ void CollisionPolygon2D::set_build_mode(BuildMode p_mode) {
|
|||||||
build_mode = p_mode;
|
build_mode = p_mode;
|
||||||
if (parent) {
|
if (parent) {
|
||||||
_build_polygon();
|
_build_polygon();
|
||||||
|
_update_in_shape_owner();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +141,9 @@ void CollisionShape2D::_notification(int p_what) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CollisionShape2D::set_shape(const Ref<Shape2D> &p_shape) {
|
void CollisionShape2D::set_shape(const Ref<Shape2D> &p_shape) {
|
||||||
|
if (p_shape == shape) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (shape.is_valid()) {
|
if (shape.is_valid()) {
|
||||||
shape->disconnect("changed", callable_mp(this, &CollisionShape2D::_shape_changed));
|
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()) {
|
if (shape.is_valid()) {
|
||||||
parent->shape_owner_add_shape(owner_id, shape);
|
parent->shape_owner_add_shape(owner_id, shape);
|
||||||
}
|
}
|
||||||
|
_update_in_shape_owner();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shape.is_valid()) {
|
if (shape.is_valid()) {
|
||||||
|
@ -93,7 +93,6 @@ void CollisionShape3D::_notification(int p_what) {
|
|||||||
if (shape.is_valid()) {
|
if (shape.is_valid()) {
|
||||||
parent->shape_owner_add_shape(owner_id, shape);
|
parent->shape_owner_add_shape(owner_id, shape);
|
||||||
}
|
}
|
||||||
_update_in_shape_owner();
|
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_ENTER_TREE: {
|
case NOTIFICATION_ENTER_TREE: {
|
||||||
@ -170,6 +169,9 @@ void CollisionShape3D::_bind_methods() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CollisionShape3D::set_shape(const Ref<Shape3D> &p_shape) {
|
void CollisionShape3D::set_shape(const Ref<Shape3D> &p_shape) {
|
||||||
|
if (p_shape == shape) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!shape.is_null()) {
|
if (!shape.is_null()) {
|
||||||
shape->unregister_owner(this);
|
shape->unregister_owner(this);
|
||||||
shape->disconnect("changed", callable_mp(this, &CollisionShape3D::_shape_changed));
|
shape->disconnect("changed", callable_mp(this, &CollisionShape3D::_shape_changed));
|
||||||
|
Loading…
Reference in New Issue
Block a user