summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp33
-rw-r--r--editor/plugins/spatial_editor_plugin.h5
2 files changed, 32 insertions, 6 deletions
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 4417ccd83f..4b0cbdb4e7 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -4578,13 +4578,15 @@ void SpatialEditor::set_state(const Dictionary &p_state) {
}
if (d.has("translate_snap"))
- snap_translate->set_text(d["translate_snap"]);
+ snap_translate_value = d["translate_snap"];
if (d.has("rotate_snap"))
- snap_rotate->set_text(d["rotate_snap"]);
+ snap_rotate_value = d["rotate_snap"];
if (d.has("scale_snap"))
- snap_scale->set_text(d["scale_snap"]);
+ snap_scale_value = d["scale_snap"];
+
+ _snap_update();
if (d.has("local_coords")) {
tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_pressed(d["local_coords"]);
@@ -4691,6 +4693,20 @@ void SpatialEditor::edit(Spatial *p_spatial) {
}
}
+void SpatialEditor::_snap_changed() {
+
+ snap_translate_value = snap_translate->get_text().to_double();
+ snap_rotate_value = snap_rotate->get_text().to_double();
+ snap_scale_value = snap_scale->get_text().to_double();
+}
+
+void SpatialEditor::_snap_update() {
+
+ snap_translate->set_text(String::num(snap_translate_value));
+ snap_rotate->set_text(String::num(snap_rotate_value));
+ snap_scale->set_text(String::num(snap_scale_value));
+}
+
void SpatialEditor::_xform_dialog_action() {
Transform t;
@@ -6171,25 +6187,30 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
/* SNAP DIALOG */
+ snap_translate_value = 1;
+ snap_rotate_value = 15;
+ snap_scale_value = 10;
+
snap_dialog = memnew(ConfirmationDialog);
snap_dialog->set_title(TTR("Snap Settings"));
add_child(snap_dialog);
+ snap_dialog->connect("confirmed", callable_mp(this, &SpatialEditor::_snap_changed));
+ snap_dialog->get_cancel()->connect("pressed", callable_mp(this, &SpatialEditor::_snap_update));
VBoxContainer *snap_dialog_vbc = memnew(VBoxContainer);
snap_dialog->add_child(snap_dialog_vbc);
snap_translate = memnew(LineEdit);
- snap_translate->set_text("1");
snap_dialog_vbc->add_margin_child(TTR("Translate Snap:"), snap_translate);
snap_rotate = memnew(LineEdit);
- snap_rotate->set_text("15");
snap_dialog_vbc->add_margin_child(TTR("Rotate Snap (deg.):"), snap_rotate);
snap_scale = memnew(LineEdit);
- snap_scale->set_text("10");
snap_dialog_vbc->add_margin_child(TTR("Scale Snap (%):"), snap_scale);
+ _snap_update();
+
/* SETTINGS DIALOG */
settings_dialog = memnew(ConfirmationDialog);
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index 14153dd63b..489bce1e15 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -592,6 +592,9 @@ private:
Ref<StandardMaterial3D> plane_gizmo_color_hl[3];
int over_gizmo_handle;
+ float snap_translate_value;
+ float snap_rotate_value;
+ float snap_scale_value;
Ref<ArrayMesh> selection_box;
RID indicators;
@@ -671,6 +674,8 @@ private:
SpinBox *settings_znear;
SpinBox *settings_zfar;
+ void _snap_changed();
+ void _snap_update();
void _xform_dialog_action();
void _menu_item_pressed(int p_option);
void _menu_item_toggled(bool pressed, int p_option);