[Bf-blender-cvs] [0ebade5] master: Fix T37509: regression in smart-uv island orientation
Campbell Barton
noreply at git.blender.org
Thu Apr 3 13:04:56 CEST 2014
Commit: 0ebade55fcef5acb9b5e34dbc7cc5ab2a4a3d964
Author: Campbell Barton
Date: Thu Apr 3 22:03:53 2014 +1100
https://developer.blender.org/rB0ebade55fcef5acb9b5e34dbc7cc5ab2a4a3d964
Fix T37509: regression in smart-uv island orientation
===================================================================
M release/scripts/startup/bl_operators/uvcalc_smart_project.py
===================================================================
diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py
index 70df5a9..1a8bd44 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.
More information about the Bf-blender-cvs
mailing list