[Bf-extensions-cvs] [be067588] master: Skinify Rig: Cleanup

lijenstina noreply at git.blender.org
Wed Jul 12 22:24:23 CEST 2017


Commit: be06758806159fa4f6a0b0c8e750f11890a2274a
Author: lijenstina
Date:   Wed Jul 12 22:23:43 2017 +0200
Branches: master
https://developer.blender.org/rBAbe06758806159fa4f6a0b0c8e750f11890a2274a

Skinify Rig: Cleanup

Bumped version to 0.9.1
Pep8 cleanup
Strip trailing empty spaces
No other functional changes

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

M	object_skinify.py

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

diff --git a/object_skinify.py b/object_skinify.py
index c62466f2..4a0b503e 100644
--- a/object_skinify.py
+++ b/object_skinify.py
@@ -19,7 +19,7 @@
 bl_info = {
     "name": "Skinify Rig",
     "author": "Albert Makac (karab44)",
-    "version": (0, 9, 0),
+    "version": (0, 9, 1),
     "blender": (2, 7, 9),
     "location": "Properties > Bone > Skinify Rig (visible on pose mode only)",
     "description": "Creates a mesh object from selected bones",
@@ -104,11 +104,13 @@ pitchipoy_data = \
 rigify_data = horse_data, shark_data, bird_data, cat_data, biped_data, human_data, \
               wolf_data, quadruped_data, human_legacy_data, pitchipoy_data
 
-#Skin.rig_type.ENUM
-#Skin.junction_dict['bname'].data[0] idx, data[1] idx +1, data[2] thicnkess
-#NOTE each fragment contains section information about adequate bone junctions idx and idx + 1 and these vertices' ids share common thickness
+
+# Skin.rig_type.ENUM
+# Skin.junction_dict['bname'].data[0] idx, data[1] idx + 1, data[2] thickness
+# NOTE each fragment contains section information about adequate bone
+# junctions idx and idx + 1 and these vertices' ids share common thickness
 class Skin(object):
-    
+
     class Rig_type(Enum):
         HORSE = 0
         SHARK = 1
@@ -121,31 +123,31 @@ class Skin(object):
         LEGACY = 8
         PITCHIPOY = 9
         OTHER = 10
-    
+
     def __init__(self, rig_type):
         self.rig_type = rig_type
         self.junctions_dict = dict()
-         
-            
-    def fragment_create(self, bname, idx = None, thickness = 0.0):
+
+    def fragment_create(self, bname, idx=None, thickness=0.0):
         data = []
         data.insert(0, idx)
-        
-        if idx != None:
+
+        if idx is not None:
             data.insert(1, idx + 1)
         else:
-            data.insert(1, None)            
-            
+            data.insert(1, None)
+
         self.junctions_dict[bname] = data
         self.junctions_dict[bname].append(thickness)
-   
-    #for the sake of code clarity     
-    def fragment_update(self, bname, idx = None, thickness = 0.0):
+
+    # for the sake of code clarity
+    def fragment_update(self, bname, idx=None, thickness=0.0):
         self.fragment_create(bname, idx, thickness)
-        
+
 
 rig_type = Skin.Rig_type.OTHER
 
+
 # initialize properties
 def init_props():
     # additional check - this should be a rare case if the handler
@@ -190,11 +192,11 @@ def identify_rig():
 
     return Skin.Rig_type.OTHER
 
-#prepares customizable ignore and thickness lists
+
+# prepares customizable ignore and thickness lists
 # edit these lists to suits your taste
 def prepare_lists(rig_type, finger_thickness):
-    
-  
+
     # EXAMPLE IGNORE LIST
     # detect the head, face, hands, breast, heels or other exceptionary bones for exclusion or customization
     common_ignore_list = ['eye', 'heel', 'breast', 'root']
@@ -227,28 +229,28 @@ def prepare_lists(rig_type, finger_thickness):
             'lid', 'forehead', 'temple', 'cheek', 'teeth', 'tongue'
             ]
     other_ignore_list = []
-    
+
     # EXAMPLE THICKNESS
-    # feel free to modify and customize the list by adding elements followed by comma common_thickness_dict = {"hand": common_finger_thickness, "head": common_head_thickness}  
-    common_finger_thickness = finger_thickness  
-    common_thickness_dict = {"hand": common_finger_thickness}   
+    # feel free to modify and customize the list by adding elements followed by comma
+    # common_thickness_dict = {"hand": common_finger_thickness, "head": common_head_thickness}
+    common_finger_thickness = finger_thickness
+    common_thickness_dict = {"hand": common_finger_thickness}
     horse_thickness_dict = {}
     shark_thickness_dict = {}
     bird_thickness_dict = {}
     cat_thickness_dict = {}
-    face_thickness = 0.20    
-    biped_thickness_dict = {}   
-    human_thickness_dict = {"face": face_thickness}   
+    face_thickness = 0.20
+    biped_thickness_dict = {}
+    human_thickness_dict = {"face": face_thickness}
     wolf_thickness_dict = {}
-    quad_thickness_dict = {}       
-    rigify_legacy_thickness_dict = {} 
+    quad_thickness_dict = {}
+    rigify_legacy_thickness_dict = {}
     pitchipoy_thickness_dict = {"face": face_thickness}
     other_thickness_dict = {}
 
-    
-    #combine lists depending on rig type
+    # combine lists depending on rig type
     ignore_list = common_ignore_list
-    thickness_dict = common_thickness_dict       
+    thickness_dict = common_thickness_dict
     if rig_type == Skin.Rig_type.HORSE:
         ignore_list = ignore_list + horse_ignore_list
         thickness_dict.update(horse_thickness_dict)
@@ -266,12 +268,12 @@ def prepare_lists(rig_type, finger_thickness):
         thickness_dict.update(cat_thickness_dict)
         print("MEOW")
     elif rig_type == Skin.Rig_type.BIPED:
-        ignore_list = ignore_list + biped_ignore_list       
-        thickness_dict.update(biped_thickness_dict)       
+        ignore_list = ignore_list + biped_ignore_list
+        thickness_dict.update(biped_thickness_dict)
         print("HUMANOID")
     elif rig_type == Skin.Rig_type.HUMAN:
         ignore_list = ignore_list + human_ignore_list
-        thickness_dict.update(human_thickness_dict)       
+        thickness_dict.update(human_thickness_dict)
         print("JUST A HUMAN AFTER ALL")
     elif rig_type == Skin.Rig_type.WOLF:
         ignore_list = ignore_list + wolf_ignore_list
@@ -293,44 +295,44 @@ def prepare_lists(rig_type, finger_thickness):
         ignore_list = ignore_list + other_ignore_list
         thickness_dict.update(other_thickness_dict)
         print("rig non recognized...")
-       
+
     return ignore_list, thickness_dict
 
 
 # generates edges from vertices used by skin modifier
 def generate_edges(mesh, shape_object, bones, scale, connect_mesh=False, connect_parents=False,
-                   head_ornaments=False, generate_all=False, thickness = 0.0, finger_thickness = 0.0):
+                   head_ornaments=False, generate_all=False, thickness=0.0, finger_thickness=0.0):
     """
     This function adds vertices for all bones' heads and tails
     """
-    
+
     me = mesh
     verts = []
     edges = []
     idx = 0
-           
+
     rig_type = identify_rig()
     skin = Skin(rig_type)
-    
-    # prepare the list             
+
+    # prepare the list
     ignore_list, thickness_dict = prepare_lists(skin.rig_type, finger_thickness)
-  
-    #create default junctions for all bones
-    for b in bones:        
+
+    # create default junctions for all bones
+    for b in bones:
         # set default thickness to all new junctions
-        skin.fragment_create(bname =  b.name, idx = None, thickness = thickness)
-    
+        skin.fragment_create(bname=b.name, idx=None, thickness=thickness)
+
     # edge generator loop
-    for b in bones:   
+    for b in bones:
         # look for rig's specific bones and their childs and set individual thickness
         for bname, thick in thickness_dict.items():
-            
-            if bname.lower() in b.name.lower():            
-                skin.fragment_update(bname = b.name, idx = None, thickness = thick)         
+
+            if bname.lower() in b.name.lower():
+                skin.fragment_update(bname=b.name, idx=None, thickness=thick)
                 for c in b.children_recursive:
-                    #update junctions with specific thickness                   
-                    skin.fragment_update(bname = c.name, idx = None, thickness = thick)
-                 
+                    # update junctions with specific thickness
+                    skin.fragment_update(bname=c.name, idx=None, thickness=thick)
+
         found = False
 
         for i in ignore_list:
@@ -374,14 +376,14 @@ def generate_edges(mesh, shape_object, bones, scale, connect_mesh=False, connect
                 verts.append(vert1)
                 verts.append(vert2)
                 edges.append([idx, idx + 1])
-               
-                # also make list of edges made of gaps between the bones         
+
+                # also make list of edges made of gaps between the bones
                 for bname, data in skin.junctions_dict.items():
-                    if b.name == bname:                  
+                    if b.name == bname:
                         skin.fragment_update(b.name, idx, data[2])
-                        break                    
-                        
-                # create new segment for new connections        
+                        break
+
+                # create new segment for new connections
                 skin.fragment_create(b.name + b.parent.name, idx, data[2])
 
                 idx = idx + 2
@@ -397,19 +399,19 @@ def generate_edges(mesh, shape_object, bones, scale, connect_mesh=False, connect
         verts.append(vert1)
         verts.append(vert2)
 
-        edges.append([idx, idx + 1])       
+        edges.append([idx, idx + 1])
+
+        # insert idx to junctions and update
+        for bname, data in skin.junctions_dict.items():
+            if b.name == bname:
+                skin.fragment_update(b.name, idx, data[2])
 
-        #insert idx to junctions and update
-        for bname, data in skin.junctions_dict.items():            
-            if b.name == bname:         
-                skin.fragment_update(b.name, idx, data[2])    
-                         
         idx = idx + 2
-  
+
     # Create mesh from given verts, faces
     me.from_pydata(verts, edges, [])
     # Update mesh with new data
-    me.update()  
+    me.update()
     # set object scale exact as armature's scale
     shape_object.scale = scale
 
@@ -433,13 +435,14 @@ def select_vertices(mesh_obj, idx):
     return selectedVerts
 
 
-def generate_mesh(shape_object, size, sub_level=1, connect_mesh=False, connect_parents=False, generate_all=False, apply_mod=True, skin = None, bones=[]):
+def generate_mesh(shape_object, size, sub_level=1, connect_mesh=False, connect_parents=False,
+                  generate_all=False, apply_mod=True, skin=None, bones=[]):
     """
     This function adds modifiers for generated edges
     """
     total_bones_num

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list