[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15012] branches/apricot/release/scripts/ uvcalc_lightmap.py: fixes from trunk

Campbell Barton ideasman42 at gmail.com
Tue May 27 17:15:50 CEST 2008


Revision: 15012
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15012
Author:   campbellbarton
Date:     2008-05-27 17:15:50 +0200 (Tue, 27 May 2008)

Log Message:
-----------
fixes from trunk

Modified Paths:
--------------
    branches/apricot/release/scripts/uvcalc_lightmap.py

Modified: branches/apricot/release/scripts/uvcalc_lightmap.py
===================================================================
--- branches/apricot/release/scripts/uvcalc_lightmap.py	2008-05-27 15:14:35 UTC (rev 15011)
+++ branches/apricot/release/scripts/uvcalc_lightmap.py	2008-05-27 15:15:50 UTC (rev 15012)
@@ -41,6 +41,12 @@
 
 from math import sqrt
 
+def AngleBetweenVecs(a1,a2):
+	try:
+		return Mathutils.AngleBetweenVecs(a1,a2)
+	except:
+		return 180.0
+
 class prettyface(object):
 	__slots__ = 'uv', 'width', 'height', 'children', 'xoff', 'yoff', 'has_parent', 'rot', 'noarea'
 	def __init__(self, data, noarea = False):
@@ -157,9 +163,9 @@
 		if len(uv) == 2:
 			# match the order of angle sizes of the 3d verts with the UV angles and rotate.
 			def get_tri_angles(v1,v2,v3):
-				a1= Mathutils.AngleBetweenVecs(v2-v1,v3-v1)
-				a2= Mathutils.AngleBetweenVecs(v1-v2,v3-v2)
-				a3 = 180 - (a1+a2) #a3= Mathutils.AngleBetweenVecs(v2-v3,v1-v3)
+				a1= AngleBetweenVecs(v2-v1,v3-v1)
+				a2= AngleBetweenVecs(v1-v2,v3-v2)
+				a3 = 180 - (a1+a2) #a3= AngleBetweenVecs(v2-v3,v1-v3)
 				
 				
 				return [(a1,0),(a2,1),(a3,2)]
@@ -255,8 +261,17 @@
 			face_groups.append(faces)
 		
 		if PREF_NEW_UVLAYER:
-			me.addUVLayer('lightmap')
-			me.activeUVLayer = 'lightmap'
+			uvname_org = uvname = 'lightmap'
+			uvnames = me.getUVLayerNames()
+			i = 1
+			while uvname in uvnames:
+				uvname = '%s.%03d' % (uvname_org, i)
+				i+=1
+			
+			me.addUVLayer(uvname)
+			me.activeUVLayer = uvname
+			
+			del uvnames, uvname_org, uvname
 		
 		
 	if PREF_PACK_TO_MANY and len(face_groups[0]) < 4:
@@ -425,9 +440,7 @@
 		
 		if not lengths:
 			lengths.append(curr_len)
-
 		
-		
 		# convert into ints
 		lengths_to_ints = {}
 		
@@ -500,11 +513,14 @@
 		# ...limiting this is needed or you end up with bug unused texture spaces
 		# ...however if its too high, boxpacking is way too slow for high poly meshes.
 		float_to_int_factor = lengths_to_ints[0][0]
-		max_int_dimension = int(((side_len / float_to_int_factor)) / PREF_BOX_DIV)
+		if float_to_int_factor > 0:
+			max_int_dimension = int(((side_len / float_to_int_factor)) / PREF_BOX_DIV)
+			ok = True
+		else:
+			max_int_dimension = 0.0 # wont be used
+			ok = False
 		
-		
 		# RECURSIVE prettyface grouping
-		ok = True
 		while ok:
 			ok = False
 			





More information about the Bf-blender-cvs mailing list