Asset Pipeline v2 #145

Closed
Nick Alberelli wants to merge 431 commits from (deleted):feature/asset-pipeline-v2 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 63 additions and 53 deletions
Showing only changes of commit 68e9a23a71 - Show all commits

View File

@ -1,11 +1,66 @@
import bpy
from . import transfer_functions
def update_transfer_data(transfer_data_item, target_obj):
transfer_data_ownership = target_obj.transfer_data_ownership
if transfer_data_item.name not in transfer_data_ownership.items():
transfer_items_names = [item.name for item in transfer_data_ownership]
if transfer_data_item.name not in transfer_items_names:
new_item = transfer_data_ownership.add()
new_item.name = transfer_data_item.name
new_item.owner = transfer_data_item.owner
new_item.type = transfer_data_item.type
new_item.id = transfer_data_item.id
def push_task_layer(
context, source_col, target_col, source_task_layer, target_task_layer
):
# Find Obj owned by Current Task Layer
transfer_objs = []
transfer_data = []
for source_obj in source_col.objects:
if source_obj.asset_id_owner == source_task_layer:
transfer_objs.append(source_obj)
# Find Transfer-Data in current TL
for item in source_obj.transfer_data_ownership:
if item.owner == source_task_layer:
transfer_data.append(item)
# Delete existing root OBJ
for target_obj in target_col.objects:
obj_root_name = target_obj.name.split('.')[0]
for push_obj in transfer_objs:
if f"{obj_root_name}.{target_task_layer}" in push_obj.name:
bpy.data.objects.remove(target_obj)
# Link new obj to collection
for transfer_obj in transfer_objs:
obj_root_name = transfer_obj.name.split('.')[0]
new_obj = transfer_obj.copy()
new_obj.data = transfer_obj.data.copy()
new_obj.name = f"{obj_root_name}.{target_task_layer}"
target_col.objects.link(new_obj)
# Cosmetically move the obj for easier organization
# TODO Remove this step
new_obj.location[0] = 0
new_obj.location[2] = 3
# Move transferrable data onto obj owned by others
for item in transfer_data:
for target_obj in target_col.objects:
if target_obj.name.split(".")[0] == item.id.name.split(".")[0]:
transfer_functions.transfer_vertex_group(
context=context,
vertex_group_name=item.name,
target_obj=target_obj,
source_obj=bpy.data.objects[
f"{item.id.name.split('.')[0]}.{source_task_layer}"
],
)
update_transfer_data(
transfer_data_item=item,
target_obj=target_obj,
)

View File

@ -29,62 +29,17 @@ class ASSETPIPE_OT_push_test(bpy.types.Operator):
def execute(self, context):
# Find current task Layer
obj = context.active_object
task_layer_col = context.collection
current_task_layer = task_layer_col.name.split('.')[-1]
source_col = context.collection
source_task_layer = source_col.name.split('.')[-1]
target_task_layer = "PUB"
# Find PUBLUSH Collection
for col in context.scene.collection.children_recursive:
if "PUB" in col.name:
publish_col = col
# Find Obj owned by Current Task Layer
push_objs = []
transfer_data = []
for obj in task_layer_col.objects:
if obj.asset_id_owner == current_task_layer:
push_objs.append(obj)
# Find Transfer-Data in current TL
for item in obj.transfer_data_ownership:
if item.owner == current_task_layer:
transfer_data.append(item)
# Delete existing root OBJ
for obj in publish_col.objects:
obj_root_name = obj.name.split('.')[0]
for push_obj in push_objs:
if f"{obj_root_name}.PUB" in push_obj.name:
bpy.data.objects.remove(obj)
# Link new obj to collection
for obj in push_objs:
obj_root_name = obj.name.split('.')[0]
new_obj = obj.copy()
new_obj.data = obj.data.copy()
new_obj.name = f"{obj_root_name}.PUB"
publish_col.objects.link(new_obj)
# Cosmetically move the obj for easier organization
# TODO Remove this step
new_obj.location[0] = 0
new_obj.location[2] = 3
# TODO Move transferrable data onto obj owned by others
for item in transfer_data:
for obj in publish_col.objects:
if obj.name.split(".")[0] == item.id.name.split(".")[0]:
transfer_functions.transfer_vertex_group(
context=context,
vertex_group_name=item.name,
target_obj=obj,
source_obj=bpy.data.objects[
f"{item.id.name.split('.')[0]}.{current_task_layer}"
],
)
core.update_transfer_data(
transfer_data_item=item,
target_obj=obj,
)
target_col = col
core.push_task_layer(
context, source_col, target_col, source_task_layer, target_task_layer
)
return {'FINISHED'}