[Bf-extensions-cvs] [f5fd8087] master: Cleanup: BVH import/export

Campbell Barton noreply at git.blender.org
Sat Oct 6 04:48:13 CEST 2018


Commit: f5fd80872aa8edb8f8217819f0c06cc7c974650c
Author: Campbell Barton
Date:   Sat Oct 6 12:39:20 2018 +1000
Branches: master
https://developer.blender.org/rBAf5fd80872aa8edb8f8217819f0c06cc7c974650c

Cleanup: BVH import/export

- Use tuple unpacking.
- Remove unused operator argument.

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

M	io_anim_bvh/__init__.py
M	io_anim_bvh/export_bvh.py
M	io_anim_bvh/import_bvh.py

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

diff --git a/io_anim_bvh/__init__.py b/io_anim_bvh/__init__.py
index 8a63fbbc..4a4983ff 100644
--- a/io_anim_bvh/__init__.py
+++ b/io_anim_bvh/__init__.py
@@ -26,10 +26,13 @@ bl_info = {
     "location": "File > Import-Export",
     "description": "Import-Export BVH from armature objects",
     "warning": "",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
-                "Scripts/Import-Export/BVH_Importer_Exporter",
+    "wiki_url": (
+        "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+        "Scripts/Import-Export/BVH_Importer_Exporter"
+    ),
     "support": 'OFFICIAL',
-    "category": "Import-Export"}
+    "category": "Import-Export",
+}
 
 if "bpy" in locals():
     import importlib
@@ -40,18 +43,18 @@ if "bpy" in locals():
 
 import bpy
 from bpy.props import (
-        StringProperty,
-        FloatProperty,
-        IntProperty,
-        BoolProperty,
-        EnumProperty,
-        )
+    StringProperty,
+    FloatProperty,
+    IntProperty,
+    BoolProperty,
+    EnumProperty,
+)
 from bpy_extras.io_utils import (
-        ImportHelper,
-        ExportHelper,
-        orientation_helper_factory,
-        axis_conversion,
-        )
+    ImportHelper,
+    ExportHelper,
+    orientation_helper_factory,
+    axis_conversion,
+)
 
 
 ImportBVHOrientationHelper = orientation_helper_factory("ImportBVHOrientationHelper", axis_forward='-Z', axis_up='Y')
@@ -66,74 +69,85 @@ class ImportBVH(bpy.types.Operator, ImportHelper, ImportBVHOrientationHelper):
     filename_ext = ".bvh"
     filter_glob = StringProperty(default="*.bvh", options={'HIDDEN'})
 
-    target = EnumProperty(items=(
+    target = EnumProperty(
+        items=(
             ('ARMATURE', "Armature", ""),
             ('OBJECT', "Object", ""),
-            ),
-                name="Target",
-                description="Import target type",
-                default='ARMATURE')
+        ),
+        name="Target",
+        description="Import target type",
+        default='ARMATURE',
+    )
 
     global_scale = FloatProperty(
-            name="Scale",
-            description="Scale the BVH by this value",
-            min=0.0001, max=1000000.0,
-            soft_min=0.001, soft_max=100.0,
-            default=1.0,
-            )
+        name="Scale",
+        description="Scale the BVH by this value",
+        min=0.0001, max=1000000.0,
+        soft_min=0.001, soft_max=100.0,
+        default=1.0,
+    )
     frame_start = IntProperty(
-            name="Start Frame",
-            description="Starting frame for the animation",
-            default=1,
-            )
+        name="Start Frame",
+        description="Starting frame for the animation",
+        default=1,
+    )
     use_fps_scale = BoolProperty(
-            name="Scale FPS",
-            description=("Scale the framerate from the BVH to the current scenes, "
-                         "otherwise each BVH frame maps directly to a Blender frame"),
-            default=False,
-            )
+        name="Scale FPS",
+        description=(
+            "Scale the framerate from the BVH to the current scenes, "
+            "otherwise each BVH frame maps directly to a Blender frame"
+        ),
+        default=False,
+    )
     update_scene_fps = BoolProperty(
-            name="Update Scene FPS",
-            description="Set the scene framerate to that of the BVH file (note that this "
-                        "nullifies the 'Scale FPS' option, as the scale will be 1:1)",
-            default=False
-            )
+        name="Update Scene FPS",
+        description=(
+            "Set the scene framerate to that of the BVH file (note that this "
+            "nullifies the 'Scale FPS' option, as the scale will be 1:1)"
+        ),
+        default=False
+    )
     update_scene_duration = BoolProperty(
-            name="Update Scene Duration",
-            description="Extend the scene's duration to the BVH duration (never shortens the scene)",
-            default=False,
-            )
+        name="Update Scene Duration",
+        description="Extend the scene's duration to the BVH duration (never shortens the scene)",
+        default=False,
+    )
     use_cyclic = BoolProperty(
-            name="Loop",
-            description="Loop the animation playback",
-            default=False,
-            )
+        name="Loop",
+        description="Loop the animation playback",
+        default=False,
+    )
     rotate_mode = EnumProperty(
-            name="Rotation",
-            description="Rotation conversion",
-            items=(('QUATERNION', "Quaternion",
-                    "Convert rotations to quaternions"),
-                   ('NATIVE', "Euler (Native)",
-                              "Use the rotation order defined in the BVH file"),
-                   ('XYZ', "Euler (XYZ)", "Convert rotations to euler XYZ"),
-                   ('XZY', "Euler (XZY)", "Convert rotations to euler XZY"),
-                   ('YXZ', "Euler (YXZ)", "Convert rotations to euler YXZ"),
-                   ('YZX', "Euler (YZX)", "Convert rotations to euler YZX"),
-                   ('ZXY', "Euler (ZXY)", "Convert rotations to euler ZXY"),
-                   ('ZYX', "Euler (ZYX)", "Convert rotations to euler ZYX"),
-                   ),
-            default='NATIVE',
-            )
+        name="Rotation",
+        description="Rotation conversion",
+        items=(
+            ('QUATERNION', "Quaternion",
+             "Convert rotations to quaternions"),
+            ('NATIVE', "Euler (Native)",
+             "Use the rotation order defined in the BVH file"),
+            ('XYZ', "Euler (XYZ)", "Convert rotations to euler XYZ"),
+            ('XZY', "Euler (XZY)", "Convert rotations to euler XZY"),
+            ('YXZ', "Euler (YXZ)", "Convert rotations to euler YXZ"),
+            ('YZX', "Euler (YZX)", "Convert rotations to euler YZX"),
+            ('ZXY', "Euler (ZXY)", "Convert rotations to euler ZXY"),
+            ('ZYX', "Euler (ZYX)", "Convert rotations to euler ZYX"),
+        ),
+        default='NATIVE',
+    )
 
     def execute(self, context):
-        keywords = self.as_keywords(ignore=("axis_forward",
-                                            "axis_up",
-                                            "filter_glob",
-                                            ))
+        keywords = self.as_keywords(
+            ignore=(
+                "axis_forward",
+                "axis_up",
+                "filter_glob",
+            )
+        )
 
-        global_matrix = axis_conversion(from_forward=self.axis_forward,
-                                        from_up=self.axis_up,
-                                        ).to_4x4()
+        global_matrix = axis_conversion(
+            from_forward=self.axis_forward,
+            from_up=self.axis_up,
+        ).to_4x4()
 
         keywords["global_matrix"] = global_matrix
 
@@ -148,46 +162,47 @@ class ExportBVH(bpy.types.Operator, ExportHelper):
 
     filename_ext = ".bvh"
     filter_glob = StringProperty(
-            default="*.bvh",
-            options={'HIDDEN'},
-            )
+        default="*.bvh",
+        options={'HIDDEN'},
+    )
 
     global_scale = FloatProperty(
-            name="Scale",
-            description="Scale the BVH by this value",
-            min=0.0001, max=1000000.0,
-            soft_min=0.001, soft_max=100.0,
-            default=1.0,
-            )
+        name="Scale",
+        description="Scale the BVH by this value",
+        min=0.0001, max=1000000.0,
+        soft_min=0.001, soft_max=100.0,
+        default=1.0,
+    )
     frame_start = IntProperty(
-            name="Start Frame",
-            description="Starting frame to export",
-            default=0,
-            )
+        name="Start Frame",
+        description="Starting frame to export",
+        default=0,
+    )
     frame_end = IntProperty(
-            name="End Frame",
-            description="End frame to export",
-            default=0,
-            )
+        name="End Frame",
+        description="End frame to export",
+        default=0,
+    )
     rotate_mode = EnumProperty(
-            name="Rotation",
-            description="Rotation conversion",
-            items=(('NATIVE', "Euler (Native)",
-                              "Use the rotation order defined in the BVH file"),
-                   ('XYZ', "Euler (XYZ)", "Convert rotations to euler XYZ"),
-                   ('XZY', "Euler (XZY)", "Convert rotations to euler XZY"),
-                   ('YXZ', "Euler (YXZ)", "Convert rotations to euler YXZ"),
-                   ('YZX', "Euler (YZX)", "Convert rotations to euler YZX"),
-                   ('ZXY', "Euler (ZXY)", "Convert rotations to euler ZXY"),
-                   ('ZYX', "Euler (ZYX)", "Convert rotations to euler ZYX"),
-                   ),
-            default='NATIVE',
-            )
+        name="Rotation",
+        description="Rotation conversion",
+        items=(
+            ('NATIVE', "Euler (Native)",
+             "Use the rotation order defined in the BVH file"),
+            ('XYZ', "Euler (XYZ)", "Convert rotations to euler XYZ"),
+            ('XZY', "Euler (XZY)", "Convert rotations to euler XZY"),
+            ('YXZ', "Euler (YXZ)", "Convert rotations to euler YXZ"),
+            ('YZX', "Euler (YZX)", "Convert rotations to euler YZX"),
+            ('ZXY', "Euler (ZXY)", "Convert rotations to euler ZXY"),
+            ('ZYX', "Euler (ZYX)", "Convert rotations to euler ZYX"),
+        ),
+        default='NATIVE',
+    )
     root_transform_only = BoolProperty(
-            name="Root Translation Only",
-            description="Only write out translation channels for the root bone",
-            default=False,
-            )
+        name="Root Translation Only",
+        description="Only write out translation channels for the root bone",
+        default=False,
+    )
 
     @classmethod
     def poll(cls, context):
@@ -208,7 +223,7 @@ class ExportBVH(bpy.types.Operator, ExportHelper):
         keywords = self.as_keywords(ignore=("check_existing", "filter_glob"))
 
         from . import export_bvh
-        return export_bvh.save(self, context,

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list