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.
6 changed files with 75 additions and 17 deletions
Showing only changes of commit 18bf74e2b3 - Show all commits

View File

@ -0,0 +1,11 @@
import bpy
def update_transfer_data(transfer_data_item, target_obj):
transfer_data_ownership = target_obj.transfer_data_ownership
if transfer_data_item not in transfer_data_ownership.items():
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

View File

@ -1,5 +1,7 @@
import bpy
from . import transfer_functions, core
class ASSETPIPE_OT_update_ownership(bpy.types.Operator):
bl_idname = "assetpipe.update_ownership"
@ -7,13 +9,17 @@ class ASSETPIPE_OT_update_ownership(bpy.types.Operator):
def execute(self, context):
obj = context.active_object
ownership = context.active_object.asset_ownership
ownership = context.active_object.transfer_data_ownership
task_layer_name = obj.name.split(".")[-1]
for vertex_group in obj.vertex_groups:
if not vertex_group.name in [item.name for item in ownership]:
item = ownership.add()
item.name = vertex_group.name
item.owner = task_layer_name.upper()
item.type = "VERTEX_GROUP" # TODO Make procedural
item.id = bpy.data.objects[
f"{obj.name.split('.')[0]}.{obj.asset_id_owner}"
]
return {'FINISHED'}
@ -33,19 +39,25 @@ class ASSETPIPE_OT_push_test(bpy.types.Operator):
publish_col = col
# Find Obj owned by Current Task Layer
push_obj = []
push_objs = []
transfer_data = []
for obj in task_layer_col.objects:
if obj.asset_id_owner == current_task_layer:
push_obj.append(obj)
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]
if f"{obj_root_name}.PUB" in obj.name:
bpy.data.objects.remove(obj)
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_obj:
for obj in push_objs:
obj_root_name = obj.name.split('.')[0]
new_obj = obj.copy()
new_obj.data = obj.data.copy()
@ -58,10 +70,21 @@ class ASSETPIPE_OT_push_test(bpy.types.Operator):
new_obj.location[2] = 3
# TODO Move transferrable data onto obj owned by others
# Find Transfer-Data in current TL
# Find matching Target Object in Publish
# Copy Transfer-Data
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,
)
return {'FINISHED'}

View File

@ -8,7 +8,9 @@ avaliable task layers from the task_layer_defaults.json file that needs to be cr
# items=[("MODEL", "Rigging", ""), ("RIG", "Modeling", "")],
class ASSETOWNERSHIP(bpy.types.PropertyGroup):
owner: bpy.props.StringProperty(name="ID Owner", default="")
owner: bpy.props.StringProperty(name="Transfer Data Owner", default="")
type: bpy.props.StringProperty(name="Transfer Data Type", default="")
id: bpy.props.PointerProperty(type=bpy.types.Object)
classes = (ASSETOWNERSHIP,)
@ -17,7 +19,9 @@ classes = (ASSETOWNERSHIP,)
def register():
for i in classes:
bpy.utils.register_class(i)
bpy.types.Object.asset_ownership = bpy.props.CollectionProperty(type=ASSETOWNERSHIP)
bpy.types.Object.transfer_data_ownership = bpy.props.CollectionProperty(
type=ASSETOWNERSHIP
)
bpy.types.Object.asset_id_owner = bpy.props.EnumProperty(
name="ID Owner",
items=[("NONE", "None", ""), ("MODEL", "Modeling", ""), ("RIG", "Rigging", "")],
@ -27,4 +31,4 @@ def register():
def unregister():
for i in classes:
bpy.utils.unregister_class(i)
del bpy.types.Object.asset_ownership
del bpy.types.Object.transfer_data_ownership

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9224d4dbb2b5f169ca9cf98d3da89dfd550167c7384575ecdc1a473adbb9e814
size 901508
oid sha256:64c2d168bfc8b4c7234cbf48c1b0fdf36cafa0386ec236eaace4a02a0e3d2dae
size 920988

View File

@ -0,0 +1,18 @@
import bpy
from bpy import context
def transfer_vertex_group(context, vertex_group_name:str, target_obj:bpy.types.Object, source_obj:bpy.types.Object):
source_obj.vertex_groups.active = source_obj.vertex_groups[vertex_group_name]
override = context.copy()
override["selected_editable_objects"] = [target_obj, source_obj]
override["active_object"] = source_obj
override["object"] = source_obj #TODO test if needed
with context.temp_override(**override ):
bpy.ops.object.data_transfer(
data_type="VGROUP_WEIGHTS",
use_create=True,
vert_mapping='POLYINTERP_NEAREST',
layers_select_src="ACTIVE",
layers_select_dst="NAME",
mix_mode="REPLACE",
)

View File

@ -19,10 +19,12 @@ class ASSETPIPE_PT_TestUI(bpy.types.Panel):
if not context.active_object:
return
obj = context.active_object
ownership = obj.asset_ownership
ownership = obj.transfer_data_ownership
self.layout.prop(obj, "asset_id_owner")
for my_item in ownership:
self.layout.label(text=f"{my_item.name} : {my_item.owner}")
self.layout.label(
text=f"{my_item.name} : {my_item.owner} : {my_item.id.name}"
)
classes = (ASSETPIPE_PT_TestUI,)