Merge pull request #115794 from TokageItLab/toggle-trackball
Make trackball rotation optional as toggle option of Node3DEditorTool
This commit is contained in:
commit
9e2ab92fee
3 changed files with 32 additions and 9 deletions
1
editor/icons/Trackball.svg
Normal file
1
editor/icons/Trackball.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="-599.5 337.5 16 16"><path fill="#e0e0e0" d="M-584.606 338.605c-.21-.211-.596-.462-1.235-.462-.958 0-2.324.603-3.859 1.632-.568-.179-1.173-.275-1.8-.275-3.313 0-6 2.687-6 6 0 .628.097 1.232.276 1.801-1.44 2.15-2.135 4.129-1.17 5.094.21.211.596.462 1.235.462 1.761 0 4.885-1.985 7.957-5.059 3.32-3.32 6.175-7.612 4.596-9.193zm-12.553 12.751c-.113 0-.164-.02-.17-.02-.137-.224.083-1.11.876-2.454.211.308.448.597.711.859l1.585-1.585c0 .001-.001.001-.001.002.846-.636 1.811-1.458 2.835-2.482 1.024-1.023 1.846-1.987 2.48-2.833l1.586-1.586c-.262-.262-.549-.498-.855-.708.989-.586 1.794-.906 2.271-.906.113 0 .164.02.17.02.261.425-.752 3.234-4.593 7.074-2.999 3-5.791 4.619-6.895 4.619zM-591.099 351.479c2.991-.198 5.378-2.584 5.578-5.575-.998 1.277-2.018 2.351-2.621 2.954-.538.538-1.631 1.585-2.957 2.621z"/></svg>
|
||||
|
After Width: | Height: | Size: 882 B |
|
|
@ -1465,7 +1465,7 @@ bool Node3DEditorViewport::_transform_gizmo_select(const Vector2 &p_screenpos, b
|
|||
if (Math::abs(distance_ray_to_center - view_rotation_radius) < circumference_tolerance &&
|
||||
ray_length_to_center > 0) {
|
||||
view_rotation_selected = true;
|
||||
} else if (distance_ray_to_center < gizmo_scale * (GIZMO_CIRCLE_SIZE - GIZMO_RING_HALF_WIDTH) && ray_length_to_center > 0) {
|
||||
} else if (spatial_editor->is_trackball_enabled() && distance_ray_to_center < gizmo_scale * (GIZMO_CIRCLE_SIZE - GIZMO_RING_HALF_WIDTH) && ray_length_to_center > 0) {
|
||||
trackball_selected = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -7134,6 +7134,7 @@ Dictionary Node3DEditor::get_state() const {
|
|||
Dictionary d;
|
||||
|
||||
d["snap_enabled"] = snap_enabled;
|
||||
d["trackball_enabled"] = trackball_enabled;
|
||||
d["translate_snap"] = snap_translate_value;
|
||||
d["rotate_snap"] = snap_rotate_value;
|
||||
d["scale_snap"] = snap_scale_value;
|
||||
|
|
@ -7214,6 +7215,11 @@ void Node3DEditor::set_state(const Dictionary &p_state) {
|
|||
tool_option_button[TOOL_OPT_USE_SNAP]->set_pressed(d["snap_enabled"]);
|
||||
}
|
||||
|
||||
if (d.has("trackball_enabled")) {
|
||||
trackball_enabled = d["trackball_enabled"];
|
||||
tool_option_button[TOOL_OPT_USE_TRACKBALL]->set_pressed(d["trackball_enabled"]);
|
||||
}
|
||||
|
||||
if (d.has("translate_snap")) {
|
||||
snap_translate_value = d["translate_snap"];
|
||||
}
|
||||
|
|
@ -7461,6 +7467,11 @@ void Node3DEditor::_menu_item_toggled(bool pressed, int p_option) {
|
|||
tool_option_button[TOOL_OPT_USE_SNAP]->set_pressed(pressed);
|
||||
snap_enabled = pressed;
|
||||
} break;
|
||||
|
||||
case MENU_TOOL_USE_TRACKBALL: {
|
||||
tool_option_button[TOOL_OPT_USE_TRACKBALL]->set_pressed(pressed);
|
||||
trackball_enabled = pressed;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -9055,6 +9066,7 @@ void Node3DEditor::_update_theme() {
|
|||
|
||||
tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_button_icon(get_editor_theme_icon(SNAME("Object")));
|
||||
tool_option_button[TOOL_OPT_USE_SNAP]->set_button_icon(get_editor_theme_icon(SNAME("Snap")));
|
||||
tool_option_button[TOOL_OPT_USE_TRACKBALL]->set_button_icon(get_editor_theme_icon(SNAME("Trackball")));
|
||||
|
||||
view_layout_menu->get_popup()->set_item_icon(view_layout_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_editor_theme_icon(SNAME("Panels1")));
|
||||
view_layout_menu->get_popup()->set_item_icon(view_layout_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_editor_theme_icon(SNAME("Panels2")));
|
||||
|
|
@ -9871,16 +9883,11 @@ Node3DEditor::Node3DEditor() {
|
|||
viewport_environment.instantiate();
|
||||
VBoxContainer *vbc = this;
|
||||
|
||||
custom_camera = nullptr;
|
||||
ERR_FAIL_COND_MSG(singleton != nullptr, "A Node3DEditor singleton already exists.");
|
||||
singleton = this;
|
||||
editor_selection = EditorNode::get_singleton()->get_editor_selection();
|
||||
editor_selection->add_editor_plugin(this);
|
||||
|
||||
snap_enabled = false;
|
||||
snap_key_enabled = false;
|
||||
tool_mode = TOOL_MODE_TRANSFORM;
|
||||
|
||||
MarginContainer *toolbar_margin = memnew(MarginContainer);
|
||||
toolbar_margin->set_theme_type_variation("MainToolBarMargin");
|
||||
vbc->add_child(toolbar_margin);
|
||||
|
|
@ -10021,6 +10028,15 @@ Node3DEditor::Node3DEditor() {
|
|||
tool_option_button[TOOL_OPT_USE_SNAP]->set_shortcut_context(this);
|
||||
tool_option_button[TOOL_OPT_USE_SNAP]->set_accessibility_name(TTRC("Use Snap"));
|
||||
|
||||
tool_option_button[TOOL_OPT_USE_TRACKBALL] = memnew(Button);
|
||||
main_menu_hbox->add_child(tool_option_button[TOOL_OPT_USE_TRACKBALL]);
|
||||
tool_option_button[TOOL_OPT_USE_TRACKBALL]->set_toggle_mode(true);
|
||||
tool_option_button[TOOL_OPT_USE_TRACKBALL]->set_theme_type_variation(SceneStringName(FlatButton));
|
||||
tool_option_button[TOOL_OPT_USE_TRACKBALL]->connect(SceneStringName(toggled), callable_mp(this, &Node3DEditor::_menu_item_toggled).bind(MENU_TOOL_USE_TRACKBALL));
|
||||
tool_option_button[TOOL_OPT_USE_TRACKBALL]->set_shortcut(ED_SHORTCUT("spatial_editor/trackball", TTRC("Use Trackball"), Key::U));
|
||||
tool_option_button[TOOL_OPT_USE_TRACKBALL]->set_shortcut_context(this);
|
||||
tool_option_button[TOOL_OPT_USE_TRACKBALL]->set_accessibility_name(TTRC("Use Trackball"));
|
||||
|
||||
main_menu_hbox->add_child(memnew(VSeparator));
|
||||
sun_button = memnew(Button);
|
||||
sun_button->set_tooltip_text(TTRC("Toggle preview sunlight.\nIf a DirectionalLight3D node is added to the scene, preview sunlight is disabled."));
|
||||
|
|
|
|||
|
|
@ -679,6 +679,7 @@ public:
|
|||
enum ToolOptions {
|
||||
TOOL_OPT_LOCAL_COORDS,
|
||||
TOOL_OPT_USE_SNAP,
|
||||
TOOL_OPT_USE_TRACKBALL,
|
||||
TOOL_OPT_MAX
|
||||
};
|
||||
|
||||
|
|
@ -700,7 +701,7 @@ private:
|
|||
|
||||
/////
|
||||
|
||||
ToolMode tool_mode;
|
||||
ToolMode tool_mode = TOOL_MODE_TRANSFORM;
|
||||
|
||||
RID origin_mesh;
|
||||
RID origin_multimesh;
|
||||
|
|
@ -778,6 +779,7 @@ private:
|
|||
MENU_TOOL_LIST_SELECT,
|
||||
MENU_TOOL_LOCAL_COORDS,
|
||||
MENU_TOOL_USE_SNAP,
|
||||
MENU_TOOL_USE_TRACKBALL,
|
||||
MENU_TRANSFORM_CONFIGURE_SNAP,
|
||||
MENU_TRANSFORM_DIALOG,
|
||||
MENU_VIEW_USE_1_VIEWPORT,
|
||||
|
|
@ -811,12 +813,14 @@ private:
|
|||
ConfirmationDialog *xform_dialog = nullptr;
|
||||
ConfirmationDialog *settings_dialog = nullptr;
|
||||
|
||||
bool snap_enabled;
|
||||
bool snap_key_enabled;
|
||||
bool snap_enabled = false;
|
||||
bool snap_key_enabled = false;
|
||||
EditorSpinSlider *snap_translate = nullptr;
|
||||
EditorSpinSlider *snap_rotate = nullptr;
|
||||
EditorSpinSlider *snap_scale = nullptr;
|
||||
|
||||
bool trackball_enabled = false;
|
||||
|
||||
LineEdit *xform_translate[3];
|
||||
LineEdit *xform_rotate[3];
|
||||
LineEdit *xform_scale[3];
|
||||
|
|
@ -996,6 +1000,8 @@ public:
|
|||
real_t get_rotate_snap() const;
|
||||
real_t get_scale_snap() const;
|
||||
|
||||
bool is_trackball_enabled() const { return trackball_enabled; }
|
||||
|
||||
Ref<ArrayMesh> get_move_gizmo(int idx) const { return move_gizmo[idx]; }
|
||||
Ref<ArrayMesh> get_axis_gizmo(int idx) const { return axis_gizmo[idx]; }
|
||||
Ref<ArrayMesh> get_move_plane_gizmo(int idx) const { return move_plane_gizmo[idx]; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue