]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_animation.py
Replace the instance variables of exporters by function parameters
[libs/gl.git] / blender / io_mspgl / export_animation.py
index 3f174e549ba8d616542314e27a7cc36830ebae29..ba83cd490686069cb68b9f874c9fa2fc82add84c 100644 (file)
@@ -2,13 +2,8 @@ import math
 import os
 
 class AnimationExporter:
-       def __init__(self):
-               self.export_all = False
-               self.collection = True
-               self.looping_threshold = 0.001
-
-       def export_to_file(self, context, out_fn):
-               if self.export_all:
+       def export_to_file(self, context, out_fn, *, export_all=False, collection=True, looping_threshold=0.001):
+               if export_all:
                        actions = []
                        for o in context.selected_objects:
                                if not o.animation_data:
@@ -24,12 +19,12 @@ class AnimationExporter:
 
                        resources = {}
                        for a in actions:
-                               resources[a.name+".anim"] = self.export_animation(context, a)
+                               resources[a.name+".anim"] = self.export_animation(context, a, looping_threshold=looping_threshold)
 
                        path, base = os.path.split(out_fn)
                        base, ext = os.path.splitext(base)
 
-                       if self.collection:
+                       if collection:
                                from .datafile import Resource
                                dummy = Resource("dummy", "dummy")
                                dummy.references = list(sorted(resources.values(), key=lambda r: r.name))
@@ -48,9 +43,9 @@ class AnimationExporter:
 
                        resource.write_to_file(out_fn)
 
-       def export_animation(self, context, action):
+       def export_animation(self, context, action, *, looping_threshold=0.001):
                from .animation import create_animation_from_action
-               anim = create_animation_from_action(context, action, looping_threshold=self.looping_threshold)
+               anim = create_animation_from_action(context, action, looping_threshold=looping_threshold)
 
                from .datafile import Resource, Statement
                resource = Resource(action.name+".anim", "animation")