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 93 additions and 88 deletions
Showing only changes of commit a186ea8fa3 - Show all commits

View File

@ -3,7 +3,7 @@ import bpy
from . import transfer_functions from . import transfer_functions
def update_transfer_data(transfer_data_item, target_obj): def update_transfer_data_ownership(transfer_data_item, target_obj):
transfer_data_ownership = target_obj.transfer_data_ownership transfer_data_ownership = target_obj.transfer_data_ownership
transfer_items_names = [item.name for item in transfer_data_ownership] transfer_items_names = [item.name for item in transfer_data_ownership]
if transfer_data_item.name not in transfer_items_names: if transfer_data_item.name not in transfer_items_names:
@ -14,42 +14,8 @@ def update_transfer_data(transfer_data_item, target_obj):
new_item.id = transfer_data_item.id new_item.id = transfer_data_item.id
def push_task_layer( def apply_transfer_data(context, transfer_data_list, target_col, source_task_layer):
context, source_col, target_col, source_task_layer, target_task_layer for item in transfer_data_list:
):
# 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: for target_obj in target_col.objects:
if target_obj.name.split(".")[0] == item.id.name.split(".")[0]: if target_obj.name.split(".")[0] == item.id.name.split(".")[0]:
transfer_functions.transfer_vertex_group( transfer_functions.transfer_vertex_group(
@ -60,7 +26,88 @@ def push_task_layer(
f"{item.id.name.split('.')[0]}.{source_task_layer}" f"{item.id.name.split('.')[0]}.{source_task_layer}"
], ],
) )
update_transfer_data( update_transfer_data_ownership(
transfer_data_item=item, transfer_data_item=item,
target_obj=target_obj, target_obj=target_obj,
) )
def push_task_layer(
context: bpy.types.Collection,
source_col: bpy.types.Collection,
target_col: bpy.types.Collection,
source_tl: str,
target_tl: str,
):
# Find Obj owned by Current Task Layer
transfer_objs = []
transfer_data_list = []
for source_obj in source_col.objects:
if source_obj.asset_id_owner == source_tl:
transfer_objs.append(source_obj)
# Find Transfer-Data in current TL
for item in source_obj.transfer_data_ownership:
if item.owner == source_tl:
transfer_data_list.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_tl}" 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_tl}"
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
apply_transfer_data(context, transfer_data_list, target_col, source_tl)
def pull_task_layer(
context: bpy.types.Collection,
source_col: bpy.types.Collection,
target_col: bpy.types.Collection,
source_tl: str,
target_tl: str,
):
# Find Obj owned by other Current Task Layer
pull_objs = []
transfer_data = []
for obj in source_col.objects:
if obj.asset_id_owner != source_tl:
pull_objs.append(obj)
# Find Transfer-Data in other Task Layers
for item in obj.transfer_data_ownership:
if item.owner != source_tl:
transfer_data.append(item)
# TODO FIX SO I CAN REPLACE OBJ NOT JUST UPDATE IT
# Delete existing root OBJ
# for obj in publish_col.objects:
# obj_root_name = obj.name.split('.')[0]
# for pull_obj in pull_objs:
# if f"{obj_root_name}.{current_task_layer}" == pull_obj.name:
# bpy.data.objects.remove(obj)
# # # Link new obj to collection
# for obj in pull_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}.{target_tl}"
# target_col.objects.link(new_obj)
# TODO Move transferrable data onto obj owned by others
apply_transfer_data(context, transfer_data, target_col, source_tl)

View File

@ -1,6 +1,6 @@
import bpy import bpy
from . import transfer_functions, core from . import core
class ASSETPIPE_OT_update_ownership(bpy.types.Operator): class ASSETPIPE_OT_update_ownership(bpy.types.Operator):
@ -49,7 +49,6 @@ class ASSETPIPE_OT_pull_test(bpy.types.Operator):
def execute(self, context): def execute(self, context):
# Find current task Layer # Find current task Layer
obj = context.active_object
task_layer_col = context.collection task_layer_col = context.collection
current_task_layer = task_layer_col.name.split('.')[-1] current_task_layer = task_layer_col.name.split('.')[-1]
@ -58,53 +57,12 @@ class ASSETPIPE_OT_pull_test(bpy.types.Operator):
if "PUB" in col.name: if "PUB" in col.name:
publish_col = col publish_col = col
# Find Obj owned by other Current Task Layer core.pull_task_layer(
pull_objs = [] context,
transfer_data = [] source_col=publish_col,
for obj in publish_col.objects: target_col=task_layer_col,
if obj.asset_id_owner != current_task_layer: source_tl="PUB",
pull_objs.append(obj) target_tl=current_task_layer,
# Find Transfer-Data in other Task Layers
for item in obj.transfer_data_ownership:
if item.owner != current_task_layer:
transfer_data.append(item)
# Delete existing root OBJ
# TODO FIX
# for obj in publish_col.objects:
# obj_root_name = obj.name.split('.')[0]
# for pull_obj in pull_objs:
# if f"{obj_root_name}.{current_task_layer}" == pull_obj.name:
# bpy.data.objects.remove(obj)
# # Link new obj to collection
for obj in pull_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}.{current_task_layer}"
task_layer_col.objects.link(new_obj)
# Cosmetically move the obj for easier organization
# TODO Remove this step
new_obj.location[0] = 3
new_obj.location[2] = 0
# TODO Move transferrable data onto obj owned by others
for item in transfer_data:
for obj in task_layer_col.objects:
if obj.name.split(".")[0] == item.id.name.split(".")[0]:
transfer_functions.transfer_vertex_group(
context=context,
vertex_group_name=item.name,
source_obj=bpy.data.objects[
f"{item.id.name.split('.')[0]}.PUB"
],
target_obj=obj,
)
core.update_transfer_data(
transfer_data_item=item,
target_obj=obj,
) )
return {'FINISHED'} return {'FINISHED'}