diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-03 15:03:53 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-03 15:03:53 +0400 |
commit | 0ebade55fcef5acb9b5e34dbc7cc5ab2a4a3d964 (patch) | |
tree | 23d3c2e3c7d7a35bf17f5ba23340a03fff45bdba /release/scripts/startup/bl_operators/uvcalc_smart_project.py | |
parent | 5770d691bbed31d05ecf22383f56df2a4371acfa (diff) |
Fix T37509: regression in smart-uv island orientation
Diffstat (limited to 'release/scripts/startup/bl_operators/uvcalc_smart_project.py')
-rw-r--r-- | release/scripts/startup/bl_operators/uvcalc_smart_project.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index 70df5a9df21..1a8bd44e846 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -232,17 +232,28 @@ def islandIntersectUvIsland(source, target, SourceOffset): return 0 # NO INTERSECTION +def rotate_uvs(uv_points, angle): + + if angle != 0.0: + mat = Matrix.Rotation(angle, 2) + for uv in uv_points: + uv[:] = mat * uv + + def optiRotateUvIsland(faces): uv_points = [uv for f in faces for uv in f.uv] angle = geometry.box_fit_2d(uv_points) if angle != 0.0: - mat = Matrix.Rotation(angle, 2) - i = 0 # count the serialized uv/vectors - for f in faces: - for j, k in enumerate(range(i, len(f.v) + i)): - f.uv[j][:] = mat * uv_points[k] - i += len(f.v) + rotate_uvs(uv_points, angle) + + # orient them vertically (could be an option) + minx, miny, maxx, maxy = boundsIsland(faces) + w, h = maxx - minx, maxy - miny + if h < w: + from math import pi + angle = pi / 2.0 + rotate_uvs(uv_points, angle) # Takes an island list and tries to find concave, hollow areas to pack smaller islands into. |