summaryrefslogtreecommitdiff
path: root/editor/plugins/path_editor_plugin.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-05-18 14:02:30 +0200
committerGitHub <noreply@github.com>2017-05-18 14:02:30 +0200
commit1877a31a860a6fadf0f14d15098a359f80457883 (patch)
tree92289d219acd0adf7a67acb42239b9f185c94504 /editor/plugins/path_editor_plugin.cpp
parentc2854381b3250d4067ec051f7b8f198f4e414bf2 (diff)
parent5b3c0a502c239c671ee1d641c00f14e6e8cca275 (diff)
Merge pull request #6941 from voithos/bezier-handle-deletion-shortcut
Add the ability to delete bezier path handles.
Diffstat (limited to 'editor/plugins/path_editor_plugin.cpp')
-rw-r--r--editor/plugins/path_editor_plugin.cpp44
1 files changed, 29 insertions, 15 deletions
diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp
index 9c95cee388..9e18a5c4c5 100644
--- a/editor/plugins/path_editor_plugin.cpp
+++ b/editor/plugins/path_editor_plugin.cpp
@@ -407,24 +407,38 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera* p_camera,const InputEve
} else if (mb.pressed && ((mb.button_index==BUTTON_LEFT && curve_del->is_pressed()) || (mb.button_index==BUTTON_RIGHT && curve_edit->is_pressed()))) {
- int erase_idx=-1;
for(int i=0;i<c->get_point_count();i++) {
- //find the offset and point index of the place to break up
- if (p_camera->unproject_position(gt.xform(c->get_point_pos(i))).distance_to(mbpos)<click_dist) {
-
- erase_idx=i;
- break;
- }
- }
+ real_t dist_to_p = p_camera->unproject_position(gt.xform(c->get_point_pos(i))).distance_to(mbpos);
+ real_t dist_to_p_out = p_camera->unproject_position(gt.xform(c->get_point_pos(i) + c->get_point_out(i))).distance_to(mbpos);
+ real_t dist_to_p_in = p_camera->unproject_position(gt.xform(c->get_point_pos(i) + c->get_point_in(i))).distance_to(mbpos);
+
+ // Find the offset and point index of the place to break up.
+ // Also check for the control points.
+ if (dist_to_p < click_dist) {
+
+ UndoRedo *ur = editor->get_undo_redo();
+ ur->create_action(TTR("Remove Path Point"));
+ ur->add_do_method(c.ptr(),"remove_point",i);
+ ur->add_undo_method(c.ptr(),"add_point",c->get_point_pos(i),c->get_point_in(i),c->get_point_out(i),i);
+ ur->commit_action();
+ return true;
+ } else if (dist_to_p_out < click_dist) {
- if (erase_idx!=-1) {
+ UndoRedo *ur = editor->get_undo_redo();
+ ur->create_action(TTR("Remove Out-Control Point"));
+ ur->add_do_method(c.ptr(),"set_point_out",i,Vector3());
+ ur->add_undo_method(c.ptr(),"set_point_out",i,c->get_point_out(i));
+ ur->commit_action();
+ return true;
+ } else if (dist_to_p_in < click_dist) {
- UndoRedo *ur = editor->get_undo_redo();
- ur->create_action(TTR("Remove Path Point"));
- ur->add_do_method(c.ptr(),"remove_point",erase_idx);
- ur->add_undo_method(c.ptr(),"add_point",c->get_point_pos(erase_idx),c->get_point_in(erase_idx),c->get_point_out(erase_idx),erase_idx);
- ur->commit_action();
- return true;
+ UndoRedo *ur = editor->get_undo_redo();
+ ur->create_action(TTR("Remove In-Control Point"));
+ ur->add_do_method(c.ptr(),"set_point_in",i,Vector3());
+ ur->add_undo_method(c.ptr(),"set_point_in",i,c->get_point_in(i));
+ ur->commit_action();
+ return true;
+ }
}
}