[Bf-extensions-cvs] [d2aa512] master: Fix T45157: FBX Import could do with better bone alignment in pure-joints armature case.
Bastien Montagne
noreply at git.blender.org
Tue Jun 23 13:01:49 CEST 2015
Commit: d2aa512ae8b1b326f41616a4109e7dadb36bd9d5
Author: Bastien Montagne
Date: Tue Jun 23 12:59:21 2015 +0200
Branches: master
https://developer.blender.org/rBAd2aa512ae8b1b326f41616a4109e7dadb36bd9d5
Fix T45157: FBX Import could do with better bone alignment in pure-joints armature case.
Note that, since I do not have any skinned zero-aligned bones FBX file at hands, I do not
know whether this option breaks skinning or not (hard to predict, we are playing with
at least four different matrices/transforms here)... Time will say.
===================================================================
M io_scene_fbx/__init__.py
M io_scene_fbx/fbx_utils.py
M io_scene_fbx/import_fbx.py
===================================================================
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index ece5f97..92b32af 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, 3, 3),
+ "version": (3, 3, 4),
"blender": (2, 74, 0),
"location": "File > Import-Export",
"description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
@@ -100,40 +100,40 @@ class ImportFBX(bpy.types.Operator, ImportHelper, IOFBXOrientationHelper):
name="Alpha Decals",
description="Treat materials with alpha as decals (no shadow casting)",
default=False,
- options={'HIDDEN'}
)
decal_offset = FloatProperty(
name="Decal Offset",
description="Displace geometry of alpha meshes",
min=0.0, max=1.0,
default=0.0,
- options={'HIDDEN'}
)
use_custom_props = BoolProperty(
name="Import User Properties",
description="Import user properties as custom properties",
default=True,
- options={'HIDDEN'},
)
use_custom_props_enum_as_string = BoolProperty(
name="Import Enums As Strings",
description="Store enumeration values as strings",
default=True,
- options={'HIDDEN'},
)
ignore_leaf_bones = BoolProperty(
name="Ignore Leaf Bones",
description="Ignore the last bone at the end of each chain (used to mark the length of the previous bone)",
default=False,
- options={'HIDDEN'},
+ )
+ force_connect_children = BoolProperty(
+ name="Force Connect Children",
+ description="Force connection of children bones to their parent, even if their computed head/tail "
+ "positions do not match (can be useful with pure-joints-type armatures)",
+ default=False,
)
automatic_bone_orientation = BoolProperty(
name="Automatic Bone Orientation",
description="Try to align the major bone axis with the bone children",
default=False,
- options={'HIDDEN'},
)
primary_bone_axis = EnumProperty(
name="Primary Bone Axis",
@@ -186,6 +186,7 @@ class ImportFBX(bpy.types.Operator, ImportHelper, IOFBXOrientationHelper):
layout.prop(self, "ignore_leaf_bones")
+ layout.prop(self, "force_connect_children"),
layout.prop(self, "automatic_bone_orientation"),
sub = layout.column()
sub.enabled = not self.automatic_bone_orientation
diff --git a/io_scene_fbx/fbx_utils.py b/io_scene_fbx/fbx_utils.py
index f5a8e1d..1058150 100644
--- a/io_scene_fbx/fbx_utils.py
+++ b/io_scene_fbx/fbx_utils.py
@@ -1227,5 +1227,6 @@ FBXImportSettings = namedtuple("FBXImportSettings", (
"use_alpha_decals", "decal_offset",
"use_custom_props", "use_custom_props_enum_as_string",
"cycles_material_wrap_map", "image_cache",
- "ignore_leaf_bones", "automatic_bone_orientation", "bone_correction_matrix", "use_prepost_rot",
+ "ignore_leaf_bones", "force_connect_children", "automatic_bone_orientation", "bone_correction_matrix",
+ "use_prepost_rot",
))
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index 7a2808d..2eaf2f9 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -1762,7 +1762,7 @@ class FbxImportHelperNode:
for child in self.children:
child.collect_armature_meshes()
- def build_skeleton(self, arm, parent_matrix, parent_bone_size=1):
+ def build_skeleton(self, arm, parent_matrix, parent_bone_size=1, force_connect_children=False):
# ----
# Now, create the (edit)bone.
bone = arm.bl_data.edit_bones.new(name=self.fbx_name)
@@ -1802,11 +1802,15 @@ class FbxImportHelperNode:
if child.ignore:
continue
if child.is_bone:
- child_bone = child.build_skeleton(arm, bone_matrix, bone_size)
+ child_bone = child.build_skeleton(arm, bone_matrix, bone_size,
+ force_connect_children=force_connect_children)
# Connection to parent.
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
return bone
@@ -1977,7 +1981,7 @@ class FbxImportHelperNode:
if child.ignore:
continue
if child.is_bone:
- child_obj = child.build_skeleton(self, Matrix())
+ child.build_skeleton(self, Matrix(), force_connect_children=settings.force_connect_children)
bpy.ops.object.mode_set(mode='OBJECT')
@@ -2075,6 +2079,7 @@ def load(operator, context, filepath="",
use_custom_props=True,
use_custom_props_enum_as_string=True,
ignore_leaf_bones=False,
+ force_connect_children=False,
automatic_bone_orientation=False,
primary_bone_axis='Y',
secondary_bone_axis='X',
@@ -2199,7 +2204,7 @@ def load(operator, context, filepath="",
use_alpha_decals, decal_offset,
use_custom_props, use_custom_props_enum_as_string,
cycles_material_wrap_map, image_cache,
- ignore_leaf_bones, automatic_bone_orientation, bone_correction_matrix,
+ ignore_leaf_bones, force_connect_children, automatic_bone_orientation, bone_correction_matrix,
use_prepost_rot,
)
More information about the Bf-extensions-cvs
mailing list