Asset Pipeline v2 #145
@ -3,7 +3,7 @@ import bpy
|
||||
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_items_names = [item.name for item in transfer_data_ownership]
|
||||
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
|
||||
|
||||
|
||||
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:
|
||||
def apply_transfer_data(context, transfer_data_list, target_col, source_task_layer):
|
||||
for item in transfer_data_list:
|
||||
for target_obj in target_col.objects:
|
||||
if target_obj.name.split(".")[0] == item.id.name.split(".")[0]:
|
||||
transfer_functions.transfer_vertex_group(
|
||||
@ -60,7 +26,88 @@ def push_task_layer(
|
||||
f"{item.id.name.split('.')[0]}.{source_task_layer}"
|
||||
],
|
||||
)
|
||||
update_transfer_data(
|
||||
update_transfer_data_ownership(
|
||||
transfer_data_item=item,
|
||||
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)
|
||||
|
@ -1,6 +1,6 @@
|
||||
import bpy
|
||||
|
||||
from . import transfer_functions, core
|
||||
from . import core
|
||||
|
||||
|
||||
class ASSETPIPE_OT_update_ownership(bpy.types.Operator):
|
||||
@ -49,7 +49,6 @@ class ASSETPIPE_OT_pull_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]
|
||||
|
||||
@ -58,54 +57,13 @@ class ASSETPIPE_OT_pull_test(bpy.types.Operator):
|
||||
if "PUB" in col.name:
|
||||
publish_col = col
|
||||
|
||||
# Find Obj owned by other Current Task Layer
|
||||
pull_objs = []
|
||||
transfer_data = []
|
||||
for obj in publish_col.objects:
|
||||
if obj.asset_id_owner != current_task_layer:
|
||||
pull_objs.append(obj)
|
||||
# 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,
|
||||
)
|
||||
core.pull_task_layer(
|
||||
context,
|
||||
source_col=publish_col,
|
||||
target_col=task_layer_col,
|
||||
source_tl="PUB",
|
||||
target_tl=current_task_layer,
|
||||
)
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user