@@ -653,6 +653,9 @@ def store_breaking_settings_armature(armature: bpy.types.Object) -> ArmatureData
|
|||||||
return (armature_data.use_mirror_x, armature.pose.use_mirror_x)
|
return (armature_data.use_mirror_x, armature.pose.use_mirror_x)
|
||||||
|
|
||||||
def restore_breaking_settings_armature(armature: bpy.types.Object, data: ArmatureData) -> None:
|
def restore_breaking_settings_armature(armature: bpy.types.Object, data: ArmatureData) -> None:
|
||||||
|
# Check if armature object is still valid (not removed)
|
||||||
|
if not armature or armature.name not in bpy.data.objects:
|
||||||
|
return
|
||||||
armature_data: bpy.types.Armature = armature.data
|
armature_data: bpy.types.Armature = armature.data
|
||||||
armature_data.use_mirror_x, armature.pose.use_mirror_x = data
|
armature_data.use_mirror_x, armature.pose.use_mirror_x = data
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ class AvatarToolkit_OT_MergeArmature(bpy.types.Operator):
|
|||||||
data_breaking_base = store_breaking_settings_armature(base_armature)
|
data_breaking_base = store_breaking_settings_armature(base_armature)
|
||||||
data_breaking_merge = store_breaking_settings_armature(merge_armature)
|
data_breaking_merge = store_breaking_settings_armature(merge_armature)
|
||||||
|
|
||||||
|
# Store the merge armature name before it gets removed during join
|
||||||
|
merge_armature_name_stored = merge_armature.name
|
||||||
|
|
||||||
# Remove Rigid Bodies and Joints
|
# Remove Rigid Bodies and Joints
|
||||||
delete_rigidbodies_and_joints(base_armature)
|
delete_rigidbodies_and_joints(base_armature)
|
||||||
delete_rigidbodies_and_joints(merge_armature)
|
delete_rigidbodies_and_joints(merge_armature)
|
||||||
@@ -77,14 +80,17 @@ class AvatarToolkit_OT_MergeArmature(bpy.types.Operator):
|
|||||||
wm.progress_end()
|
wm.progress_end()
|
||||||
|
|
||||||
restore_breaking_settings_armature(base_armature, data_breaking_base)
|
restore_breaking_settings_armature(base_armature, data_breaking_base)
|
||||||
restore_breaking_settings_armature(merge_armature, data_breaking_merge)
|
|
||||||
|
if merge_armature_name_stored in bpy.data.objects:
|
||||||
|
merge_armature_obj = bpy.data.objects[merge_armature_name_stored]
|
||||||
|
restore_breaking_settings_armature(merge_armature_obj, data_breaking_merge)
|
||||||
|
|
||||||
self.report({'INFO'}, t('MergeArmature.success'))
|
self.report({'INFO'}, t('MergeArmature.success'))
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error merging armatures:", exception=e)
|
logger.error(f"Error merging armatures: {str(e)}\n{traceback.format_exc()}")
|
||||||
self.report({'ERROR'}, traceback.format_exc())
|
self.report({'ERROR'}, traceback.format_exc())
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user