Merge pull request #73063 from KoBeWi/it_exited_the_tree_but_changed_its_mind_and_broke_instead
Fix camera reparenting
This commit is contained in:
commit
38d7583f86
2 changed files with 8 additions and 0 deletions
|
@ -266,6 +266,8 @@ void Camera2D::_notification(int p_what) {
|
||||||
clear_current();
|
clear_current();
|
||||||
}
|
}
|
||||||
viewport = nullptr;
|
viewport = nullptr;
|
||||||
|
just_exited_tree = true;
|
||||||
|
callable_mp(this, &Camera2D::_reset_just_exited).call_deferred();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
|
@ -438,6 +440,10 @@ void Camera2D::_update_process_internal_for_smoothing() {
|
||||||
void Camera2D::make_current() {
|
void Camera2D::make_current() {
|
||||||
ERR_FAIL_COND(!enabled || !is_inside_tree());
|
ERR_FAIL_COND(!enabled || !is_inside_tree());
|
||||||
get_tree()->call_group(group_name, "_make_current", this);
|
get_tree()->call_group(group_name, "_make_current", this);
|
||||||
|
if (just_exited_tree) {
|
||||||
|
// If camera exited the scene tree in the same frame, group call will skip it, so this needs to be called manually.
|
||||||
|
_make_current(this);
|
||||||
|
}
|
||||||
_update_scroll();
|
_update_scroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ protected:
|
||||||
Point2 camera_pos;
|
Point2 camera_pos;
|
||||||
Point2 smoothed_camera_pos;
|
Point2 smoothed_camera_pos;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
bool just_exited_tree = false;
|
||||||
|
|
||||||
ObjectID custom_viewport_id; // to check validity
|
ObjectID custom_viewport_id; // to check validity
|
||||||
Viewport *custom_viewport = nullptr;
|
Viewport *custom_viewport = nullptr;
|
||||||
|
@ -88,6 +89,7 @@ protected:
|
||||||
void _update_scroll();
|
void _update_scroll();
|
||||||
|
|
||||||
void _make_current(Object *p_which);
|
void _make_current(Object *p_which);
|
||||||
|
void _reset_just_exited() { just_exited_tree = false; }
|
||||||
|
|
||||||
void _set_old_smoothing(real_t p_enable);
|
void _set_old_smoothing(real_t p_enable);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue