Asset Pipeline v2 #145
@ -37,6 +37,7 @@ class AssetTransferMapping:
|
|||||||
self.external_col_to_remove: Set[bpy.types.Object] = set()
|
self.external_col_to_remove: Set[bpy.types.Object] = set()
|
||||||
self.external_col_to_add: Set[bpy.types.Object] = set()
|
self.external_col_to_add: Set[bpy.types.Object] = set()
|
||||||
self.external_obj_to_add: Set[bpy.types.Object] = set()
|
self.external_obj_to_add: Set[bpy.types.Object] = set()
|
||||||
|
self.surrendered_obj_to_remove: Set[bpy.types.Object] = set()
|
||||||
self._no_match_source_objs: Set[bpy.types.Object] = set()
|
self._no_match_source_objs: Set[bpy.types.Object] = set()
|
||||||
|
|
||||||
self._no_match_source_colls: Set[bpy.types.Object] = set()
|
self._no_match_source_colls: Set[bpy.types.Object] = set()
|
||||||
@ -65,7 +66,9 @@ class AssetTransferMapping:
|
|||||||
return external_obj
|
return external_obj
|
||||||
|
|
||||||
def _check_id_conflict(self, external_id, local_id):
|
def _check_id_conflict(self, external_id, local_id):
|
||||||
if external_id.asset_id_owner != local_id.asset_id_owner:
|
if external_id.asset_id_owner != local_id.asset_id_owner and (
|
||||||
|
local_id.asset_id_surrender == external_id.asset_id_owner
|
||||||
|
):
|
||||||
self.conflict_ids.append(local_id)
|
self.conflict_ids.append(local_id)
|
||||||
|
|
||||||
def _gen_object_map(self) -> Dict[bpy.types.Object, bpy.types.Object]:
|
def _gen_object_map(self) -> Dict[bpy.types.Object, bpy.types.Object]:
|
||||||
@ -84,9 +87,23 @@ class AssetTransferMapping:
|
|||||||
self._check_id_conflict(external_obj, local_obj)
|
self._check_id_conflict(external_obj, local_obj)
|
||||||
# IF ITEM IS OWNED BY LOCAL TASK LAYERS
|
# IF ITEM IS OWNED BY LOCAL TASK LAYERS
|
||||||
if local_obj.asset_id_owner in self._local_tls:
|
if local_obj.asset_id_owner in self._local_tls:
|
||||||
|
if (
|
||||||
|
local_obj.asset_id_surrender
|
||||||
|
and not external_obj.asset_id_surrender
|
||||||
|
and local_obj.asset_id_owner != external_obj.asset_id_owner
|
||||||
|
):
|
||||||
|
self.surrendered_obj_to_remove.add(local_obj)
|
||||||
|
continue
|
||||||
object_map[external_obj] = local_obj
|
object_map[external_obj] = local_obj
|
||||||
# IF ITEM IS NOT OWNED BY LOCAL TASK LAYERS
|
# IF ITEM IS NOT OWNED BY LOCAL TASK LAYERS
|
||||||
else:
|
else:
|
||||||
|
if (
|
||||||
|
external_obj.asset_id_surrender
|
||||||
|
and not local_obj.asset_id_surrender
|
||||||
|
and local_obj.asset_id_owner != external_obj.asset_id_owner
|
||||||
|
):
|
||||||
|
self.surrendered_obj_to_remove.add(external_obj)
|
||||||
|
continue
|
||||||
object_map[local_obj] = external_obj
|
object_map[local_obj] = external_obj
|
||||||
|
|
||||||
# Find new objects to add to local_col
|
# Find new objects to add to local_col
|
||||||
|
@ -462,6 +462,47 @@ class ASSETPIPE_OT_fix_prefixes(bpy.types.Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
class ASSETPIPE_OT_update_surrendered_object(bpy.types.Operator):
|
||||||
|
bl_idname = "assetpipe.update_surrendered_object"
|
||||||
|
bl_label = "Update Surrendered"
|
||||||
|
bl_description = """Update Surrended Object Owner"""
|
||||||
|
|
||||||
|
# TODO This is throwing an error
|
||||||
|
obj: bpy.props.PointerProperty(type=bpy.types.Object)
|
||||||
|
|
||||||
|
_surrendered_transfer_data = None
|
||||||
|
_old_onwer = ""
|
||||||
|
|
||||||
|
def invoke(self, context: bpy.types.Context, event: bpy.types.Event):
|
||||||
|
self.obj = context.active_object
|
||||||
|
self._old_onwer = self.obj.asset_id_owner
|
||||||
|
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.obj,
|
||||||
|
self.obj.asset_id_owner,
|
||||||
|
"asset_id_owner",
|
||||||
|
False,
|
||||||
|
True,
|
||||||
|
)
|
||||||
|
|
||||||
|
def execute(self, context: bpy.types.Context):
|
||||||
|
if self.obj.asset_id_owner == self._old_onwer:
|
||||||
|
self.report(
|
||||||
|
{'ERROR'},
|
||||||
|
f"Object Owner was not updated",
|
||||||
|
)
|
||||||
|
return {'CANCELLED'}
|
||||||
|
self.obj.asset_id_surrender = False
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class ASSETPIPE_OT_update_surrendered_transfer_data(bpy.types.Operator):
|
class ASSETPIPE_OT_update_surrendered_transfer_data(bpy.types.Operator):
|
||||||
bl_idname = "assetpipe.update_surrendered_transfer_data"
|
bl_idname = "assetpipe.update_surrendered_transfer_data"
|
||||||
bl_label = "Update Surrendered"
|
bl_label = "Update Surrendered"
|
||||||
@ -721,6 +762,7 @@ classes = (
|
|||||||
ASSETPIPE_OT_update_local_task_layers,
|
ASSETPIPE_OT_update_local_task_layers,
|
||||||
ASSETPIPE_OT_revert_file,
|
ASSETPIPE_OT_revert_file,
|
||||||
ASSETPIPE_OT_fix_prefixes,
|
ASSETPIPE_OT_fix_prefixes,
|
||||||
|
ASSETPIPE_OT_update_surrendered_object,
|
||||||
ASSETPIPE_OT_update_surrendered_transfer_data,
|
ASSETPIPE_OT_update_surrendered_transfer_data,
|
||||||
ASSETPIPE_OT_batch_ownership_change,
|
ASSETPIPE_OT_batch_ownership_change,
|
||||||
)
|
)
|
||||||
|
@ -142,6 +142,9 @@ def register():
|
|||||||
)
|
)
|
||||||
bpy.types.Scene.asset_pipeline = bpy.props.PointerProperty(type=AssetPipeline)
|
bpy.types.Scene.asset_pipeline = bpy.props.PointerProperty(type=AssetPipeline)
|
||||||
bpy.types.ID.asset_id_owner = bpy.props.StringProperty(name="Owner", default="NONE")
|
bpy.types.ID.asset_id_owner = bpy.props.StringProperty(name="Owner", default="NONE")
|
||||||
|
bpy.types.ID.asset_id_surrender = bpy.props.BoolProperty(
|
||||||
|
name="Surrender Ownership", default=False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
|
@ -5,6 +5,7 @@ from .merge.transfer_data.transfer_ui import draw_transfer_data
|
|||||||
from .merge.task_layer import draw_task_layer_selection
|
from .merge.task_layer import draw_task_layer_selection
|
||||||
from .config import verify_json_data
|
from .config import verify_json_data
|
||||||
from . import constants
|
from . import constants
|
||||||
|
from .merge.task_layer import get_local_task_layers
|
||||||
|
|
||||||
|
|
||||||
class ASSETPIPE_PT_sync(bpy.types.Panel):
|
class ASSETPIPE_PT_sync(bpy.types.Panel):
|
||||||
@ -127,7 +128,16 @@ class ASSETPIPE_PT_ownership_inspector(bpy.types.Panel):
|
|||||||
layout = layout.box()
|
layout = layout.box()
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.label(text=f"{obj.name}: ", icon="OBJECT_DATA")
|
row.label(text=f"{obj.name}: ", icon="OBJECT_DATA")
|
||||||
draw_task_layer_selection(row, scene, obj, obj.asset_id_owner, "asset_id_owner")
|
|
||||||
|
if obj.get("asset_id_surrender"):
|
||||||
|
enabled = False if obj.asset_id_owner in get_local_task_layers() else True
|
||||||
|
row.operator("assetpipe.update_surrendered_object")
|
||||||
|
row.enabled = enabled
|
||||||
|
else:
|
||||||
|
row.prop(obj, "asset_id_surrender", text="Surrender")
|
||||||
|
draw_task_layer_selection(
|
||||||
|
row, scene, obj, obj.asset_id_owner, "asset_id_owner"
|
||||||
|
)
|
||||||
draw_transfer_data(transfer_data, layout)
|
draw_transfer_data(transfer_data, layout)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user