Asset Pipeline v2 #145
@ -126,9 +126,14 @@ class AssetTransferMapping:
|
|||||||
|
|
||||||
def _gen_transfer_data_map(self):
|
def _gen_transfer_data_map(self):
|
||||||
transfer_data_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
|
transfer_data_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
|
||||||
|
remove_transfer_data = []
|
||||||
for obj in self._external_col.all_objects:
|
for obj in self._external_col.all_objects:
|
||||||
|
# TODO Remove any tansfer_info that is on an external obj but owned by the local TL
|
||||||
|
# TODO this works on pull not push FIX!
|
||||||
|
# TODO Just do the opposite of this in the local collection
|
||||||
for transfer_info in obj.transfer_data_ownership:
|
for transfer_info in obj.transfer_data_ownership:
|
||||||
|
if transfer_info.owner in self._local_tls:
|
||||||
|
remove_transfer_data.append(transfer_info.name)
|
||||||
if (
|
if (
|
||||||
transfer_info.owner not in self._local_tls
|
transfer_info.owner not in self._local_tls
|
||||||
and transfer_info.owner != "NONE"
|
and transfer_info.owner != "NONE"
|
||||||
@ -138,11 +143,33 @@ class AssetTransferMapping:
|
|||||||
target_obj = self._local_col.all_objects.get(target_obj_name)
|
target_obj = self._local_col.all_objects.get(target_obj_name)
|
||||||
transfer_data_map[name] = (transfer_info, target_obj)
|
transfer_data_map[name] = (transfer_info, target_obj)
|
||||||
|
|
||||||
|
for name in remove_transfer_data:
|
||||||
|
# TODO FIX THIS
|
||||||
|
try:
|
||||||
|
index = obj.transfer_data_ownership.keys().index(name)
|
||||||
|
obj.transfer_data_ownership.remove(index)
|
||||||
|
print(f"Remvoing {name} from {obj.name}")
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
|
||||||
|
remove_transfer_data = []
|
||||||
for obj in self._local_col.all_objects:
|
for obj in self._local_col.all_objects:
|
||||||
for transfer_info in obj.transfer_data_ownership:
|
for transfer_info in obj.transfer_data_ownership:
|
||||||
|
# if transfer_info.owner not in self._local_tls:
|
||||||
|
# remove_transfer_data.append(transfer_info.name)
|
||||||
if transfer_info.owner in self._local_tls:
|
if transfer_info.owner in self._local_tls:
|
||||||
name = transfer_info.name + '_' + obj.name
|
name = transfer_info.name + '_' + obj.name
|
||||||
target_obj_name = asset_suffix.get_target_name(obj.name)
|
target_obj_name = asset_suffix.get_target_name(obj.name)
|
||||||
target_obj = self._external_col.all_objects.get(target_obj_name)
|
target_obj = self._external_col.all_objects.get(target_obj_name)
|
||||||
transfer_data_map[name] = (transfer_info, target_obj)
|
transfer_data_map[name] = (transfer_info, target_obj)
|
||||||
|
|
||||||
|
# for name in remove_transfer_data:
|
||||||
|
# # TODO FIX THIS
|
||||||
|
# try:
|
||||||
|
# index = obj.transfer_data_ownership.keys().index(name)
|
||||||
|
# obj.transfer_data_ownership.remove(index)
|
||||||
|
# print(f"Remvoing {name} from {obj.name}")
|
||||||
|
# except:
|
||||||
|
# continue
|
||||||
|
|
||||||
return transfer_data_map
|
return transfer_data_map
|
||||||
|
@ -135,10 +135,9 @@ def merge_task_layer(
|
|||||||
for source_obj in map.object_map:
|
for source_obj in map.object_map:
|
||||||
target_obj = map.object_map[source_obj]
|
target_obj = map.object_map[source_obj]
|
||||||
# TODO Figure out why this doesn't work on Push only Pull currently
|
# TODO Figure out why this doesn't work on Push only Pull currently
|
||||||
if target_obj.asset_id_owner not in local_tls:
|
# transfer_core.copy_transfer_data(
|
||||||
transfer_core.copy_transfer_data(
|
# target_obj.transfer_data_ownership, source_obj.transfer_data_ownership
|
||||||
target_obj.transfer_data_ownership, source_obj.transfer_data_ownership
|
# )
|
||||||
)
|
|
||||||
remap_user(source_obj, target_obj)
|
remap_user(source_obj, target_obj)
|
||||||
transfer_core.transfer_data_clean(target_obj)
|
transfer_core.transfer_data_clean(target_obj)
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ def transfer_data_clean(obj):
|
|||||||
transfer_functions.uv_layer_clean(obj)
|
transfer_functions.uv_layer_clean(obj)
|
||||||
transfer_functions.modifiers_clean(obj)
|
transfer_functions.modifiers_clean(obj)
|
||||||
transfer_functions.constraints_clean(obj)
|
transfer_functions.constraints_clean(obj)
|
||||||
|
transfer_functions.material_slot_clean(obj)
|
||||||
|
|
||||||
|
|
||||||
def transfer_data_is_missing(transfer_data_item) -> bool:
|
def transfer_data_is_missing(transfer_data_item) -> bool:
|
||||||
|
@ -10,7 +10,7 @@ from .. import asset_suffix, constants
|
|||||||
def vertex_groups_clean(obj):
|
def vertex_groups_clean(obj):
|
||||||
transfer_data = obj.transfer_data_ownership
|
transfer_data = obj.transfer_data_ownership
|
||||||
for vertex_group in obj.vertex_groups:
|
for vertex_group in obj.vertex_groups:
|
||||||
if not transfer_data.get(vertex_group.name):
|
if not vertex_group.name in transfer_data.keys():
|
||||||
obj.vertex_groups.remove(vertex_group)
|
obj.vertex_groups.remove(vertex_group)
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ def vertex_colors_clean(obj):
|
|||||||
return
|
return
|
||||||
transfer_data = obj.transfer_data_ownership
|
transfer_data = obj.transfer_data_ownership
|
||||||
for vertex_color in obj.data.vertex_colors:
|
for vertex_color in obj.data.vertex_colors:
|
||||||
if not transfer_data.get(vertex_color.name):
|
if not asset_suffix.get_basename(vertex_color.name) in transfer_data.keys():
|
||||||
obj.vertex_colors.data.remove(vertex_color)
|
obj.vertex_colors.data.remove(vertex_color)
|
||||||
|
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ def uv_layer_clean(obj):
|
|||||||
return
|
return
|
||||||
transfer_data = obj.transfer_data_ownership
|
transfer_data = obj.transfer_data_ownership
|
||||||
for uv_layer in obj.data.uv_layers:
|
for uv_layer in obj.data.uv_layers:
|
||||||
if not transfer_data.get(uv_layer.name):
|
if not asset_suffix.get_basename(uv_layer.name) in transfer_data.keys():
|
||||||
obj.data.uv_layers.remove(uv_layer)
|
obj.data.uv_layers.remove(uv_layer)
|
||||||
|
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ def transfer_uv_layer(obj_source, obj_target, uv_name):
|
|||||||
def modifiers_clean(obj):
|
def modifiers_clean(obj):
|
||||||
transfer_data = obj.transfer_data_ownership
|
transfer_data = obj.transfer_data_ownership
|
||||||
for modifiers in obj.modifiers:
|
for modifiers in obj.modifiers:
|
||||||
if not transfer_data.get(modifiers.name):
|
if not modifiers.name in transfer_data.keys():
|
||||||
obj.modifiers.remove(modifiers)
|
obj.modifiers.remove(modifiers)
|
||||||
|
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ def transfer_modifier(transfer_info, obj_target):
|
|||||||
def constraints_clean(obj):
|
def constraints_clean(obj):
|
||||||
transfer_data = obj.transfer_data_ownership
|
transfer_data = obj.transfer_data_ownership
|
||||||
for constraint in obj.constraints:
|
for constraint in obj.constraints:
|
||||||
if not transfer_data.get(constraint.name):
|
if not constraint.name in transfer_data.keys():
|
||||||
obj.constraints.remove(constraint)
|
obj.constraints.remove(constraint)
|
||||||
|
|
||||||
|
|
||||||
@ -337,8 +337,10 @@ def transfer_constraint(transfer_info, obj_target):
|
|||||||
def material_slot_clean(obj):
|
def material_slot_clean(obj):
|
||||||
transfer_data = obj.transfer_data_ownership
|
transfer_data = obj.transfer_data_ownership
|
||||||
for mat_slot in obj.material_slots:
|
for mat_slot in obj.material_slots:
|
||||||
if not transfer_data.get(mat_slot.name):
|
if not asset_suffix.get_basename(mat_slot.name) in transfer_data.keys():
|
||||||
obj.material_slots.remove(mat_slot)
|
index = obj.material_slots.keys().index(mat_slot.name)
|
||||||
|
obj.active_material_index = index
|
||||||
|
bpy.ops.object.material_slot_remove({"object": obj})
|
||||||
|
|
||||||
|
|
||||||
def material_slot_is_missing(transfer_info):
|
def material_slot_is_missing(transfer_info):
|
||||||
|
@ -26,7 +26,9 @@ class ASSETPIPE_sync(bpy.types.Panel):
|
|||||||
layout.prop(status, "asset_collection", text="Asset")
|
layout.prop(status, "asset_collection", text="Asset")
|
||||||
layout.label(text="Test UI")
|
layout.label(text="Test UI")
|
||||||
layout.operator("assetpipe.publish_new_version")
|
layout.operator("assetpipe.publish_new_version")
|
||||||
layout.operator("assetpipe.sync_with_publish", text="Update Ownership")
|
layout.operator(
|
||||||
|
"assetpipe.sync_with_publish", text="Update Ownership"
|
||||||
|
).pull = False
|
||||||
layout.operator(
|
layout.operator(
|
||||||
"assetpipe.sync_with_publish", text="Push to Publish", icon="TRIA_UP"
|
"assetpipe.sync_with_publish", text="Push to Publish", icon="TRIA_UP"
|
||||||
).push = True
|
).push = True
|
||||||
|
Loading…
Reference in New Issue
Block a user