From 31ce1435698f700a04fbd97e6cdbc0d4941c40b4 Mon Sep 17 00:00:00 2001 From: Chris Blackbourn Date: Fri, 9 Jun 2023 15:09:32 +1200 Subject: [PATCH] Fix #108786: Logic errors with pinned islands inside uv packer Pinning information was accidentally skipped inside of the UV packing engine because of their ordering. This was most noticeable when using the "Bounding Box" shape method, causing some pinned islands to be moved when they should have been locked in place. --- source/blender/geometry/intern/uv_pack.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/geometry/intern/uv_pack.cc b/source/blender/geometry/intern/uv_pack.cc index 77d769f5862..745c775f048 100644 --- a/source/blender/geometry/intern/uv_pack.cc +++ b/source/blender/geometry/intern/uv_pack.cc @@ -1781,7 +1781,7 @@ static float pack_islands_scale_margin(const Span islands, rctf locked_bounds = {0.0f}; /* AABB of islands which can't translate. */ int64_t locked_island_count = 0; /* Index of first non-locked island. */ for (int64_t i = 0; i < islands.size(); i++) { - PackIsland *pack_island = islands[i]; + PackIsland *pack_island = islands[aabbs[i]->index]; if (pack_island->can_translate_(params)) { break; } @@ -1794,6 +1794,12 @@ static float pack_islands_scale_margin(const Span islands, } float2 top_right = pack_island->pivot_ + pack_island->half_diagonal_; BLI_rctf_do_minmax_v(&locked_bounds, top_right); + + uv_phi &phi = r_phis[aabbs[i]->index]; /* Lock in place. */ + phi.translation = pack_island->pivot_; + sub_v2_v2(phi.translation, params.udim_base_offset); + phi.rotation = 0.0f; + locked_island_count = i + 1; }