fix issues with merge armatures
please report these issues lol!! I found this after I got my friend to test the addon. OOF!!
This commit is contained in:
@@ -313,6 +313,7 @@ def join_mesh_objects(context: Context, meshes: List[Object], progress: Optional
|
|||||||
|
|
||||||
for mesh in valid_meshes:
|
for mesh in valid_meshes:
|
||||||
mesh.select_set(True)
|
mesh.select_set(True)
|
||||||
|
mesh.hide_set(False)
|
||||||
|
|
||||||
context.view_layer.objects.active = valid_meshes[0]
|
context.view_layer.objects.active = valid_meshes[0]
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from typing import List, Optional, Dict, Set, Tuple, Any
|
|||||||
from bpy.types import Context, Object, Operator, ArmatureModifier, EditBone, VertexGroup, Mesh, ShapeKey
|
from bpy.types import Context, Object, Operator, ArmatureModifier, EditBone, VertexGroup, Mesh, ShapeKey
|
||||||
from ...core.logging_setup import logger
|
from ...core.logging_setup import logger
|
||||||
from ...core.translations import t
|
from ...core.translations import t
|
||||||
|
import traceback
|
||||||
from ...core.common import (
|
from ...core.common import (
|
||||||
get_all_meshes,
|
get_all_meshes,
|
||||||
fix_zero_length_bones,
|
fix_zero_length_bones,
|
||||||
@@ -73,8 +74,8 @@ class AvatarToolkit_OT_MergeArmature(bpy.types.Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error merging armatures: {str(e)}")
|
logger.error(f"Error merging armatures:", exception=e)
|
||||||
self.report({'ERROR'}, str(e))
|
self.report({'ERROR'}, traceback.format_exc())
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
def delete_rigidbodies_and_joints(armature: Object) -> None:
|
def delete_rigidbodies_and_joints(armature: Object) -> None:
|
||||||
@@ -150,6 +151,9 @@ def merge_armatures(
|
|||||||
# Store meshes that need to be reparented
|
# Store meshes that need to be reparented
|
||||||
meshes_to_reparent = [obj for obj in bpy.data.objects if obj.type == 'MESH' and obj.parent == merge_armature]
|
meshes_to_reparent = [obj for obj in bpy.data.objects if obj.type == 'MESH' and obj.parent == merge_armature]
|
||||||
|
|
||||||
|
base_armature.hide_set(False)
|
||||||
|
merge_armature.hide_set(False)
|
||||||
|
|
||||||
# Check transforms early
|
# Check transforms early
|
||||||
if not validate_merge_armature_transforms(base_armature, merge_armature, None, tolerance):
|
if not validate_merge_armature_transforms(base_armature, merge_armature, None, tolerance):
|
||||||
if not bpy.context.scene.avatar_toolkit.apply_transforms:
|
if not bpy.context.scene.avatar_toolkit.apply_transforms:
|
||||||
@@ -170,6 +174,8 @@ def merge_armatures(
|
|||||||
fix_zero_length_bones(base_armature)
|
fix_zero_length_bones(base_armature)
|
||||||
fix_zero_length_bones(merge_armature)
|
fix_zero_length_bones(merge_armature)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Store original parent relationships
|
# Store original parent relationships
|
||||||
original_parents: Dict[str, Optional[str]] = {}
|
original_parents: Dict[str, Optional[str]] = {}
|
||||||
merge_armature_data: bpy.types.Armature = merge_armature.data
|
merge_armature_data: bpy.types.Armature = merge_armature.data
|
||||||
@@ -187,9 +193,9 @@ def merge_armatures(
|
|||||||
for standard,bone_name in identified_bone_names_source.items():
|
for standard,bone_name in identified_bone_names_source.items():
|
||||||
if standard in identifed_base_bone_names: #if the bone we are at on our merge armature has a standard name translation for the target armature
|
if standard in identifed_base_bone_names: #if the bone we are at on our merge armature has a standard name translation for the target armature
|
||||||
merge_armature_data.edit_bones[bone_name].name = identifed_base_bone_names[standard] #change it's name to the one on the target merge to armature's coorisponding standard bone
|
merge_armature_data.edit_bones[bone_name].name = identifed_base_bone_names[standard] #change it's name to the one on the target merge to armature's coorisponding standard bone
|
||||||
bone_name = merge_armature_data.edit_bones[bone_name].name
|
bone_name = identifed_base_bone_names[standard]
|
||||||
#adjust original parents list to point to the new name.
|
#adjust original parents list to point to the new name.
|
||||||
for child_bone in merge_armature_data.edit_bones[bone_name]:
|
for child_bone in merge_armature_data.edit_bones[bone_name].children:
|
||||||
original_parents[child_bone.name] = bone_name
|
original_parents[child_bone.name] = bone_name
|
||||||
#then remove so it doesn't clash when merged.
|
#then remove so it doesn't clash when merged.
|
||||||
merge_armature_data.edit_bones.remove(merge_armature_data.edit_bones[bone_name])
|
merge_armature_data.edit_bones.remove(merge_armature_data.edit_bones[bone_name])
|
||||||
@@ -201,6 +207,7 @@ def merge_armatures(
|
|||||||
bpy.ops.object.select_all(action='DESELECT')
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
base_armature.select_set(True)
|
base_armature.select_set(True)
|
||||||
merge_armature.select_set(True)
|
merge_armature.select_set(True)
|
||||||
|
|
||||||
bpy.context.view_layer.objects.active = base_armature
|
bpy.context.view_layer.objects.active = base_armature
|
||||||
bpy.ops.object.join()
|
bpy.ops.object.join()
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ from ...core.armature_validation import validate_armature
|
|||||||
|
|
||||||
class AvatarToolkit_OT_ApplyModifierForShapkeyObj(bpy.types.Operator):
|
class AvatarToolkit_OT_ApplyModifierForShapkeyObj(bpy.types.Operator):
|
||||||
"""Operator for forcing the application of a modifier. A shortened way of saying \"Apply modifier for object with shapekeys\""""
|
"""Operator for forcing the application of a modifier. A shortened way of saying \"Apply modifier for object with shapekeys\""""
|
||||||
bl_idname: str = 'avatar_toolkit.merge_armatures'
|
bl_idname: str = 'avatar_toolkit.apply_shapekey_force'
|
||||||
bl_label: str = t('Tools.apply_modifier_on_shapekey_obj')
|
bl_label: str = t('Tools.apply_modifier_on_shapekey_obj')
|
||||||
bl_description: str = t('Tools.apply_modifier_on_shapekey_obj_desc')
|
bl_description: str = t('Tools.apply_modifier_on_shapekey_obj_desc')
|
||||||
bl_options: Set[str] = {'REGISTER', 'UNDO'}
|
bl_options: Set[str] = {'REGISTER', 'UNDO'}
|
||||||
|
|||||||
Reference in New Issue
Block a user