Merge pull request #16890 from Chaosus/ctrlsnap

Enable snapping in 3D when control key pressed
This commit is contained in:
Rémi Verschelde 2018-02-21 16:05:23 +01:00 committed by GitHub
commit 6afaf83de3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -4691,6 +4691,8 @@ void SpatialEditor::_unhandled_key_input(Ref<InputEvent> p_event) {
if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack())
return;
snap_key_enabled = Input::get_singleton()->is_key_pressed(KEY_CONTROL);
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
@ -4962,6 +4964,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
editor_selection->add_editor_plugin(this);
snap_enabled = false;
snap_key_enabled = false;
tool_mode = TOOL_MODE_SELECT;
hbc_menu = memnew(HBoxContainer);

View File

@ -505,6 +505,7 @@ private:
ConfirmationDialog *settings_dialog;
bool snap_enabled;
bool snap_key_enabled;
LineEdit *snap_translate;
LineEdit *snap_rotate;
LineEdit *snap_scale;
@ -579,7 +580,7 @@ public:
ToolMode get_tool_mode() const { return tool_mode; }
bool are_local_coords_enabled() const { return tool_option_button[SpatialEditor::TOOL_OPT_LOCAL_COORDS]->is_pressed(); }
bool is_snap_enabled() const { return snap_enabled; }
bool is_snap_enabled() const { return snap_enabled ^ snap_key_enabled; }
float get_translate_snap() const { return snap_translate->get_text().to_double(); }
float get_rotate_snap() const { return snap_rotate->get_text().to_double(); }
float get_scale_snap() const { return snap_scale->get_text().to_double(); }