diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2018-01-11 21:05:42 +0100 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2018-01-11 21:08:58 +0100 |
commit | aefedb73fcba789207db4da0d27214eecaf0f078 (patch) | |
tree | 6e2b4faa9ac2a228019eff0c2e732395cf5413cc /scene/3d/collision_polygon.cpp | |
parent | a60896869e6c17f674ff25bee87cabb54cd4403d (diff) | |
download | redot-engine-aefedb73fcba789207db4da0d27214eecaf0f078.tar.gz |
Update collision shapes data on tree entered
This is needed because the final startup values for shapes may change between parenting and entering the scene tree. For instance, if the collision shape belongs to a inherited scene.
Fixes #13835.
Diffstat (limited to 'scene/3d/collision_polygon.cpp')
-rw-r--r-- | scene/3d/collision_polygon.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp index ef1b33a4e2..3a77360bc2 100644 --- a/scene/3d/collision_polygon.cpp +++ b/scene/3d/collision_polygon.cpp @@ -73,6 +73,14 @@ void CollisionPolygon::_build_polygon() { } } +void CollisionPolygon::_update_in_shape_owner(bool p_xform_only) { + + parent->shape_owner_set_transform(owner_id, get_transform()); + if (p_xform_only) + return; + parent->shape_owner_set_disabled(owner_id, disabled); +} + void CollisionPolygon::_notification(int p_what) { switch (p_what) { @@ -82,14 +90,20 @@ void CollisionPolygon::_notification(int p_what) { if (parent) { owner_id = parent->create_shape_owner(this); _build_polygon(); - parent->shape_owner_set_transform(owner_id, get_transform()); - parent->shape_owner_set_disabled(owner_id, disabled); + _update_in_shape_owner(); } } break; + case NOTIFICATION_ENTER_TREE: { + + if (parent) { + _update_in_shape_owner(); + } + + } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { if (parent) { - parent->shape_owner_set_transform(owner_id, get_transform()); + _update_in_shape_owner(true); } } break; |