Asset Pipeline v2 #145
@ -31,8 +31,7 @@ def ownership_transfer_data_cleanup(
|
||||
|
||||
def ownership_get(
|
||||
local_col: bpy.types.Collection,
|
||||
task_layer_name: str,
|
||||
temp_transfer_data: bpy.types.CollectionProperty,
|
||||
scene: bpy.types.Scene,
|
||||
) -> list[bpy.types.Object]:
|
||||
"""Find new transfer data owned by the local task layer.
|
||||
Marks items as owned by the local task layer if they are in the
|
||||
@ -49,6 +48,7 @@ def ownership_get(
|
||||
in the merge process
|
||||
"""
|
||||
invalid_objs = []
|
||||
task_layer_name = scene.asset_pipeline.task_layer_name
|
||||
task_layer_col_name = get_dict_tuple_item(
|
||||
constants.TASK_LAYER_TYPES, task_layer_name
|
||||
)[1]
|
||||
@ -62,7 +62,7 @@ def ownership_get(
|
||||
invalid_objs.append(obj)
|
||||
continue
|
||||
ownership_transfer_data_cleanup(obj, task_layer_name)
|
||||
transfer_core.get_transfer_data(obj, task_layer_name, temp_transfer_data)
|
||||
transfer_core.init_transfer_data(scene, obj)
|
||||
|
||||
return invalid_objs
|
||||
|
||||
|
@ -124,11 +124,7 @@ class ASSETPIPE_OT_sync_with_publish(bpy.types.Operator):
|
||||
self.report({'ERROR'}, "Current File Name doesn't contain valid task layer")
|
||||
return {'CANCELLED'}
|
||||
|
||||
self._invalid_objs = core.ownership_get(
|
||||
local_col,
|
||||
task_layer_name,
|
||||
self._temp_transfer_data,
|
||||
)
|
||||
self._invalid_objs = core.ownership_get(local_col, context.scene)
|
||||
|
||||
# Default behaviour is to pull before pushing
|
||||
if self.push:
|
||||
|
@ -54,6 +54,15 @@ class AssetPipeline(bpy.types.PropertyGroup):
|
||||
task_layer_name: bpy.props.EnumProperty(
|
||||
name="Task Layer Name", items=constants.TASK_LAYER_TYPES
|
||||
)
|
||||
|
||||
def add_temp_trasnfer_data(self, name, owner, type, obj):
|
||||
new_transfer_data = self.temp_transfer_data
|
||||
transfer_info = new_transfer_data.add()
|
||||
transfer_info.name = name
|
||||
transfer_info.owner = owner
|
||||
transfer_info.type = type
|
||||
transfer_info.obj = obj
|
||||
|
||||
## NEW FILE
|
||||
|
||||
dir: bpy.props.StringProperty(
|
||||
|
@ -51,7 +51,10 @@ def transfer_data_is_missing(transfer_data_item) -> bool:
|
||||
)
|
||||
|
||||
|
||||
def get_transfer_data(obj: bpy.types.Object, task_layer_name: str, temp_transfer_data):
|
||||
def init_transfer_data(
|
||||
scene: bpy.types.Scene,
|
||||
obj: bpy.types.Object,
|
||||
):
|
||||
"""Collect Transfer Data Items on a given object
|
||||
|
||||
Args:
|
||||
@ -59,12 +62,12 @@ def get_transfer_data(obj: bpy.types.Object, task_layer_name: str, temp_transfer
|
||||
task_layer_name (str): Name of task layer
|
||||
temp_transfer_data: Item of class ASSET_TRANSFER_DATA_TEMP
|
||||
"""
|
||||
transfer_functions.get_vertex_groups(obj, task_layer_name, temp_transfer_data)
|
||||
transfer_functions.get_material_slots(obj, task_layer_name, temp_transfer_data)
|
||||
transfer_functions.get_modifiers(obj, task_layer_name, temp_transfer_data)
|
||||
transfer_functions.get_constraints(obj, task_layer_name, temp_transfer_data)
|
||||
transfer_functions.get_vertex_colors(obj, task_layer_name, temp_transfer_data)
|
||||
transfer_functions.get_uv_layers(obj, task_layer_name, temp_transfer_data)
|
||||
transfer_functions.init_vertex_groups(scene, obj)
|
||||
transfer_functions.init_material_slots(scene, obj)
|
||||
transfer_functions.init_modifiers(scene, obj)
|
||||
transfer_functions.init_constraints(scene, obj)
|
||||
transfer_functions.init_vertex_colors(scene, obj)
|
||||
transfer_functions.init_uv_layers(scene, obj)
|
||||
|
||||
|
||||
def apply_transfer_data(context: bpy.types.Context, transfer_data_map) -> None:
|
||||
|
@ -21,19 +21,22 @@ def vertex_group_is_missing(transfer_info):
|
||||
return True
|
||||
|
||||
|
||||
def get_vertex_groups(obj, task_layer_name, new_transfer_data):
|
||||
def init_vertex_groups(scene, obj):
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
task_layer_name = scene.asset_pipeline.task_layer_name
|
||||
td_type = constants.VERTEX_GROUP_KEY
|
||||
for vertex_group in obj.vertex_groups:
|
||||
# Only add new ownership transfer_info if vertex group doesn't have an owner
|
||||
matches = transfer_core.check_transfer_data_entry(
|
||||
transfer_data, vertex_group.name, constants.VERTEX_GROUP_KEY
|
||||
transfer_data, vertex_group.name, td_type
|
||||
)
|
||||
if len(matches) == 0:
|
||||
transfer_info = new_transfer_data.add()
|
||||
transfer_info.name = vertex_group.name
|
||||
transfer_info.owner = task_layer_name
|
||||
transfer_info.type = constants.VERTEX_GROUP_KEY
|
||||
transfer_info.obj = obj
|
||||
scene.asset_pipeline.add_temp_trasnfer_data(
|
||||
name=vertex_group.name,
|
||||
owner=task_layer_name,
|
||||
type=td_type,
|
||||
obj=obj,
|
||||
)
|
||||
|
||||
|
||||
def transfer_vertex_group(
|
||||
@ -83,21 +86,24 @@ def vertex_color_is_missing(transfer_info):
|
||||
return True
|
||||
|
||||
|
||||
def get_vertex_colors(obj, task_layer_name, new_transfer_data):
|
||||
def init_vertex_colors(scene, obj):
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
task_layer_name = scene.asset_pipeline.task_layer_name
|
||||
td_type = constants.VERTEX_COLOR_KEY
|
||||
if not obj.type == "MESH":
|
||||
return
|
||||
for vertex_color in obj.data.vertex_colors:
|
||||
# Only add new ownership transfer_info if vertex color doesn't have an owner
|
||||
matches = transfer_core.check_transfer_data_entry(
|
||||
transfer_data, vertex_color.name, constants.VERTEX_COLOR_KEY
|
||||
transfer_data, vertex_color.name, td_type
|
||||
)
|
||||
if len(matches) == 0:
|
||||
transfer_info = new_transfer_data.add()
|
||||
transfer_info.name = vertex_color.name
|
||||
transfer_info.owner = task_layer_name
|
||||
transfer_info.type = constants.VERTEX_COLOR_KEY
|
||||
transfer_info.obj = obj
|
||||
scene.asset_pipeline.add_temp_trasnfer_data(
|
||||
name=vertex_color.name,
|
||||
owner=task_layer_name,
|
||||
type=td_type,
|
||||
obj=obj,
|
||||
)
|
||||
|
||||
|
||||
def transfer_vertex_color(
|
||||
@ -140,21 +146,24 @@ def uv_layer_is_missing(transfer_info):
|
||||
return True
|
||||
|
||||
|
||||
def get_uv_layers(obj, task_layer_name, new_transfer_data):
|
||||
def init_uv_layers(scene, obj):
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
task_layer_name = scene.asset_pipeline.task_layer_name
|
||||
td_type = constants.UV_LAYERS_KEY
|
||||
if not obj.type == "MESH":
|
||||
return
|
||||
for uv_layer in obj.data.uv_layers:
|
||||
# Only add new ownership transfer_info if vertex color doesn't have an owner
|
||||
matches = transfer_core.check_transfer_data_entry(
|
||||
transfer_data, uv_layer.name, constants.UV_LAYERS_KEY
|
||||
transfer_data, uv_layer.name, td_type
|
||||
)
|
||||
if len(matches) == 0:
|
||||
transfer_info = new_transfer_data.add()
|
||||
transfer_info.name = uv_layer.name
|
||||
transfer_info.owner = task_layer_name
|
||||
transfer_info.type = constants.UV_LAYERS_KEY
|
||||
transfer_info.obj = obj
|
||||
scene.asset_pipeline.add_temp_trasnfer_data(
|
||||
name=uv_layer.name,
|
||||
owner=task_layer_name,
|
||||
type=td_type,
|
||||
obj=obj,
|
||||
)
|
||||
|
||||
|
||||
def transfer_uv_layer(source_obj, target_obj, uv_name):
|
||||
@ -195,18 +204,21 @@ def modifier_is_missing(transfer_info):
|
||||
return True
|
||||
|
||||
|
||||
def get_modifiers(obj, task_layer_name, new_transfer_data):
|
||||
def init_modifiers(scene, obj):
|
||||
task_layer_name = scene.asset_pipeline.task_layer_name
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
td_type = constants.MODIFIER_KEY
|
||||
for mod in obj.modifiers:
|
||||
matches = transfer_core.check_transfer_data_entry(
|
||||
transfer_data, mod.name, constants.MODIFIER_KEY
|
||||
transfer_data, mod.name, td_type
|
||||
)
|
||||
if len(matches) == 0:
|
||||
transfer_info = new_transfer_data.add()
|
||||
transfer_info.name = mod.name
|
||||
transfer_info.owner = task_layer_name
|
||||
transfer_info.type = constants.MODIFIER_KEY
|
||||
transfer_info.obj = obj
|
||||
scene.asset_pipeline.add_temp_trasnfer_data(
|
||||
name=mod.name,
|
||||
owner=task_layer_name,
|
||||
type=td_type,
|
||||
obj=obj,
|
||||
)
|
||||
|
||||
|
||||
def transfer_modifier(modifier_name, target_obj, source_obj):
|
||||
@ -279,18 +291,21 @@ def constraint_is_missing(transfer_info):
|
||||
return True
|
||||
|
||||
|
||||
def get_constraints(obj, task_layer_name, new_transfer_data):
|
||||
def init_constraints(scene, obj):
|
||||
task_layer_name = scene.asset_pipeline.task_layer_name
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
for mod in obj.constraints:
|
||||
td_type = constants.CONSTRAINT_KEY
|
||||
for constraint in obj.constraints:
|
||||
matches = transfer_core.check_transfer_data_entry(
|
||||
transfer_data, mod.name, constants.CONSTRAINT_KEY
|
||||
transfer_data, constraint.name, td_type
|
||||
)
|
||||
if len(matches) == 0:
|
||||
transfer_info = new_transfer_data.add()
|
||||
transfer_info.name = mod.name
|
||||
transfer_info.owner = task_layer_name
|
||||
transfer_info.type = constants.CONSTRAINT_KEY
|
||||
transfer_info.obj = obj
|
||||
scene.asset_pipeline.add_temp_trasnfer_data(
|
||||
name=constraint.name,
|
||||
owner=task_layer_name,
|
||||
type=td_type,
|
||||
obj=obj,
|
||||
)
|
||||
|
||||
|
||||
def transfer_constraint(constraint_name, target_obj, source_obj):
|
||||
@ -344,18 +359,21 @@ def material_slot_is_missing(transfer_info):
|
||||
return True
|
||||
|
||||
|
||||
def get_material_slots(obj, task_layer_name, new_transfer_data):
|
||||
def init_material_slots(scene, obj):
|
||||
task_layer_name = scene.asset_pipeline.task_layer_name
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
td_type = constants.MATERIAL_SLOT_KEY
|
||||
for slot in obj.material_slots:
|
||||
matches = transfer_core.check_transfer_data_entry(
|
||||
transfer_data, slot.name, constants.MATERIAL_SLOT_KEY
|
||||
transfer_data, slot.name, td_type
|
||||
)
|
||||
if len(matches) == 0:
|
||||
transfer_info = new_transfer_data.add()
|
||||
transfer_info.name = slot.name
|
||||
transfer_info.owner = task_layer_name
|
||||
transfer_info.type = constants.MATERIAL_SLOT_KEY
|
||||
transfer_info.obj = obj
|
||||
scene.asset_pipeline.add_temp_trasnfer_data(
|
||||
name=slot.name,
|
||||
owner=task_layer_name,
|
||||
type=td_type,
|
||||
obj=obj,
|
||||
)
|
||||
|
||||
|
||||
def transfer_material_slot(material_slot_name, target_obj, source_obj):
|
||||
|
Loading…
Reference in New Issue
Block a user