[Bf-extensions-cvs] [3e07910] fbx_io_development: Cleanup: pep8 (to some extent only :/ )

Bastien Montagne noreply at git.blender.org
Thu Jul 31 21:27:32 CEST 2014


Commit: 3e079107e42a227ae9e8b873f6ffaaadb7307be9
Author: Bastien Montagne
Date:   Thu Jul 31 21:25:33 2014 +0200
Branches: fbx_io_development
https://developer.blender.org/rBA3e079107e42a227ae9e8b873f6ffaaadb7307be9

Cleanup: pep8 (to some extent only :/ )

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

M	io_scene_fbx/__init__.py
M	io_scene_fbx/encode_bin.py
M	io_scene_fbx/export_fbx_bin.py
M	io_scene_fbx/fbx_utils.py
M	io_scene_fbx/import_fbx.py

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

diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index fa6cb52..38843b5 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -134,7 +134,7 @@ class ImportFBX(bpy.types.Operator, ImportHelper):
             default=True,
             options={'HIDDEN'},
             )
-    
+
     def draw(self, context):
         layout = self.layout
 
@@ -153,7 +153,7 @@ class ImportFBX(bpy.types.Operator, ImportHelper):
         sub = layout.row()
         sub.enabled = self.use_custom_props
         sub.prop(self, "use_custom_props_enum_as_string")
-        
+
     def execute(self, context):
         keywords = self.as_keywords(ignore=("filter_glob", "directory"))
         keywords["use_cycles"] = (context.scene.render.engine == 'CYCLES')
diff --git a/io_scene_fbx/encode_bin.py b/io_scene_fbx/encode_bin.py
index 6444ef9..2023a49 100644
--- a/io_scene_fbx/encode_bin.py
+++ b/io_scene_fbx/encode_bin.py
@@ -45,6 +45,7 @@ _FOOT_ID = b'\xfa\xbc\xab\x09\xd0\xc8\xd4\x66\xb1\x76\xfb\x83\x1c\xf7\x26\x7e'
 # Awful exceptions: those "classes" of elements seem to need block sentinel even when having no children and some props.
 _ELEMS_ID_ALWAYS_BLOCK_SENTINEL = {b"AnimationStack", b"AnimationLayer"}
 
+
 class FBXElem:
     __slots__ = (
         "id",
diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index 8d606dd..7904e1d 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -102,7 +102,7 @@ convert_rad_to_deg = units_convertor("radian", "degree")
 convert_rad_to_deg_iter = units_convertor_iter("radian", "degree")
 
 
-##### Templates #####
+# ##### Templates #####
 # TODO: check all those "default" values, they should match Blender's default as much as possible, I guess?
 
 def fbx_template_def_globalsettings(scene, settings, override_defaults=None, nbr_users=0):
@@ -513,7 +513,7 @@ def fbx_template_def_animcurve(scene, settings, override_defaults=None, nbr_user
     return FBXTemplate(b"AnimationCurve", b"", props, nbr_users, [False])
 
 
-##### Generators for connection elements. #####
+# ##### Generators for connection elements. #####
 
 def elem_connection(elem, c_type, uid_src, uid_dst, prop_dst=None):
     e = elem_data_single_string(elem, b"C", c_type)
@@ -523,7 +523,7 @@ def elem_connection(elem, c_type, uid_src, uid_dst, prop_dst=None):
         e.add_string(prop_dst)
 
 
-##### FBX objects generators. #####
+# ##### FBX objects generators. #####
 
 def fbx_data_element_custom_properties(props, bid):
     """
@@ -541,6 +541,7 @@ def fbx_data_element_custom_properties(props, bid):
         elif list_val and len(list_val) == 3:
             elem_props_set(props, "p_vector", k.encode(), list_val, custom=True)
 
+
 def fbx_data_empty_elements(root, empty, scene_data):
     """
     Write the Empty data block.
@@ -951,7 +952,7 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
     def _nortuples_gen(raw_nors, m):
         # Great, now normals are also expected 4D!
         # XXX Back to 3D normals for now!
-        #gen = zip(*(iter(raw_nors),) * 3 + (_infinite_gen(1.0),))
+        # gen = zip(*(iter(raw_nors),) * 3 + (_infinite_gen(1.0),))
         gen = zip(*(iter(raw_nors),) * 3)
         return gen if m is None else (m * Vector(v) for v in gen)
 
@@ -970,14 +971,14 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
         ln2idx = tuple(set(t_ln))
         elem_data_single_float64_array(lay_nor, b"Normals", chain(*ln2idx))
         # Normal weights, no idea what it is.
-        #t_lnw = array.array(data_types.ARRAY_FLOAT64, (0.0,)) * len(ln2idx)
-        #elem_data_single_float64_array(lay_nor, b"NormalsW", t_lnw)
+        # t_lnw = array.array(data_types.ARRAY_FLOAT64, (0.0,)) * len(ln2idx)
+        # elem_data_single_float64_array(lay_nor, b"NormalsW", t_lnw)
 
         ln2idx = {nor: idx for idx, nor in enumerate(ln2idx)}
         elem_data_single_int32_array(lay_nor, b"NormalsIndex", (ln2idx[n] for n in t_ln))
 
         del ln2idx
-        #del t_lnw
+        # del t_lnw
     else:
         lay_nor = elem_data_single_int32(geom, b"LayerElementNormal", 0)
         elem_data_single_int32(lay_nor, b"Version", FBX_GEOMETRY_NORMAL_VERSION)
@@ -986,8 +987,8 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
         elem_data_single_string(lay_nor, b"ReferenceInformationType", b"Direct")
         elem_data_single_float64_array(lay_nor, b"Normals", chain(*t_ln))
         # Normal weights, no idea what it is.
-        #t_ln = array.array(data_types.ARRAY_FLOAT64, (0.0,)) * len(me.loops)
-        #elem_data_single_float64_array(lay_nor, b"NormalsW", t_ln)
+        # t_ln = array.array(data_types.ARRAY_FLOAT64, (0.0,)) * len(me.loops)
+        # elem_data_single_float64_array(lay_nor, b"NormalsW", t_ln)
     del t_ln
 
     # tspace
@@ -996,7 +997,7 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
         tspacenumber = len(me.uv_layers)
         if tspacenumber:
             t_ln = array.array(data_types.ARRAY_FLOAT64, (0.0,)) * len(me.loops) * 3
-            #t_lnw = array.array(data_types.ARRAY_FLOAT64, (0.0,)) * len(me.loops)
+            # t_lnw = array.array(data_types.ARRAY_FLOAT64, (0.0,)) * len(me.loops)
             for idx, uvlayer in enumerate(me.uv_layers):
                 name = uvlayer.name
                 me.calc_tangents(name)
@@ -1010,7 +1011,7 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
                 elem_data_single_string(lay_nor, b"ReferenceInformationType", b"Direct")
                 elem_data_single_float64_array(lay_nor, b"Binormals", chain(*_nortuples_gen(t_ln, geom_mat_no)))
                 # Binormal weights, no idea what it is.
-                #elem_data_single_float64_array(lay_nor, b"BinormalsW", t_lnw)
+                # elem_data_single_float64_array(lay_nor, b"BinormalsW", t_lnw)
 
                 # Loop tangents.
                 # NOTE: this is not supported by importer currently.
@@ -1022,10 +1023,10 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
                 elem_data_single_string(lay_nor, b"ReferenceInformationType", b"Direct")
                 elem_data_single_float64_array(lay_nor, b"Tangents", chain(*_nortuples_gen(t_ln, geom_mat_no)))
                 # Tangent weights, no idea what it is.
-                #elem_data_single_float64_array(lay_nor, b"TangentsW", t_lnw)
+                # elem_data_single_float64_array(lay_nor, b"TangentsW", t_lnw)
 
             del t_ln
-            #del t_lnw
+            # del t_lnw
             me.free_tangents()
 
     me.free_normals_split()
@@ -1594,7 +1595,7 @@ def fbx_data_animation_elements(root, scene_data):
                 elem_props_template_finalize(acn_tmpl, acn_props)
 
 
-##### Top-level FBX data container. #####
+# ##### Top-level FBX data container. #####
 
 def fbx_mat_properties_from_texture(tex):
     """
@@ -1612,13 +1613,13 @@ def fbx_mat_properties_from_texture(tex):
         ("emit", "emit", b"EmissiveFactor"),
         ("diffuse", "diffuse", b"EmissiveColor"),  # Uses diffuse color in Blender!
         ("ambient", "ambient", b"AmbientFactor"),
-        #("", "", b"AmbientColor"),  # World stuff in Blender, for now ignore...
+        # ("", "", b"AmbientColor"),  # World stuff in Blender, for now ignore...
         ("normal", "normal", b"NormalMap"),
         # Note: unsure about those... :/
-        #("", "", b"Bump"),
-        #("", "", b"BumpFactor"),
-        #("", "", b"DisplacementColor"),
-        #("", "", b"DisplacementFactor"),
+        # ("", "", b"Bump"),
+        # ("", "", b"BumpFactor"),
+        # ("", "", b"DisplacementColor"),
+        # ("", "", b"DisplacementFactor"),
         # Phong only.
         ("specular", "specular", b"SpecularFactor"),
         ("color_spec", "specular_color", b"SpecularColor"),
@@ -1785,8 +1786,9 @@ def fbx_animations_do(scene_data, ref_id, f_start, f_end, start_zero, objects=No
     for channel_key, (anim_shape, me, shape) in animdata_shapes.items():
         final_keys = OrderedDict()
         anim_shape.simplfy(simplify_fac, bake_step)
-        if anim_shape:
-            for elem_key, group_key, group, fbx_group, fbx_gname in anim_shape.get_final_data(scene, ref_id, force_keep):
+        if not anim_shape:
+            continue
+        for elem_key, group_key, group, fbx_group, fbx_gname in anim_shape.get_final_data(scene, ref_id, force_keep):
                 anim_data = animations.get(elem_key)
                 if anim_data is None:
                     anim_data = animations[elem_key] = ("dummy_unused_key", OrderedDict())
@@ -1943,7 +1945,7 @@ def fbx_data_from_scene(scene, settings):
     """
     objtypes = settings.object_types
 
-    ##### Gathering data...
+    # ##### Gathering data...
 
     # This is rather simple for now, maybe we could end generating templates with most-used values
     # instead of default ones?
@@ -2014,8 +2016,8 @@ def fbx_data_from_scene(scene, settings):
                     # Note: Maybe this is a bit too simplistic, should we use real shape base here? Though FBX does not
                     #       have this at all... Anyway, this should cover most common cases imho.
                     continue
-                shape_verts_co.extend(sv.co - v.co);
-                shape_verts_idx.append(idx);
+                shape_verts_co.extend(sv.co - v.co)
+                shape_verts_idx.append(idx)
             if not shape_verts_co:
                 continue
             channel_key, geom_key = get_blender_mesh_shape_channel_key(me, shape)
@@ -2074,7 +2076,7 @@ def fbx_data_from_scene(scene, settings):
             # Note FBX does has support for procedural, but this is not portable at all (opaque blob),
             # so not useful for us.
             # TODO I think ENVIRONMENT_MAP should be usable in FBX as well, but for now let it aside.
-            #if tex.texture.type not in {'IMAGE', 'ENVIRONMENT_MAP'}:
+            # if tex.texture.type not in {'IMAGE', 'ENVIRONMENT_MAP'}:
             if tex.texture.type not in {'IMAGE'}:
                 continue
             img = tex.texture.image
@@ -2101,7 +2103,8 @@ def fbx_data_from_scene(scene, sett

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list