Merge pull request #76372 from sygi/dont_propagate_lock_view

Store lock view rotation whether its on or off
This commit is contained in:
Rémi Verschelde 2023-06-12 17:09:38 +02:00
commit 6306eb4047
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 16 additions and 14 deletions

View File

@ -3329,13 +3329,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
case VIEW_LOCK_ROTATION: {
int idx = view_menu->get_popup()->get_item_index(VIEW_LOCK_ROTATION);
bool current = view_menu->get_popup()->is_item_checked(idx);
lock_rotation = !current;
view_menu->get_popup()->set_item_checked(idx, !current);
if (lock_rotation) {
locked_label->show();
} else {
locked_label->hide();
}
_set_lock_view_rotation(!current);
} break;
case VIEW_AUDIO_LISTENER: {
@ -3809,10 +3803,7 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) {
}
}
if (p_state.has("lock_rotation")) {
lock_rotation = p_state["lock_rotation"];
int idx = view_menu->get_popup()->get_item_index(VIEW_LOCK_ROTATION);
view_menu->get_popup()->set_item_checked(idx, lock_rotation);
_set_lock_view_rotation(p_state["lock_rotation"]);
}
if (p_state.has("use_environment")) {
bool env = p_state["use_environment"];
@ -3928,9 +3919,7 @@ Dictionary Node3DEditorViewport::get_state() const {
if (previewing) {
d["previewing"] = EditorNode::get_singleton()->get_edited_scene()->get_path_to(previewing);
}
if (lock_rotation) {
d["lock_rotation"] = lock_rotation;
}
d["lock_rotation"] = lock_rotation;
return d;
}
@ -4935,6 +4924,17 @@ void Node3DEditorViewport::shortcut_changed_callback(const Ref<Shortcut> p_short
}
}
void Node3DEditorViewport::_set_lock_view_rotation(bool p_lock_rotation) {
lock_rotation = p_lock_rotation;
int idx = view_menu->get_popup()->get_item_index(VIEW_LOCK_ROTATION);
view_menu->get_popup()->set_item_checked(idx, p_lock_rotation);
if (p_lock_rotation) {
locked_label->show();
} else {
locked_label->hide();
}
}
Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p_index) {
cpu_time_history_index = 0;
gpu_time_history_index = 0;

View File

@ -450,6 +450,8 @@ private:
void register_shortcut_action(const String &p_path, const String &p_name, Key p_keycode, bool p_physical = false);
void shortcut_changed_callback(const Ref<Shortcut> p_shortcut, const String &p_shortcut_path);
void _set_lock_view_rotation(bool p_lock_rotation);
protected:
void _notification(int p_what);
static void _bind_methods();