Asset Pipeline v2 #145
@ -143,6 +143,7 @@ class AssetTransferMapping:
|
||||
name=transfer_data_item.name,
|
||||
td_type_key=transfer_data_item.type,
|
||||
task_layer_name=transfer_data_item.owner,
|
||||
surrender=transfer_data_item.surrender,
|
||||
)
|
||||
|
||||
map_item = {
|
||||
@ -173,6 +174,54 @@ class AssetTransferMapping:
|
||||
print("CONFLICT FOUND")
|
||||
return True
|
||||
|
||||
def transfer_data_map_surrendered(self, transfer_data_item):
|
||||
obj = transfer_data_item.id_data
|
||||
other_obj = bpy.data.objects.get(get_target_name(obj.name))
|
||||
other_transfer_data_item = None
|
||||
# Find Related Transfer Data Item on Target/Source Object
|
||||
for other_obj_transfer_data_item in other_obj.transfer_data_ownership:
|
||||
if other_obj_transfer_data_item.name == transfer_data_item.name:
|
||||
other_transfer_data_item = other_obj_transfer_data_item
|
||||
|
||||
# TODO CONSIDER PREFIXES
|
||||
|
||||
if not other_transfer_data_item:
|
||||
return None, None
|
||||
|
||||
# If the other transfer data is surrendered map it accordingly
|
||||
if (
|
||||
other_transfer_data_item.surrender
|
||||
and not transfer_data_item.surrender
|
||||
and other_transfer_data_item.owner != transfer_data_item.owner
|
||||
):
|
||||
if transfer_data_item.owner in self._local_tls:
|
||||
target_obj = obj
|
||||
source_obj = other_obj
|
||||
else:
|
||||
target_obj = other_obj
|
||||
source_obj = obj
|
||||
|
||||
return self._get_transfer_data_map_item(
|
||||
source_obj, target_obj, transfer_data_item
|
||||
)
|
||||
|
||||
if (
|
||||
transfer_data_item.surrender
|
||||
and not other_transfer_data_item.surrender
|
||||
and other_transfer_data_item.owner != transfer_data_item.owner
|
||||
):
|
||||
if other_transfer_data_item.owner in self._local_tls:
|
||||
target_obj = obj
|
||||
source_obj = other_obj
|
||||
else:
|
||||
target_obj = other_obj
|
||||
source_obj = obj
|
||||
|
||||
return self._get_transfer_data_map_item(
|
||||
source_obj, target_obj, other_transfer_data_item
|
||||
)
|
||||
return None, None
|
||||
|
||||
def _gen_transfer_data_map(self):
|
||||
context = bpy.context
|
||||
transfer_data_map: Dict[bpy.types.Collection, bpy.types.Collection] = {}
|
||||
@ -183,6 +232,13 @@ class AssetTransferMapping:
|
||||
objs = [source_obj, target_obj]
|
||||
for obj in objs:
|
||||
for transfer_data_item in obj.transfer_data_ownership:
|
||||
name, map_item = self.transfer_data_map_surrendered(
|
||||
transfer_data_item
|
||||
)
|
||||
if bool(name and map_item):
|
||||
transfer_data_map[name] = map_item
|
||||
continue
|
||||
|
||||
self._check_transfer_data_conflict(obj, transfer_data_item)
|
||||
if (
|
||||
transfer_data_item.owner in self._local_tls
|
||||
|
@ -102,6 +102,7 @@ def ownership_set(temp_transfer_data: bpy.types.CollectionProperty) -> None:
|
||||
transfer_data_item.name,
|
||||
transfer_data_item.type,
|
||||
transfer_data_item.owner,
|
||||
transfer_data_item.surrender,
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import bpy
|
||||
import contextlib
|
||||
from .. import constants
|
||||
from .. import config
|
||||
|
||||
@ -38,9 +39,16 @@ def get_transfer_data_owner(td_type_key: str, use_default_owner: bool, name=""):
|
||||
|
||||
|
||||
def draw_task_layer_selection(
|
||||
row, scene, data, data_owner, data_owner_name, use_default_owner=False
|
||||
row,
|
||||
scene,
|
||||
data,
|
||||
data_owner,
|
||||
data_owner_name,
|
||||
show_all_task_layers=False,
|
||||
show_local=False,
|
||||
):
|
||||
if use_default_owner == True:
|
||||
# TODO Simplify Arguments and add Type Hints / Doc String
|
||||
if show_all_task_layers == True:
|
||||
row.prop_search(
|
||||
data,
|
||||
data_owner_name,
|
||||
@ -49,7 +57,10 @@ def draw_task_layer_selection(
|
||||
text="",
|
||||
)
|
||||
return
|
||||
if data_owner not in [tl.name for tl in scene.asset_pipeline.local_task_layers]:
|
||||
if (
|
||||
data_owner not in [tl.name for tl in scene.asset_pipeline.local_task_layers]
|
||||
and not show_local
|
||||
):
|
||||
row.enabled = False
|
||||
row.prop_search(
|
||||
data,
|
||||
|
@ -33,6 +33,7 @@ def copy_transfer_data_ownership(
|
||||
transfer_data_item.name,
|
||||
transfer_data_item.type,
|
||||
transfer_data_item.owner,
|
||||
transfer_data_item.surrender,
|
||||
)
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ def draw_transfer_data_type(
|
||||
for transfer_data_item in transfer_data:
|
||||
row = box.row()
|
||||
row.label(text=f"{transfer_data_item.name}: ")
|
||||
|
||||
row.prop(transfer_data_item, "surrender")
|
||||
draw_task_layer_selection(
|
||||
row,
|
||||
scene,
|
||||
@ -36,6 +36,11 @@ def draw_transfer_data_type(
|
||||
"owner",
|
||||
transfer_data_item.get("use_default_owner"),
|
||||
)
|
||||
if transfer_data_item.get("surrender"):
|
||||
row.operator(
|
||||
"assetpipe.update_surrendered_transfer_data"
|
||||
).transfer_data_item_name = transfer_data_item.name
|
||||
row.enabled = True
|
||||
|
||||
|
||||
def draw_transfer_data(
|
||||
|
@ -29,6 +29,7 @@ def transfer_data_add_entry(
|
||||
name: str,
|
||||
td_type_key: str,
|
||||
task_layer_name: str,
|
||||
surrender: bool,
|
||||
):
|
||||
"""Add entry to transfer data ownership
|
||||
|
||||
@ -42,6 +43,7 @@ def transfer_data_add_entry(
|
||||
transfer_data_item.name = name
|
||||
transfer_data_item.owner = task_layer_name
|
||||
transfer_data_item.type = td_type_key
|
||||
transfer_data_item.surrender = surrender
|
||||
return transfer_data_item
|
||||
|
||||
|
||||
|
@ -2,7 +2,10 @@ import bpy
|
||||
from . import config
|
||||
import os
|
||||
from pathlib import Path
|
||||
from .merge.task_layer import set_local_task_layers
|
||||
from .merge.task_layer import (
|
||||
set_local_task_layers,
|
||||
draw_task_layer_selection,
|
||||
)
|
||||
from .merge.naming import get_name_with_task_layer_prefix
|
||||
from .merge.transfer_data.transfer_core import data_type_from_transfer_data_key
|
||||
from .merge.publish import get_next_published_file, find_all_published
|
||||
@ -480,6 +483,53 @@ class ASSETPIPE_OT_fix_prefixes(bpy.types.Operator):
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class ASSETPIPE_OT_update_surrendered_transfer_data(bpy.types.Operator):
|
||||
bl_idname = "assetpipe.update_surrendered_transfer_data"
|
||||
bl_label = "Update Surrendered"
|
||||
bl_description = """Update Surrended Transfer Data Owner"""
|
||||
|
||||
transfer_data_item_name: bpy.props.StringProperty(name="Transfer Data Item Name")
|
||||
|
||||
_surrendered_transfer_data = None
|
||||
_old_onwer = ""
|
||||
|
||||
def invoke(self, context: bpy.types.Context, event: bpy.types.Event):
|
||||
obj = context.active_object
|
||||
for transfer_data_item in obj.transfer_data_ownership:
|
||||
if transfer_data_item.name == self.transfer_data_item_name:
|
||||
self._surrendered_transfer_data = transfer_data_item
|
||||
self._old_onwer = self._surrendered_transfer_data.owner
|
||||
print(f"Found Surrended Item: {self._surrendered_transfer_data.name}")
|
||||
return context.window_manager.invoke_props_dialog(self, width=400)
|
||||
|
||||
def draw(self, context: bpy.types.Context):
|
||||
layout = self.layout
|
||||
row = layout.row()
|
||||
|
||||
draw_task_layer_selection(
|
||||
row,
|
||||
context.scene,
|
||||
self._surrendered_transfer_data,
|
||||
self._surrendered_transfer_data.owner,
|
||||
"owner",
|
||||
self._surrendered_transfer_data.get("use_default_owner"),
|
||||
True,
|
||||
)
|
||||
|
||||
def execute(self, context: bpy.types.Context):
|
||||
# TODO Report Cancelled if new owner not in local task layer
|
||||
if self._surrendered_transfer_data.owner == self._old_onwer:
|
||||
self.report(
|
||||
{'ERROR'},
|
||||
f"Transfer Data Owner was not updated",
|
||||
)
|
||||
return {'CANCELLED'}
|
||||
self._surrendered_transfer_data.surrender = False
|
||||
# TODO RENAME PREFIXES HERE
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
classes = (
|
||||
ASSETPIPE_OT_update_ownership,
|
||||
ASSETPIPE_OT_sync_push,
|
||||
@ -490,6 +540,7 @@ classes = (
|
||||
ASSETPIPE_OT_update_local_task_layers,
|
||||
ASSETPIPE_OT_revert_file,
|
||||
ASSETPIPE_OT_fix_prefixes,
|
||||
ASSETPIPE_OT_update_surrendered_transfer_data,
|
||||
)
|
||||
|
||||
|
||||
|
@ -32,6 +32,7 @@ class AssetTransferData(bpy.types.PropertyGroup):
|
||||
name="Transfer Data Type",
|
||||
items=constants.TRANSFER_DATA_TYPES_ENUM_ITEMS,
|
||||
)
|
||||
surrender: bpy.props.BoolProperty(name="Surrender Ownership", default=False)
|
||||
|
||||
|
||||
class AssetTransferDataTemp(bpy.types.PropertyGroup):
|
||||
@ -43,6 +44,7 @@ class AssetTransferDataTemp(bpy.types.PropertyGroup):
|
||||
name="Transfer Data Type",
|
||||
items=constants.TRANSFER_DATA_TYPES_ENUM_ITEMS,
|
||||
)
|
||||
surrender: bpy.props.BoolProperty(name="Surrender Ownership", default=False)
|
||||
obj: bpy.props.PointerProperty(type=bpy.types.Object)
|
||||
use_default_owner: bpy.props.BoolProperty(
|
||||
name="Defaults Ownership",
|
||||
|
Loading…
Reference in New Issue
Block a user