[Bf-extensions-cvs] [9bc76f9] master: LoopTools: Update panel Rename, Cleanup

lijenstina noreply at git.blender.org
Fri Apr 7 16:23:24 CEST 2017


Commit: 9bc76f9902e756c149695b2b3d86ebe2d690ae65
Author: lijenstina
Date:   Fri Apr 7 16:22:32 2017 +0200
Branches: master
https://developer.blender.org/rBA9bc76f9902e756c149695b2b3d86ebe2d690ae65

LoopTools: Update panel Rename, Cleanup

Bumped version to 4.6.7
As a part of the task T50726:
Update the Panel rename code to more generic one

PEP8 cleanup:
Tuple imports and use them for class types
Consistent Scene props definitions
Update url link

===================================================================

M	mesh_looptools.py

===================================================================

diff --git a/mesh_looptools.py b/mesh_looptools.py
index b05c783..e3fd302 100644
--- a/mesh_looptools.py
+++ b/mesh_looptools.py
@@ -19,12 +19,12 @@
 bl_info = {
     "name": "LoopTools",
     "author": "Bart Crouch",
-    "version": (4, 6, 6),
+    "version": (4, 6, 7),
     "blender": (2, 72, 2),
     "location": "View3D > Toolbar and View3D > Specials (W-key)",
     "warning": "",
     "description": "Mesh modelling toolkit. Several tools to aid modelling",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
                 "Scripts/Modeling/LoopTools",
     "category": "Mesh",
 }
@@ -36,12 +36,25 @@ import collections
 import mathutils
 import math
 from bpy_extras import view3d_utils
-
-
-##########################################
-####### General functions ################
-##########################################
-
+from bpy.types import (
+        Operator,
+        Menu,
+        Panel,
+        PropertyGroup,
+        AddonPreferences,
+        )
+from bpy.props import (
+        BoolProperty,
+        EnumProperty,
+        FloatProperty,
+        IntProperty,
+        PointerProperty,
+        StringProperty,
+        )
+
+# ########################################
+# ##### General functions ################
+# ########################################
 
 # used by all tools to improve speed on reruns Unlink
 looptools_cache = {}
@@ -73,8 +86,8 @@ def cache_read(tool, object, bm, input_method, boundaries):
         return(False, False, False, False, False)
     if boundaries != looptools_cache[tool]["boundaries"]:
         return(False, False, False, False, False)
-    modifiers = [mod.name for mod in object.modifiers if mod.show_viewport \
-        and mod.type == 'MIRROR']
+    modifiers = [mod.name for mod in object.modifiers if mod.show_viewport and
+                 mod.type == 'MIRROR']
     if modifiers != looptools_cache[tool]["modifiers"]:
         return(False, False, False, False, False)
     input = [v.index for v in bm.verts if v.select and not v.hide]
@@ -97,8 +110,8 @@ loops, derived, mapping):
         del looptools_cache[tool]
     # prepare values to be saved to cache
     input = [v.index for v in bm.verts if v.select and not v.hide]
-    modifiers = [mod.name for mod in object.modifiers if mod.show_viewport \
-        and mod.type == 'MIRROR']
+    modifiers = [mod.name for mod in object.modifiers if mod.show_viewport and
+                 mod.type == 'MIRROR']
     # update cache
     looptools_cache[tool] = {"input": input, "object": object.name,
         "input_method": input_method, "boundaries": boundaries,
@@ -115,12 +128,12 @@ def calculate_cubic_splines(bm_mod, tknots, knots):
         for k in range(-1, -5, -1):
             if k - 1 < -len(knots):
                 k += len(knots)
-            k_new1.append(knots[k-1])
+            k_new1.append(knots[k - 1])
         k_new2 = []
         for k in range(4):
             if k + 1 > len(knots) - 1:
                 k -= len(knots)
-            k_new2.append(knots[k+1])
+            k_new2.append(knots[k + 1])
         for k in k_new1:
             knots.insert(0, k)
         for k in k_new2:
@@ -130,14 +143,14 @@ def calculate_cubic_splines(bm_mod, tknots, knots):
         for t in range(-1, -5, -1):
             if t - 1 < -len(tknots):
                 t += len(tknots)
-            total1 += tknots[t] - tknots[t-1]
+            total1 += tknots[t] - tknots[t - 1]
             t_new1.append(tknots[0] - total1)
         t_new2 = []
         total2 = 0
         for t in range(4):
             if t + 1 > len(tknots) - 1:
                 t -= len(tknots)
-            total2 += tknots[t+1] - tknots[t]
+            total2 += tknots[t + 1] - tknots[t]
             t_new2.append(tknots[-1] + total2)
         for t in t_new1:
             tknots.insert(0, t)
@@ -158,39 +171,39 @@ def calculate_cubic_splines(bm_mod, tknots, knots):
         for i in locs:
             a.append(i[j])
         h = []
-        for i in range(n-1):
-            if x[i+1] - x[i] == 0:
+        for i in range(n - 1):
+            if x[i + 1] - x[i] == 0:
                 h.append(1e-8)
             else:
-                h.append(x[i+1] - x[i])
+                h.append(x[i + 1] - x[i])
         q = [False]
-        for i in range(1, n-1):
-            q.append(3/h[i]*(a[i+1]-a[i]) - 3/h[i-1]*(a[i]-a[i-1]))
+        for i in range(1, n - 1):
+            q.append(3 / h[i] * (a[i + 1] - a[i]) - 3 / h[i - 1] * (a[i] - a[i - 1]))
         l = [1.0]
         u = [0.0]
         z = [0.0]
-        for i in range(1, n-1):
-            l.append(2*(x[i+1]-x[i-1]) - h[i-1]*u[i-1])
+        for i in range(1, n - 1):
+            l.append(2 * (x[i + 1] - x[i - 1]) - h[i - 1] * u[i - 1])
             if l[i] == 0:
                 l[i] = 1e-8
             u.append(h[i] / l[i])
-            z.append((q[i] - h[i-1] * z[i-1]) / l[i])
+            z.append((q[i] - h[i - 1] * z[i - 1]) / l[i])
         l.append(1.0)
         z.append(0.0)
-        b = [False for i in range(n-1)]
+        b = [False for i in range(n - 1)]
         c = [False for i in range(n)]
-        d = [False for i in range(n-1)]
-        c[n-1] = 0.0
-        for i in range(n-2, -1, -1):
-            c[i] = z[i] - u[i]*c[i+1]
-            b[i] = (a[i+1]-a[i])/h[i] - h[i]*(c[i+1]+2*c[i])/3
-            d[i] = (c[i+1]-c[i]) / (3*h[i])
-        for i in range(n-1):
+        d = [False for i in range(n - 1)]
+        c[n - 1] = 0.0
+        for i in range(n - 2, -1, -1):
+            c[i] = z[i] - u[i] * c[i + 1]
+            b[i] = (a[i + 1] - a[i]) / h[i] - h[i] * (c[i + 1] + 2 * c[i]) / 3
+            d[i] = (c[i + 1] - c[i]) / (3 * h[i])
+        for i in range(n - 1):
             result.append([a[i], b[i], c[i], d[i], x[i]])
     splines = []
-    for i in range(len(knots)-1):
-        splines.append([result[i], result[i+n-1], result[i+(n-1)*2]])
-    if circular: # cleaning up after hack
+    for i in range(len(knots) - 1):
+        splines.append([result[i], result[i + n - 1], result[i + (n - 1) * 2]])
+    if circular:  # cleaning up after hack
         knots = knots[4:-4]
         tknots = tknots[4:-4]
 
@@ -200,13 +213,13 @@ def calculate_cubic_splines(bm_mod, tknots, knots):
 # calculates linear splines through all given knots
 def calculate_linear_splines(bm_mod, tknots, knots):
     splines = []
-    for i in range(len(knots)-1):
+    for i in range(len(knots) - 1):
         a = bm_mod.verts[knots[i]].co
-        b = bm_mod.verts[knots[i+1]].co
-        d = b-a
+        b = bm_mod.verts[knots[i + 1]].co
+        d = b - a
         t = tknots[i]
-        u = tknots[i+1]-t
-        splines.append([a, d, t, u]) # [locStart, locDif, tStart, tDif]
+        u = tknots[i + 1] - t
+        splines.append([a, d, t, u])  # [locStart, locDif, tStart, tDif]
 
     return(splines)
 
@@ -230,15 +243,15 @@ def calculate_plane(bm_mod, loop, method="best_fit", object=False):
                                 (0.0, 0.0, 0.0),
                                 ))
         for loc in locs:
-            mat[0][0] += (loc[0]-x)**2
-            mat[1][0] += (loc[0]-x)*(loc[1]-y)
-            mat[2][0] += (loc[0]-x)*(loc[2]-z)
-            mat[0][1] += (loc[1]-y)*(loc[0]-x)
-            mat[1][1] += (loc[1]-y)**2
-            mat[2][1] += (loc[1]-y)*(loc[2]-z)
-            mat[0][2] += (loc[2]-z)*(loc[0]-x)
-            mat[1][2] += (loc[2]-z)*(loc[1]-y)
-            mat[2][2] += (loc[2]-z)**2
+            mat[0][0] += (loc[0] - x) ** 2
+            mat[1][0] += (loc[0] - x) * (loc[1] - y)
+            mat[2][0] += (loc[0] - x) * (loc[2] - z)
+            mat[0][1] += (loc[1] - y) * (loc[0] - x)
+            mat[1][1] += (loc[1] - y) ** 2
+            mat[2][1] += (loc[1] - y) * (loc[2] - z)
+            mat[0][2] += (loc[2] - z) * (loc[0] - x)
+            mat[1][2] += (loc[2] - z) * (loc[1] - y)
+            mat[2][2] += (loc[2] - z) ** 2
 
         # calculating the normal to the plane
         normal = False
@@ -297,7 +310,7 @@ def calculate_plane(bm_mod, loop, method="best_fit", object=False):
 def calculate_splines(interpolation, bm_mod, tknots, knots):
     if interpolation == 'cubic':
         splines = calculate_cubic_splines(bm_mod, tknots, knots[:])
-    else: # interpolations == 'linear'
+    else:  # interpolations == 'linear'
         splines = calculate_linear_splines(bm_mod, tknots, knots[:])
 
     return(splines)
@@ -322,8 +335,7 @@ def check_loops(loops, mapping, bm_mod):
         # vertices can not all be at the same location
         stacked = True
         for i in range(len(loop) - 1):
-            if (bm_mod.verts[loop[i]].co - \
-            bm_mod.verts[loop[i+1]].co).length > 1e-6:
+            if (bm_mod.verts[loop[i]].co - bm_mod.verts[loop[i + 1]].co).length > 1e-6:
                 stacked = False
                 break
         if stacked:
@@ -336,8 +348,7 @@ def check_loops(loops, mapping, bm_mod):
 
 # input: bmesh, output: dict with the edge-key as key and face-index as value
 def dict_edge_faces(bm):
-    edge_faces = dict([[edgekey(edge), []] for edge in bm.edges if \
-        not edge.hide])
+    edge_faces = dict([[edgekey(edge), []] for edge in bm.edges if not edge.hide])
     for face in bm.faces:
         if face.hide:
             continue
@@ -352,8 +363,7 @@ def dict_face_faces(bm, edge_faces=False):
     if not edge_faces:
         edge_faces = dict_edge_faces(bm)
 
-    connected_faces = dict([[face.index, []] for face in bm.faces if \
-        not face.hide])
+    connected_faces = dict([[face.index, []] for face in bm.faces if not face.hide])
     for face in bm.faces:
         if face.hide:
             continue
@@ -397,9 +407,9 @@ def dict_vert_verts(edge_keys):
     for ek in edge_keys:
         for i in range(2):
             if ek[i] in vert_verts:
-                vert_verts[ek[i]].append(ek[1-i])
+                vert_verts[ek[i]].append(ek[1 - i])
             else:
-                vert_verts[ek[i]] = [ek[1-i]]
+                vert_verts[ek[i]] = [ek[1 - i]]
 
     return(vert_verts)
 
@@ -411,8 +421,7 @@ def edgekey(edge):
 
 # returns the edgekeys of a bmesh face
 def face_edgekeys(face):
-    ret

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list