redefine and fix migrate basebody shapkeys
This commit is contained in:
File diff suppressed because one or more lines are too long
+48
-8
@@ -151,9 +151,9 @@ def run_step_5(orig, rep, rep_descendants, orig_to_rep):
|
|||||||
m.object = rep
|
m.object = rep
|
||||||
|
|
||||||
|
|
||||||
def run_step_6(orig, rep, rep_descendants):
|
def run_step_6(orig, rep, rep_descendants, context=None):
|
||||||
"""Replacement base body: library override only, then shape-key action."""
|
"""Replacement base body: library override (fully editable when context given), then shape-key action."""
|
||||||
for ob in rep_descendants:
|
for ob in list(rep_descendants):
|
||||||
if ob.type != "MESH":
|
if ob.type != "MESH":
|
||||||
continue
|
continue
|
||||||
name_lower = (ob.name + " " + (ob.data.name if ob.data else "")).lower()
|
name_lower = (ob.name + " " + (ob.data.name if ob.data else "")).lower()
|
||||||
@@ -165,11 +165,51 @@ def run_step_6(orig, rep, rep_descendants):
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
if getattr(ob.data, "library", None) or getattr(ob.data, "override_library", None):
|
# Debug: base body mesh state before override handling.
|
||||||
|
_lib = getattr(ob.data, "library", None)
|
||||||
|
_ol = getattr(ob.data, "override_library", None)
|
||||||
|
_sys = getattr(_ol, "is_system_override", None) if _ol else None
|
||||||
|
print(f"[DLM step6] {ob.name} data: linked={_lib is not None}, override={_ol is not None}, is_system_override={_sys}")
|
||||||
|
# Library override: use hierarchy create (fully editable) when context available, else single-id override.
|
||||||
|
if getattr(ob, "library", None):
|
||||||
|
if context:
|
||||||
|
try:
|
||||||
|
ob = ob.override_hierarchy_create(
|
||||||
|
context.scene, context.view_layer, do_fully_editable=True
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
ob.override_create()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
ob.override_create()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
if getattr(ob.data, "library", None):
|
||||||
try:
|
try:
|
||||||
ob.data.override_create()
|
ob.data.override_create(remap_local_usages=True)
|
||||||
except Exception:
|
# Make override user-editable (same as shift-click in data tab).
|
||||||
pass
|
ol = getattr(ob.data, "override_library", None)
|
||||||
|
if ol is not None and getattr(ol, "is_system_override", None) is not None:
|
||||||
|
try:
|
||||||
|
ol.is_system_override = False
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[DLM step6] {ob.name} set is_system_override=False: {e}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[DLM step6] {ob.name} ob.data.override_create: {e}")
|
||||||
|
elif getattr(ob.data, "override_library", None):
|
||||||
|
ol = ob.data.override_library
|
||||||
|
if getattr(ol, "is_system_override", False):
|
||||||
|
try:
|
||||||
|
ol.is_system_override = False
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[DLM step6] {ob.name} set is_system_override=False: {e}")
|
||||||
|
# Debug: state after override handling.
|
||||||
|
_ol2 = getattr(ob.data, "override_library", None)
|
||||||
|
_sys2 = getattr(_ol2, "is_system_override", None) if _ol2 else None
|
||||||
|
print(f"[DLM step6] {ob.name} after: override={_ol2 is not None}, is_system_override={_sys2} (False=editable)")
|
||||||
if ob.data.shape_keys:
|
if ob.data.shape_keys:
|
||||||
if not ob.data.shape_keys.animation_data:
|
if not ob.data.shape_keys.animation_data:
|
||||||
ob.data.shape_keys.animation_data_create()
|
ob.data.shape_keys.animation_data_create()
|
||||||
@@ -205,7 +245,7 @@ def run_full_migration(context):
|
|||||||
run_step_3(orig, rep)
|
run_step_3(orig, rep)
|
||||||
run_step_4(orig, rep, orig_to_rep)
|
run_step_4(orig, rep, orig_to_rep)
|
||||||
run_step_5(orig, rep, rep_descendants, orig_to_rep)
|
run_step_5(orig, rep, rep_descendants, orig_to_rep)
|
||||||
run_step_6(orig, rep, rep_descendants)
|
run_step_6(orig, rep, rep_descendants, context)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False, str(e)
|
return False, str(e)
|
||||||
return True, f"Migrated {orig.name} → {rep.name}"
|
return True, f"Migrated {orig.name} → {rep.name}"
|
||||||
|
|||||||
+8
-8
@@ -358,9 +358,9 @@ class DLM_OT_migrator_retarget_relations(Operator):
|
|||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
|
||||||
class DLM_OT_migrator_replacement_base_body(Operator):
|
class DLM_OT_migrator_basebody_shapekeys(Operator):
|
||||||
bl_idname = "dlm.migrator_replacement_base_body"
|
bl_idname = "dlm.migrator_basebody_shapekeys"
|
||||||
bl_label = "Replacement base body"
|
bl_label = "Migrate BaseBody shapekeys"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
@@ -372,8 +372,8 @@ class DLM_OT_migrator_replacement_base_body(Operator):
|
|||||||
from ..ops.migrator import run_step_6
|
from ..ops.migrator import run_step_6
|
||||||
from ..utils import descendants
|
from ..utils import descendants
|
||||||
rep_descendants = descendants(rep)
|
rep_descendants = descendants(rep)
|
||||||
run_step_6(orig, rep, rep_descendants)
|
run_step_6(orig, rep, rep_descendants, context)
|
||||||
self.report({"INFO"}, "Replacement base body done.")
|
self.report({"INFO"}, "Migrate BaseBody shapekeys done.")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.report({"ERROR"}, str(e))
|
self.report({"ERROR"}, str(e))
|
||||||
@@ -386,7 +386,7 @@ MIGRATOR_STEP_OPS = (
|
|||||||
"dlm.migrator_custom_properties",
|
"dlm.migrator_custom_properties",
|
||||||
"dlm.migrator_bone_constraints",
|
"dlm.migrator_bone_constraints",
|
||||||
"dlm.migrator_retarget_relations",
|
"dlm.migrator_retarget_relations",
|
||||||
"dlm.migrator_replacement_base_body",
|
"dlm.migrator_basebody_shapekeys",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -402,7 +402,7 @@ class DLM_OT_run_character_migration(Operator):
|
|||||||
bpy.ops.dlm.migrator_custom_properties,
|
bpy.ops.dlm.migrator_custom_properties,
|
||||||
bpy.ops.dlm.migrator_bone_constraints,
|
bpy.ops.dlm.migrator_bone_constraints,
|
||||||
bpy.ops.dlm.migrator_retarget_relations,
|
bpy.ops.dlm.migrator_retarget_relations,
|
||||||
bpy.ops.dlm.migrator_replacement_base_body,
|
bpy.ops.dlm.migrator_basebody_shapekeys,
|
||||||
]
|
]
|
||||||
for i, op in enumerate(steps):
|
for i, op in enumerate(steps):
|
||||||
result = op()
|
result = op()
|
||||||
@@ -464,5 +464,5 @@ OPERATOR_CLASSES = [
|
|||||||
DLM_OT_migrator_custom_properties,
|
DLM_OT_migrator_custom_properties,
|
||||||
DLM_OT_migrator_bone_constraints,
|
DLM_OT_migrator_bone_constraints,
|
||||||
DLM_OT_migrator_retarget_relations,
|
DLM_OT_migrator_retarget_relations,
|
||||||
DLM_OT_migrator_replacement_base_body,
|
DLM_OT_migrator_basebody_shapekeys,
|
||||||
]
|
]
|
||||||
|
|||||||
+1
-1
@@ -92,7 +92,7 @@ class DLM_PT_main_panel(Panel):
|
|||||||
row = box.row(align=True)
|
row = box.row(align=True)
|
||||||
row.operator("dlm.migrator_bone_constraints", text="Bone constraints")
|
row.operator("dlm.migrator_bone_constraints", text="Bone constraints")
|
||||||
row.operator("dlm.migrator_retarget_relations", text="Retarget relations")
|
row.operator("dlm.migrator_retarget_relations", text="Retarget relations")
|
||||||
row.operator("dlm.migrator_replacement_base_body", text="Replacement base body")
|
row.operator("dlm.migrator_basebody_shapekeys", text="Migrate BaseBody shapekeys")
|
||||||
|
|
||||||
# Linked Libraries: header row (always), main box only when expanded
|
# Linked Libraries: header row (always), main box only when expanded
|
||||||
missing_count = sum(1 for lib in props.linked_libraries if lib.is_missing)
|
missing_count = sum(1 for lib in props.linked_libraries if lib.is_missing)
|
||||||
|
|||||||
Reference in New Issue
Block a user