Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not commit gizmo handles if no changes were made #102317

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions editor/plugins/gizmos/soft_body_3d_gizmo_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ bool SoftBody3DGizmoPlugin::is_selectable_when_hidden() const {
return true;
}

bool SoftBody3DGizmoPlugin::can_commit_handle_on_click() const {
return true;
}

void SoftBody3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_node_3d());

Expand Down
1 change: 1 addition & 0 deletions editor/plugins/gizmos/soft_body_3d_gizmo_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class SoftBody3DGizmoPlugin : public EditorNode3DGizmoPlugin {
String get_gizmo_name() const override;
int get_priority() const override;
bool is_selectable_when_hidden() const override;
bool can_commit_handle_on_click() const override;
void redraw(EditorNode3DGizmo *p_gizmo) override;

String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const override;
Expand Down
4 changes: 4 additions & 0 deletions editor/plugins/node_3d_editor_gizmos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,10 @@ bool EditorNode3DGizmoPlugin::is_selectable_when_hidden() const {
return ret;
}

bool EditorNode3DGizmoPlugin::can_commit_handle_on_click() const {
return false;
}

void EditorNode3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
GDVIRTUAL_CALL(_redraw, p_gizmo);
}
Expand Down
1 change: 1 addition & 0 deletions editor/plugins/node_3d_editor_gizmos.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class EditorNode3DGizmoPlugin : public Resource {
virtual int get_priority() const;
virtual bool can_be_hidden() const;
virtual bool is_selectable_when_hidden() const;
virtual bool can_commit_handle_on_click() const;

virtual void redraw(EditorNode3DGizmo *p_gizmo);
virtual bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const;
Expand Down
6 changes: 5 additions & 1 deletion editor/plugins/node_3d_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1984,7 +1984,11 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
}

if (_edit.gizmo.is_valid()) {
_edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, false);
//Certain gizmo plugins should be able to commit handles without dragging them.
if (_edit.original_mouse_pos != _edit.mouse_pos || _edit.gizmo->get_plugin()->can_commit_handle_on_click()) {
_edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, false);
}

spatial_editor->get_single_selected_node()->update_gizmos();
_edit.gizmo = Ref<EditorNode3DGizmo>();
break;
Expand Down