diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-11-22 22:22:16 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2018-11-22 22:23:19 -0300 |
commit | cdafb7bce2f0c9961cd84453b471345fe10c3043 (patch) | |
tree | 486984ba56852b2cf631bea33a374ccd42f6d680 /editor/plugins | |
parent | 1c169413ffb8a5d446caaa41cc604bbf0cb6cc40 (diff) |
Properly show 2D bone previews in 2D skeleton UV editor, fixes #20950
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/polygon_2d_editor_plugin.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index f937744d45..45268d8c8d 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -963,22 +963,32 @@ void Polygon2DEditor::_uv_draw() { bool current = bone_path == skeleton->get_path_to(bone); + bool found_child = false; + for (int j = 0; j < bone->get_child_count(); j++) { - Node2D *n = Object::cast_to<Node2D>(bone->get_child(j)); + Bone2D *n = Object::cast_to<Bone2D>(bone->get_child(j)); if (!n) continue; - bool edit_bone = n->has_meta("_edit_bone_") && n->get_meta("_edit_bone_"); - if (edit_bone) { + found_child = true; - Transform2D bone_xform = node->get_global_transform().affine_inverse() * (skeleton->get_global_transform() * bone->get_skeleton_rest()); - Transform2D endpoint_xform = bone_xform * n->get_transform(); + Transform2D bone_xform = node->get_global_transform().affine_inverse() * (skeleton->get_global_transform() * bone->get_skeleton_rest()); + Transform2D endpoint_xform = bone_xform * n->get_transform(); - Color color = current ? Color(1, 1, 1) : Color(0.5, 0.5, 0.5); - uv_edit_draw->draw_line(mtx.xform(bone_xform.get_origin()), mtx.xform(endpoint_xform.get_origin()), Color(0, 0, 0), current ? 5 : 4); - uv_edit_draw->draw_line(mtx.xform(bone_xform.get_origin()), mtx.xform(endpoint_xform.get_origin()), color, current ? 3 : 2); - } + Color color = current ? Color(1, 1, 1) : Color(0.5, 0.5, 0.5); + uv_edit_draw->draw_line(mtx.xform(bone_xform.get_origin()), mtx.xform(endpoint_xform.get_origin()), Color(0, 0, 0), current ? 5 : 4); + uv_edit_draw->draw_line(mtx.xform(bone_xform.get_origin()), mtx.xform(endpoint_xform.get_origin()), color, current ? 3 : 2); + } + + if (!found_child) { + //draw normally + Transform2D bone_xform = node->get_global_transform().affine_inverse() * (skeleton->get_global_transform() * bone->get_skeleton_rest()); + Transform2D endpoint_xform = bone_xform * Transform2D(0, Vector2(bone->get_default_length(), 0)); + + Color color = current ? Color(1, 1, 1) : Color(0.5, 0.5, 0.5); + uv_edit_draw->draw_line(mtx.xform(bone_xform.get_origin()), mtx.xform(endpoint_xform.get_origin()), Color(0, 0, 0), current ? 5 : 4); + uv_edit_draw->draw_line(mtx.xform(bone_xform.get_origin()), mtx.xform(endpoint_xform.get_origin()), color, current ? 3 : 2); } } } |