[Bf-extensions-cvs] [0d60405] fbx_io_development: FBX import: fix rigged mesh space issue in anim import as well.

Bastien Montagne noreply at git.blender.org
Mon Jul 21 21:16:33 CEST 2014


Commit: 0d604056d0eb012462319b456aff8b50bb2093d5
Author: Bastien Montagne
Date:   Mon Jul 21 19:29:10 2014 +0200
Branches: fbx_io_development
https://developer.blender.org/rBA0d604056d0eb012462319b456aff8b50bb2093d5

FBX import: fix rigged mesh space issue in anim import as well.

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

M	io_scene_fbx/import_fbx.py

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

diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index 179e51a..ff75011 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -629,7 +629,7 @@ def blen_read_animations_curves_iter(curves, blen_start_offset, fbx_start_offset
             break
 
 
-def blen_read_animations_action_object(action, ob, obpath, grpname, cnodes, global_matrix, fps):
+def blen_read_animations_action_object(action, ob, obpath, grpname, cnodes, global_matrix, force_global, fps):
     """
     'Bake' loc/rot/scale into the action, taking into account global_matrix if no parent is present.
     """
@@ -677,7 +677,7 @@ def blen_read_animations_action_object(action, ob, obpath, grpname, cnodes, glob
         mat = blen_read_object_transform_do(transform_data)
         # Don't forget global matrix - but never for bones!
         if isinstance(ob, Object):
-            if not ob.parent and global_matrix is not None:
+            if (not ob.parent or force_global) and global_matrix is not None:
                 mat = global_matrix * mat
         else:  # PoseBone, Urg!
             # First, get local (i.e. parentspace) rest pose matrix
@@ -731,7 +731,7 @@ def blen_read_animations_action_shapes(action, kb, curves, fps):
         fc.update()
 
 
-def blen_read_animations(fbx_tmpl_astack, fbx_tmpl_alayer, stacks, scene, global_matrix):
+def blen_read_animations(fbx_tmpl_astack, fbx_tmpl_alayer, stacks, scene, global_matrix, force_global_space):
     """
     Recreate an action per stack/layer/object combinations.
     Note actions are not linked to objects, this is up to the user!
@@ -756,7 +756,8 @@ def blen_read_animations(fbx_tmpl_astack, fbx_tmpl_alayer, stacks, scene, global
                 else:
                     obpath = ob.path_from_id() + "."
                     grpname = ob.name
-                blen_read_animations_action_object(action, ob, obpath, grpname, cnodes, global_matrix, scene.render.fps)
+                blen_read_animations_action_object(action, ob, obpath, grpname, cnodes, global_matrix,
+                                                   ob in force_global_space, scene.render.fps)
 
             for shape_anim_data in shapes.values():
                 for keyblocks, curves in shape_anim_data:
@@ -1829,6 +1830,7 @@ def load(operator, context, filepath="",
 
     # II) We can finish armatures processing.
     arm_parents = set()
+    anim_force_global_space = set()
     def _():
         fbx_tmpl = fbx_template_get((b'Model', b'KFbxNode'))
 
@@ -1883,6 +1885,7 @@ def load(operator, context, filepath="",
                 ob_me.matrix_basis = global_matrix * ob_me.matrix_basis
                 # And reverse-apply armature transform, so that it gets valid parented (local) position!
                 ob_me.matrix_parent_inverse = ob_arm.matrix_basis.inverted()
+                anim_force_global_space.add(ob_me)
     _(); del _
 
     # Animation!
@@ -1974,7 +1977,7 @@ def load(operator, context, filepath="",
                 curvenodes[acn_uuid][ac_uuid] = (fbx_acitem, channel)
 
         # And now that we have sorted all this, apply animations!
-        blen_read_animations(fbx_tmpl_astack, fbx_tmpl_alayer, stacks, scene, global_matrix)
+        blen_read_animations(fbx_tmpl_astack, fbx_tmpl_alayer, stacks, scene, global_matrix, anim_force_global_space)
 
     _(); del _



More information about the Bf-extensions-cvs mailing list