From 7519964b32998282bd75e91cad60106b35241c55 Mon Sep 17 00:00:00 2001 From: aXu-AP <1621768+aXu-AP@users.noreply.github.com> Date: Fri, 27 Oct 2023 20:34:25 +0300 Subject: [PATCH] Fix 2D bone weight editor not accounting for offset Skeleton was shown in wrong place in Polygon2D UV editor's bone painting mode. --- editor/plugins/polygon_2d_editor_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 37e38e1e6137..a33a90134264 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -1209,7 +1209,7 @@ void Polygon2DEditor::_uv_draw() { found_child = true; - Transform2D bone_xform = node->get_global_transform().affine_inverse() * (skeleton->get_global_transform() * bone->get_skeleton_rest()); + Transform2D bone_xform = node->get_global_transform().affine_inverse().translated(-node->get_offset()) * (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); @@ -1219,7 +1219,7 @@ void Polygon2DEditor::_uv_draw() { if (!found_child) { //draw normally - Transform2D bone_xform = node->get_global_transform().affine_inverse() * (skeleton->get_global_transform() * bone->get_skeleton_rest()); + Transform2D bone_xform = node->get_global_transform().affine_inverse().translated(-node->get_offset()) * (skeleton->get_global_transform() * bone->get_skeleton_rest()); Transform2D endpoint_xform = bone_xform * Transform2D(0, Vector2(bone->get_length(), 0)); Color color = current ? Color(1, 1, 1) : Color(0.5, 0.5, 0.5);