From 47cbeabb1182fbd964d8cbefb04d30a2ced6efc4 Mon Sep 17 00:00:00 2001 From: Chris Blackbourn Date: Mon, 22 May 2023 15:40:15 +1200 Subject: [PATCH] UV: Fix uv packing problem with rotate and scale line-search When rotation is enabled and doing a scale line-search (locked islands or "fraction" margin method), if the `rotate_inside_square` would result in a a tighter packing, the wrong scale value was being used, resulting in UVs outside of the unit square. Reported as #108037 "1. Use locked scale on after scaling UV..." --- source/blender/geometry/intern/uv_pack.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/geometry/intern/uv_pack.cc b/source/blender/geometry/intern/uv_pack.cc index 4363fa66492..1b27b7770cb 100644 --- a/source/blender/geometry/intern/uv_pack.cc +++ b/source/blender/geometry/intern/uv_pack.cc @@ -1150,12 +1150,12 @@ static bool rotate_inside_square(const Span island_indices, return false; /* Nothing to do. */ } - /* Transform phis. */ + /* Transform phis, rotate by best_angle, then translate back to the origin. No scale. */ for (const int64_t j : island_indices.index_range()) { const int64_t i = island_indices[j]->index; const PackIsland *island = islands[i]; - const float island_scale = island->can_scale_(params) ? scale : 1.0f; - island->build_transformation(island_scale, square_finder.best_angle, matrix); + const float identity_scale = 1.0f; /* Don't rescale the placement, just rotate. */ + island->build_transformation(identity_scale, square_finder.best_angle, matrix); r_phis[i].rotation += square_finder.best_angle; mul_m2_v2(matrix, r_phis[i].translation); r_phis[i].translation.x -= square_finder.best_bounds.xmin;