[Bf-extensions-cvs] [665b1a4] master: Fix T42912: FBX export: Parenting to bones was broken.

Bastien Montagne noreply at git.blender.org
Sat Dec 20 14:21:25 CET 2014


Commit: 665b1a4113bc5a0cf918527b8659d2667e93caf9
Author: Bastien Montagne
Date:   Sat Dec 20 14:20:23 2014 +0100
Branches: master
https://developer.blender.org/rBA665b1a4113bc5a0cf918527b8659d2667e93caf9

Fix T42912: FBX export: Parenting to bones was broken.

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

M	io_scene_fbx/fbx_utils.py
M	io_scene_fbx/import_fbx.py

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

diff --git a/io_scene_fbx/fbx_utils.py b/io_scene_fbx/fbx_utils.py
index 22ff4be..4d5cbe8 100644
--- a/io_scene_fbx/fbx_utils.py
+++ b/io_scene_fbx/fbx_utils.py
@@ -998,9 +998,15 @@ class ObjectWrapper(metaclass=MetaObjectWrapper):
             # In fact, this is wrong - since we do not store that matrix in FBX at all, we shall not use it here...
             #~ matrix = self.bdata.matrix_parent_inverse * matrix
             if parent._tag == 'BO':
+                # In bone parent case, local matrix is in ***armature*** space!!!!!!!!!!!!
+                # So we need to bring it back into parent bone space.
+                matrix = parent._ref.pose.bones[parent.name].matrix.inverted_safe() * matrix
+
                 # In bone parent case, we get transformation in **bone tip** space (sigh).
                 # Have to bring it back into bone root, which is FBX expected value.
-                matrix = Matrix.Translation((0, (parent.bdata.tail - parent.bdata.head).length, 0)) * matrix
+                # Actually, since we parent back to bone space above, we do not need that
+                # correction here it seems...
+                #~ matrix = Matrix.Translation((0, (parent.bdata.tail - parent.bdata.head).length, 0)) * matrix
 
         # Our matrix is in local space, time to bring it in its final desired space.
         if parent:
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index 1db465f..d70bc90 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -1637,6 +1637,8 @@ class FbxImportHelperNode:
         return obj
 
     def build_skeleton_children(self, fbx_tmpl, settings, scene):
+        from mathutils import Matrix
+
         if self.is_bone:
             for child in self.children:
                 if child.ignore:
@@ -1646,6 +1648,7 @@ class FbxImportHelperNode:
                     child_obj.parent = self.bl_obj  # get the armature the bone belongs to
                     child_obj.parent_bone = self.bl_bone
                     child_obj.parent_type = 'BONE'
+                    child_obj.matrix_parent_inverse = Matrix()
 
                     # Blender attaches to the end of a bone, while FBX attaches to the start. bone_child_matrix corrects for that.
                     if child.pre_matrix:



More information about the Bf-extensions-cvs mailing list