Asset Pipeline: Make Parent Relationships Persistent #205

Merged
Nick Alberelli merged 1 commits from TinyNick/blender-studio-pipeline:fix/asset-pipeline-persistent-parent into main 2024-01-16 23:33:01 +01:00
2 changed files with 4 additions and 12 deletions

View File

@ -18,9 +18,7 @@ from .transfer_util import (
) )
def copy_transfer_data_ownership( def copy_transfer_data_ownership(transfer_data_item, target_obj: bpy.types.Object) -> None:
transfer_data_item, target_obj: bpy.types.Object
) -> None:
"""Copy Transferable Data item to object if non entry exists """Copy Transferable Data item to object if non entry exists
Args: Args:
@ -67,7 +65,6 @@ def transfer_data_is_missing(transfer_data_item) -> bool:
or constraints.constraint_is_missing(transfer_data_item) or constraints.constraint_is_missing(transfer_data_item)
or shape_keys.shape_key_is_missing(transfer_data_item) or shape_keys.shape_key_is_missing(transfer_data_item)
or attributes.attribute_is_missing(transfer_data_item) or attributes.attribute_is_missing(transfer_data_item)
or parent.parent_is_missing(transfer_data_item)
) )
@ -115,9 +112,7 @@ def apply_transfer_data(context: bpy.types.Context, transfer_data_map) -> None:
for name in transfer_data_map: for name in transfer_data_map:
temp_transfer_data = context.scene.asset_pipeline.temp_transfer_data temp_transfer_data = context.scene.asset_pipeline.temp_transfer_data
transfer_data = transfer_data_map[name] transfer_data = transfer_data_map[name]
transfer_data_item = temp_transfer_data[ transfer_data_item = temp_transfer_data[transfer_data.get('transfer_data_item_index')]
transfer_data.get('transfer_data_item_index')
]
target_obj = transfer_data.get('target_obj') target_obj = transfer_data.get('target_obj')
source_obj = transfer_data.get('source_obj') source_obj = transfer_data.get('source_obj')
if target_obj is None: if target_obj is None:

View File

@ -33,11 +33,8 @@ def init_parent(scene, obj):
name = constants.PARENT_TRANSFER_DATA_ITEM_NAME name = constants.PARENT_TRANSFER_DATA_ITEM_NAME
transfer_data = obj.transfer_data_ownership transfer_data = obj.transfer_data_ownership
# Only Execute if Material Slots exist on object if obj.parent not in list(asset_pipe.asset_collection.all_objects) and obj.parent is not None:
if obj.parent == None: raise Exception(f"Object parent {obj.parent.name} cannot be outside of asset collection")
return
if obj.parent not in list(asset_pipe.asset_collection.all_objects):
raise Exception("Object parent cannot be outside of asset collection")
matches = check_transfer_data_entry(transfer_data, name, td_type_key) matches = check_transfer_data_entry(transfer_data, name, td_type_key)
# Only add new ownership transfer_data_item if vertex group doesn't have an owner # Only add new ownership transfer_data_item if vertex group doesn't have an owner
if len(matches) == 0: if len(matches) == 0: