Introduce BVH export option to sort bone child node name appearances #105120
|
@ -264,6 +264,11 @@ class ExportBVH(bpy.types.Operator, ExportHelper):
|
|||
description="Only write out translation channels for the root bone",
|
||||
default=False,
|
||||
)
|
||||
sort_child_names: BoolProperty(
|
||||
name="Sort Child Names",
|
||||
description="Sort the name ordering of children for each bone alphabetically",
|
||||
default=False,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
|
@ -321,6 +326,7 @@ class BVH_PT_export_transform(bpy.types.Panel):
|
|||
layout.prop(operator, "global_scale")
|
||||
layout.prop(operator, "rotate_mode")
|
||||
layout.prop(operator, "root_transform_only")
|
||||
layout.prop(operator, "sort_child_names")
|
||||
|
||||
|
||||
class BVH_PT_export_animation(bpy.types.Panel):
|
||||
|
|
|
@ -13,6 +13,7 @@ def write_armature(
|
|||
global_scale=1.0,
|
||||
rotate_mode='NATIVE',
|
||||
root_transform_only=False,
|
||||
sort_child_names=False,
|
||||
):
|
||||
|
||||
def ensure_rot_order(rot_order_str):
|
||||
|
@ -36,10 +37,13 @@ def write_armature(
|
|||
for bone in arm.bones:
|
||||
children[bone.name] = []
|
||||
|
||||
# keep bone order from armature, no sorting, not esspential but means
|
||||
# keep bone order from armature, not essential but means
|
||||
# we can maintain order from import -> export which secondlife incorrectly expects.
|
||||
for bone in arm.bones:
|
||||
children[getattr(bone.parent, "name", None)].append(bone.name)
|
||||
if sort_child_names:
|
||||
for key in children:
|
||||
children[key].sort()
|
||||
|
||||
# bone name list in the order that the bones are written
|
||||
serialized_names = []
|
||||
|
@ -281,6 +285,7 @@ def save(
|
|||
global_scale=1.0,
|
||||
rotate_mode="NATIVE",
|
||||
root_transform_only=False,
|
||||
sort_child_names=False,
|
||||
):
|
||||
write_armature(
|
||||
context, filepath,
|
||||
|
@ -289,6 +294,7 @@ def save(
|
|||
global_scale=global_scale,
|
||||
rotate_mode=rotate_mode,
|
||||
root_transform_only=root_transform_only,
|
||||
sort_child_names=sort_child_names,
|
||||
)
|
||||
|
||||
return {'FINISHED'}
|
||||
|
|
Loading…
Reference in New Issue