[Bf-extensions-cvs] [8ab7b30] master: Cleanup: pep8 (to some extent :/ )
Bastien Montagne
noreply at git.blender.org
Thu Jul 31 22:19:47 CEST 2014
Commit: 8ab7b3092c4c5919cc5d0a5c855ad1c083103d7d
Author: Bastien Montagne
Date: Thu Jul 31 21:52:26 2014 +0200
Branches: master
https://developer.blender.org/rBA8ab7b3092c4c5919cc5d0a5c855ad1c083103d7d
Cleanup: pep8 (to some extent :/ )
===================================================================
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/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 8a1e1a2..d201d6a 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):
"""
@@ -948,7 +948,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)
@@ -967,14 +967,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)
@@ -983,8 +983,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
@@ -993,7 +993,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)
@@ -1007,7 +1007,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.
@@ -1019,10 +1019,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()
@@ -1591,7 +1591,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):
"""
@@ -1609,13 +1609,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"),
@@ -1782,8 +1782,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())
@@ -1940,7 +1941,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?
@@ -2011,8 +2012,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)
@@ -2071,7 +2072,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
@@ -2098,7 +2099,8 @@ def fbx_data_from_scene(scene, settings):
frame_end = scene.frame_end
if settings.bake_anim:
# From objects & bones only for a start.
- tmp_scdata = FBXData( # Kind of hack, we need a temp scene_data for object's space handling to bake animations...
+ # Kind of hack, we need a temp scene_data for object's space handling to bake animations...
+ tmp_scdata = FBXExportData(
None, None, None,
settings, scene, objects, None, 0.0, 0.0,
data_empties, data_lamps, data_cameras, data_meshes, None,
@@ -2107,7 +2109,7 @@ def fbx_data_from_scene(scene, settings):
)
animations, frame_start, frame_end = fbx_animations(tmp_scdata)
- ##### Creation of templates...
+ # ##### Creation of templates...
templates = OrderedDict()
templates[b"GlobalSettings"] = fbx_template_def_globalsettings(scene, settings, nbr_users=1)
@@ -2184,7 +2186,7 @@ def fbx_data_from_scene(scene, settings):
templates_users = sum(tmpl.nbr_users for tmpl in templates.values())
- ##### Creation of connections...
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list