[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2660] trunk/py/scripts/addons/ mesh_looptools.py: Replacing custom code with mathutils normalize()

Bart Crouch bartius.crouch at gmail.com
Sat Nov 26 12:46:18 CET 2011


Revision: 2660
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2660
Author:   crouch
Date:     2011-11-26 11:46:13 +0000 (Sat, 26 Nov 2011)
Log Message:
-----------
Replacing custom code with mathutils normalize()

Modified Paths:
--------------
    trunk/py/scripts/addons/mesh_looptools.py

Modified: trunk/py/scripts/addons/mesh_looptools.py
===================================================================
--- trunk/py/scripts/addons/mesh_looptools.py	2011-11-26 10:24:22 UTC (rev 2659)
+++ trunk/py/scripts/addons/mesh_looptools.py	2011-11-26 11:46:13 UTC (rev 2660)
@@ -19,9 +19,9 @@
 bl_info = {
     'name': "LoopTools",
     'author': "Bart Crouch",
-    'version': (3, 2, 1),
+    'version': (3, 2, 2),
     'blender': (2, 6, 0),
-    'api': 41270,
+    'api': 42162,
     'location': "View3D > Toolbar and View3D > Specials (W-key)",
     'warning': "",
     'description': "Mesh modelling toolkit. Several tools to aid modelling",
@@ -244,19 +244,12 @@
             elif sum(mat[2]) == 0.0:
                 normal = mathutils.Vector((0.0, 0.0, 1.0))
         if not normal:
-            itermax = 500
-            iter = 0
             vec = mathutils.Vector((1.0, 1.0, 1.0))
-            vec2 = (mat * vec)/(mat * vec).length
-            while vec != vec2 and iter<itermax:
-                iter+=1
-                vec = vec2
-                vec2 = mat * vec
-                if vec2.length != 0:
-                    vec2 /= vec2.length
-            if vec2.length == 0:
-                vec2 = mathutils.Vector((1.0, 1.0, 1.0))
-            normal = vec2
+            normal = (mat * vec)/(mat * vec).length
+            if normal.length == 0:
+                normal = vec
+            else:
+                normal.normalize()
     
     elif method == 'normal':
         # averaging the vertex normals
@@ -933,19 +926,12 @@
             elif sum(mat[2]) == 0:
                 normal = mathutils.Vector((0.0, 0.0, 1.0))
         if not normal:
-            itermax = 500
-            iter = 0
             vec = mathutils.Vector((1.0, 1.0, 1.0))
-            vec2 = (mat * vec)/(mat * vec).length
-            while vec != vec2 and iter<itermax:
-                iter+=1
-                vec = vec2
-                vec2 = mat * vec
-                if vec2.length != 0:
-                    vec2 /= vec2.length
-            if vec2.length == 0:
-                vec2 = mathutils.Vector((1.0, 1.0, 1.0))
-            normal = vec2
+            normal = (mat * vec)/(mat * vec).length
+            if normal.length == 0:
+                normal = vec
+            else:
+                normal.normalize()
         normals.append(normal)
     # have plane normals face in the same direction (maximum angle: 90 degrees)
     if ((center1 + normals[0]) - center2).length < \



More information about the Bf-extensions-cvs mailing list