diff options
| author | Juan Linietsky | 2015-11-18 18:19:50 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2015-11-18 18:19:50 -0300 |
| commit | 5360e34c822892c9529c32033b8580dd2dff0d4d (patch) | |
| tree | 886a2d79b939e9d1365a90a1b3faa1dae8e40d56 /tools/editor/plugins/collision_shape_2d_editor_plugin.cpp | |
| parent | b08312b30c5fa47bffc2d21d4cb57520b822bf45 (diff) | |
| parent | 0b05739a8ba7b0181f7f596a4813058ba3a0cb3b (diff) | |
| download | godot-5360e34c822892c9529c32033b8580dd2dff0d4d.tar.gz godot-5360e34c822892c9529c32033b8580dd2dff0d4d.tar.zst godot-5360e34c822892c9529c32033b8580dd2dff0d4d.zip | |
Merge pull request #2808 from Ovnuniarchos/ShapeLine2DXPolygonEditor
2D shapes editor update
Diffstat (limited to 'tools/editor/plugins/collision_shape_2d_editor_plugin.cpp')
| -rw-r--r-- | tools/editor/plugins/collision_shape_2d_editor_plugin.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp index 62cf1b4ac..f56b9a2fd 100644 --- a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -115,6 +115,18 @@ void CollisionShape2DEditor::set_handle(int idx, Point2& p_point) { } break; case LINE_SHAPE: { + if (idx<2) { + Ref<LineShape2D> line = node->get_shape(); + + if (idx==0){ + line->set_d(p_point.length()); + }else{ + line->set_normal(p_point/30.0); + } + + canvas_item_editor->get_viewport_control()->update(); + } + } break; @@ -200,6 +212,19 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant& p_org) { } break; case LINE_SHAPE: { + Ref<LineShape2D> line = node->get_shape(); + + if (idx==0) { + undo_redo->add_do_method(line.ptr(),"set_d",line->get_d()); + undo_redo->add_do_method(c,"update"); + undo_redo->add_undo_method(line.ptr(),"set_d",p_org); + undo_redo->add_undo_method(c,"update"); + } else { + undo_redo->add_do_method(line.ptr(),"set_normal",line->get_normal()); + undo_redo->add_do_method(c,"update"); + undo_redo->add_undo_method(line.ptr(),"set_normal",p_org); + undo_redo->add_undo_method(c,"update"); + } } break; @@ -418,6 +443,14 @@ void CollisionShape2DEditor::_canvas_draw() { } break; case LINE_SHAPE: { + Ref<LineShape2D> shape = node->get_shape(); + + handles.resize(2); + handles[0] = shape->get_normal() * shape->get_d(); + handles[1] = shape->get_normal() * (shape->get_d() + 30.0); + + c->draw_texture(h,gt.xform(handles[0])-size); + c->draw_texture(h,gt.xform(handles[1])-size); } break; |
