[Bf-extensions-cvs] [a9c73ba] master: FBX importer: Fixed infinite loop in animation importer.

Jens Ch. Restemeier noreply at git.blender.org
Thu Jul 31 22:19:48 CEST 2014


Commit: a9c73ba7bd0531b78a9c3238af539e95b01ae032
Author: Jens Ch. Restemeier
Date:   Thu Jul 31 22:13:52 2014 +0200
Branches: master
https://developer.blender.org/rBAa9c73ba7bd0531b78a9c3238af539e95b01ae032

FBX importer: Fixed infinite loop in animation importer.

This will need a cleanup when adding proper support for spline animation curves.

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

M	io_scene_fbx/import_fbx.py

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

diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index f9cf9f2..bb252b2 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -664,34 +664,29 @@ def blen_read_animations_curves_iter(fbx_curves, blen_start_offset, fbx_start_of
                     c]
                    for c in fbx_curves)
 
-    while True:
-        tmin = min(curves, key=lambda e: e[1][e[0]])
-        curr_fbxktime = tmin[1][tmin[0]]
+    allkeys = sorted({item for sublist in curves for item in sublist[1]})
+    for curr_fbxktime in allkeys:
         curr_values = []
-        do_break = True
         for item in curves:
             idx, times, values, fbx_curve = item
-            if idx != -1:
-                do_break = False
-            if times[idx] > curr_fbxktime:
-                if idx == 0:
-                    curr_values.append((values[idx], fbx_curve))
-                else:
-                    # Interpolate between this key and the previous one.
-                    ifac = (curr_fbxktime - times[idx - 1]) / (times[idx] - times[idx - 1])
-                    curr_values.append(((values[idx] - values[idx - 1]) * ifac + values[idx - 1], fbx_curve))
-            else:
-                curr_values.append((values[idx], fbx_curve))
+
+            if times[idx] < curr_fbxktime:
                 if idx >= 0:
                     idx += 1
                     if idx >= len(times):
                         # We have reached our last element for this curve, stay on it from now on...
                         idx = -1
                     item[0] = idx
+
+            if times[idx] >= curr_fbxktime:
+                if idx == 0:
+                    curr_values.append((values[idx], fbx_curve))
+                else:
+                    # Interpolate between this key and the previous one.
+                    ifac = (curr_fbxktime - times[idx - 1]) / (times[idx] - times[idx - 1])
+                    curr_values.append(((values[idx] - values[idx - 1]) * ifac + values[idx - 1], fbx_curve))
         curr_blenkframe = (curr_fbxktime - fbx_start_offset) * timefac + blen_start_offset
         yield (curr_blenkframe, curr_values)
-        if do_break:
-            break
 
 
 def blen_read_animations_action_item(action, item, cnodes, force_global, fps, settings):



More information about the Bf-extensions-cvs mailing list