[Bf-extensions-cvs] [0c3c1d5] master: FBX import: enhancement related to T45157: do not force-connect children when there are several ones with different 'head' positions.
Bastien Montagne
noreply at git.blender.org
Mon Jun 29 13:13:46 CEST 2015
Commit: 0c3c1d569e73288e6eefddf1789309cb101e6b31
Author: Bastien Montagne
Date: Mon Jun 29 13:11:59 2015 +0200
Branches: master
https://developer.blender.org/rBA0c3c1d569e73288e6eefddf1789309cb101e6b31
FBX import: enhancement related to T45157: do not force-connect children when
there are several ones with different 'head' positions.
Also, fix a minor bug from previous 'multi-armatures for a single mesh' commit.
===================================================================
M io_scene_fbx/__init__.py
M io_scene_fbx/import_fbx.py
===================================================================
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index a5f4258..4d5b32b 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -21,7 +21,7 @@
bl_info = {
"name": "FBX format",
"author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
- "version": (3, 4, 0),
+ "version": (3, 4, 1),
"blender": (2, 74, 0),
"location": "File > Import-Export",
"description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index 851339d..eed332a 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -1806,6 +1806,7 @@ class FbxImportHelperNode:
# while Blender attaches to the tail.
self.bone_child_matrix = Matrix.Translation(-bone_tail)
+ connected = ...
for child in self.children:
if child.ignore:
continue
@@ -1816,9 +1817,31 @@ class FbxImportHelperNode:
child_bone.parent = bone
if similar_values_iter(bone.tail, child_bone.head):
child_bone.use_connect = True
- elif force_connect_children:
- bone.tail = child_bone.head
- child_bone.use_connect = True
+ # Disallow any force-connection at this level from now on, since that child was 'really'
+ # connected, we do not want to move current bone's tail anymore!
+ if connected is ...:
+ connected = None
+ elif connected is not None:
+ # We already force-connected some children, so we have to store that child_bone in
+ # force-connected list as well (since current bone's tail is no more in its original position).
+ connected[1].append(child_bone)
+ elif force_connect_children and connected is not None:
+ if connected is ...: # First child bone to force-connect, it's OK so far.
+ connected = (bone.tail.copy(), [child_bone])
+ bone.tail = child_bone.head
+ child_bone.use_connect = True
+ else:
+ # We already have at least one child bone force-connected.
+ # Since we already moved current bone's tail to match that child,
+ # if current child bone had been 'compatible' (same head position) it would have been
+ # already handled by code above.
+ # This means that at this point we know we have several child bones with different head
+ # positions, hence we cannot force-connect them to current bone. We need to restore
+ # situation prior to first force-connect!
+ for cb in connected[1]:
+ cb.use_connect = False
+ bone.tail = connected[0]
+ connected = None
return bone
@@ -1880,7 +1903,7 @@ class FbxImportHelperNode:
if child.ignore:
continue
child_obj = child.bl_obj
- if child_obj:
+ if child_obj and child_obj != self.bl_obj:
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'
More information about the Bf-extensions-cvs
mailing list