mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 11:56:49 +01:00
Ported: Physics Interpolation 2D - reset on NOTIFICATION_ENTER_TREE
As a convenience, physics interpolation is reset automatically on entering the tree. This will be desired in most situations, and saves the user having to write code for this explicitly.
- lawnjelly
bcfca5ec86
This commit is contained in:
parent
a29d232a4c
commit
e5cec36ba0
@ -592,6 +592,19 @@ void CanvasItem::_notification(int p_what) {
|
||||
get_tree()->xform_change_list.add(&xform_change);
|
||||
}
|
||||
|
||||
// If using physics interpolation, reset for this node only,
|
||||
// as a helper, as in most cases, users will want items reset when
|
||||
// adding to the tree.
|
||||
// In cases where they move immediately after adding,
|
||||
// there will be little cost in having two resets as these are cheap,
|
||||
// and it is worth it for convenience.
|
||||
// Do not propagate to children, as each child of an added branch
|
||||
// receives its own NOTIFICATION_ENTER_TREE, and this would
|
||||
// cause unnecessary duplicate resets.
|
||||
if (is_physics_interpolated_and_enabled()) {
|
||||
notification(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
|
||||
}
|
||||
|
||||
if (get_viewport()) {
|
||||
get_parent()->connect(SceneStringNames::get_singleton()->child_order_changed, get_viewport(), SceneStringNames::get_singleton()->canvas_parent_mark_dirty, varray(get_parent()), CONNECT_REFERENCE_COUNTED);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user