Do not commit transforms and handles if no changes were made
This commit is contained in:
parent
26b1fd0d84
commit
f2f3f17de8
|
@ -291,6 +291,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
|
||||||
|
|
||||||
const PosVertex closest = closest_point(gpoint);
|
const PosVertex closest = closest_point(gpoint);
|
||||||
if (closest.valid()) {
|
if (closest.valid()) {
|
||||||
|
original_mouse_pos = gpoint;
|
||||||
pre_move_edit = _get_polygon(closest.polygon);
|
pre_move_edit = _get_polygon(closest.polygon);
|
||||||
edited_point = PosVertex(closest, xform.affine_inverse().xform(closest.pos));
|
edited_point = PosVertex(closest, xform.affine_inverse().xform(closest.pos));
|
||||||
selected_point = closest;
|
selected_point = closest;
|
||||||
|
@ -327,8 +328,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (edited_point.valid()) {
|
if (edited_point.valid()) {
|
||||||
//apply
|
if (original_mouse_pos != gpoint) {
|
||||||
|
|
||||||
Vector<Vector2> vertices = _get_polygon(edited_point.polygon);
|
Vector<Vector2> vertices = _get_polygon(edited_point.polygon);
|
||||||
ERR_FAIL_INDEX_V(edited_point.vertex, vertices.size(), false);
|
ERR_FAIL_INDEX_V(edited_point.vertex, vertices.size(), false);
|
||||||
vertices.write[edited_point.vertex] = edited_point.pos - _get_offset(edited_point.polygon);
|
vertices.write[edited_point.vertex] = edited_point.pos - _get_offset(edited_point.polygon);
|
||||||
|
@ -336,6 +336,7 @@ bool AbstractPolygon2DEditor::forward_gui_input(const Ref<InputEvent> &p_event)
|
||||||
undo_redo->create_action(TTR("Edit Polygon"));
|
undo_redo->create_action(TTR("Edit Polygon"));
|
||||||
_action_set_polygon(edited_point.polygon, pre_move_edit, vertices);
|
_action_set_polygon(edited_point.polygon, pre_move_edit, vertices);
|
||||||
_commit_action();
|
_commit_action();
|
||||||
|
}
|
||||||
|
|
||||||
edited_point = PosVertex();
|
edited_point = PosVertex();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -79,6 +79,7 @@ class AbstractPolygon2DEditor : public HBoxContainer {
|
||||||
Vertex hover_point; // point under mouse cursor
|
Vertex hover_point; // point under mouse cursor
|
||||||
Vertex selected_point; // currently selected
|
Vertex selected_point; // currently selected
|
||||||
PosVertex edge_point; // adding an edge point?
|
PosVertex edge_point; // adding an edge point?
|
||||||
|
Vector2 original_mouse_pos;
|
||||||
|
|
||||||
Vector<Vector2> pre_move_edit;
|
Vector<Vector2> pre_move_edit;
|
||||||
Vector<Vector2> wip;
|
Vector<Vector2> wip;
|
||||||
|
|
|
@ -65,10 +65,13 @@ bool Cast2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) {
|
if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) {
|
||||||
Vector2 target_position = node->get("target_position");
|
Vector2 target_position = node->get("target_position");
|
||||||
|
|
||||||
|
Vector2 gpoint = mb->get_position();
|
||||||
|
|
||||||
if (mb->is_pressed()) {
|
if (mb->is_pressed()) {
|
||||||
if (xform.xform(target_position).distance_to(mb->get_position()) < 8) {
|
if (xform.xform(target_position).distance_to(gpoint) < 8) {
|
||||||
pressed = true;
|
pressed = true;
|
||||||
original_target_position = target_position;
|
original_target_position = target_position;
|
||||||
|
original_mouse_pos = gpoint;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -77,6 +80,7 @@ bool Cast2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (pressed) {
|
} else if (pressed) {
|
||||||
|
if (original_mouse_pos != gpoint) {
|
||||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||||
undo_redo->create_action(TTR("Set Target Position"));
|
undo_redo->create_action(TTR("Set Target Position"));
|
||||||
undo_redo->add_do_property(node, "target_position", target_position);
|
undo_redo->add_do_property(node, "target_position", target_position);
|
||||||
|
@ -84,9 +88,9 @@ bool Cast2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
undo_redo->add_undo_property(node, "target_position", original_target_position);
|
undo_redo->add_undo_property(node, "target_position", original_target_position);
|
||||||
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
|
}
|
||||||
|
|
||||||
pressed = false;
|
pressed = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ class Cast2DEditor : public Control {
|
||||||
|
|
||||||
bool pressed = false;
|
bool pressed = false;
|
||||||
Point2 original_target_position;
|
Point2 original_target_position;
|
||||||
|
Vector2 original_mouse_pos;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
|
@ -326,6 +326,7 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
original_mouse_pos = gpoint;
|
||||||
original_point = handles[edit_handle];
|
original_point = handles[edit_handle];
|
||||||
original = get_handle_value(edit_handle);
|
original = get_handle_value(edit_handle);
|
||||||
original_transform = node->get_global_transform();
|
original_transform = node->get_global_transform();
|
||||||
|
@ -336,7 +337,9 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
|
if (original_mouse_pos != gpoint) {
|
||||||
commit_handle(edit_handle, original);
|
commit_handle(edit_handle, original);
|
||||||
|
}
|
||||||
|
|
||||||
edit_handle = -1;
|
edit_handle = -1;
|
||||||
pressed = false;
|
pressed = false;
|
||||||
|
|
|
@ -74,6 +74,7 @@ class CollisionShape2DEditor : public Control {
|
||||||
Transform2D original_transform;
|
Transform2D original_transform;
|
||||||
Vector2 original_point;
|
Vector2 original_point;
|
||||||
Point2 last_point;
|
Point2 last_point;
|
||||||
|
Vector2 original_mouse_pos;
|
||||||
|
|
||||||
Ref<Shape2D> current_shape;
|
Ref<Shape2D> current_shape;
|
||||||
|
|
||||||
|
|
|
@ -1870,7 +1870,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||||
surface->queue_redraw();
|
surface->queue_redraw();
|
||||||
} else {
|
} else {
|
||||||
if (_edit.gizmo.is_valid()) {
|
if (_edit.gizmo.is_valid()) {
|
||||||
|
if (_edit.original_mouse_pos != _edit.mouse_pos) {
|
||||||
_edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, false);
|
_edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, false);
|
||||||
|
}
|
||||||
_edit.gizmo = Ref<EditorNode3DGizmo>();
|
_edit.gizmo = Ref<EditorNode3DGizmo>();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1904,8 +1906,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
|
||||||
|
|
||||||
se->gizmo->commit_subgizmos(ids, restore, false);
|
se->gizmo->commit_subgizmos(ids, restore, false);
|
||||||
} else {
|
} else {
|
||||||
|
if (_edit.original_mouse_pos != _edit.mouse_pos) {
|
||||||
commit_transform();
|
commit_transform();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
_edit.mode = TRANSFORM_NONE;
|
_edit.mode = TRANSFORM_NONE;
|
||||||
set_message("");
|
set_message("");
|
||||||
spatial_editor->update_transform_gizmo();
|
spatial_editor->update_transform_gizmo();
|
||||||
|
|
|
@ -86,6 +86,8 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
if (mb->is_pressed() && action == ACTION_NONE) {
|
if (mb->is_pressed() && action == ACTION_NONE) {
|
||||||
Ref<Curve2D> curve = node->get_curve();
|
Ref<Curve2D> curve = node->get_curve();
|
||||||
|
|
||||||
|
original_mouse_pos = gpoint;
|
||||||
|
|
||||||
for (int i = 0; i < curve->get_point_count(); i++) {
|
for (int i = 0; i < curve->get_point_count(); i++) {
|
||||||
real_t dist_to_p = gpoint.distance_to(xform.xform(curve->get_point_position(i)));
|
real_t dist_to_p = gpoint.distance_to(xform.xform(curve->get_point_position(i)));
|
||||||
real_t dist_to_p_out = gpoint.distance_to(xform.xform(curve->get_point_position(i) + curve->get_point_out(i)));
|
real_t dist_to_p_out = gpoint.distance_to(xform.xform(curve->get_point_position(i) + curve->get_point_out(i)));
|
||||||
|
@ -224,6 +226,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
|
|
||||||
case ACTION_MOVING_POINT:
|
case ACTION_MOVING_POINT:
|
||||||
case ACTION_MOVING_NEW_POINT: {
|
case ACTION_MOVING_NEW_POINT: {
|
||||||
|
if (original_mouse_pos != gpoint) {
|
||||||
if (action == ACTION_MOVING_POINT) {
|
if (action == ACTION_MOVING_POINT) {
|
||||||
undo_redo->create_action(TTR("Move Point in Curve"));
|
undo_redo->create_action(TTR("Move Point in Curve"));
|
||||||
undo_redo->add_undo_method(curve.ptr(), "set_point_position", action_point, moving_from);
|
undo_redo->add_undo_method(curve.ptr(), "set_point_position", action_point, moving_from);
|
||||||
|
@ -232,10 +235,11 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
|
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
|
||||||
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
||||||
undo_redo->commit_action(false);
|
undo_redo->commit_action(false);
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case ACTION_MOVING_IN: {
|
case ACTION_MOVING_IN: {
|
||||||
|
if (original_mouse_pos != gpoint) {
|
||||||
undo_redo->create_action(TTR("Move In-Control in Curve"));
|
undo_redo->create_action(TTR("Move In-Control in Curve"));
|
||||||
undo_redo->add_do_method(curve.ptr(), "set_point_in", action_point, new_pos);
|
undo_redo->add_do_method(curve.ptr(), "set_point_in", action_point, new_pos);
|
||||||
undo_redo->add_undo_method(curve.ptr(), "set_point_in", action_point, moving_from);
|
undo_redo->add_undo_method(curve.ptr(), "set_point_in", action_point, moving_from);
|
||||||
|
@ -247,10 +251,11 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
|
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
|
||||||
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case ACTION_MOVING_OUT: {
|
case ACTION_MOVING_OUT: {
|
||||||
|
if (original_mouse_pos != gpoint) {
|
||||||
undo_redo->create_action(TTR("Move Out-Control in Curve"));
|
undo_redo->create_action(TTR("Move Out-Control in Curve"));
|
||||||
undo_redo->add_do_method(curve.ptr(), "set_point_out", action_point, new_pos);
|
undo_redo->add_do_method(curve.ptr(), "set_point_out", action_point, new_pos);
|
||||||
undo_redo->add_undo_method(curve.ptr(), "set_point_out", action_point, moving_from);
|
undo_redo->add_undo_method(curve.ptr(), "set_point_out", action_point, moving_from);
|
||||||
|
@ -262,7 +267,7 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
|
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
|
||||||
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
|
||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,7 @@ class Path2DEditor : public HBoxContainer {
|
||||||
float orig_in_length = 0.0f;
|
float orig_in_length = 0.0f;
|
||||||
float orig_out_length = 0.0f;
|
float orig_out_length = 0.0f;
|
||||||
Vector2 edge_point;
|
Vector2 edge_point;
|
||||||
|
Vector2 original_mouse_pos;
|
||||||
|
|
||||||
void _mode_selected(int p_mode);
|
void _mode_selected(int p_mode);
|
||||||
void _handle_option_pressed(int p_option);
|
void _handle_option_pressed(int p_option);
|
||||||
|
|
Loading…
Reference in New Issue