From 5b3c0a502c239c671ee1d641c00f14e6e8cca275 Mon Sep 17 00:00:00 2001 From: Zaven Muradyan Date: Wed, 26 Oct 2016 23:18:18 -0700 Subject: Add the ability to delete bezier path handles. --- editor/plugins/path_editor_plugin.cpp | 44 +++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'editor/plugins/path_editor_plugin.cpp') 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;iget_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)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; + } } } -- cgit v1.2.3