Asset Pipeline v2 #145
@ -3,7 +3,6 @@ from ..merge.naming import task_layer_prefix_transfer_data_update
|
|||||||
from .asset_mapping import AssetTransferMapping
|
from .asset_mapping import AssetTransferMapping
|
||||||
from .transfer_data.transfer_core import (
|
from .transfer_data.transfer_core import (
|
||||||
init_transfer_data,
|
init_transfer_data,
|
||||||
init_transfer_data_with_defaults,
|
|
||||||
transfer_data_is_missing,
|
transfer_data_is_missing,
|
||||||
apply_transfer_data,
|
apply_transfer_data,
|
||||||
transfer_data_clean,
|
transfer_data_clean,
|
||||||
@ -81,8 +80,6 @@ def ownership_get(
|
|||||||
if obj.asset_id_owner == "NONE" and obj in task_layer_objs:
|
if obj.asset_id_owner == "NONE" and obj in task_layer_objs:
|
||||||
obj.asset_id_owner = default_task_layer
|
obj.asset_id_owner = default_task_layer
|
||||||
# obj.name = asset_prefix_name_get(obj.name)
|
# obj.name = asset_prefix_name_get(obj.name)
|
||||||
init_transfer_data_with_defaults(scene, obj)
|
|
||||||
continue
|
|
||||||
# Skip items that have no owner
|
# Skip items that have no owner
|
||||||
if obj.asset_id_owner == "NONE":
|
if obj.asset_id_owner == "NONE":
|
||||||
continue
|
continue
|
||||||
|
@ -15,13 +15,9 @@ def get_default_task_layer(td_type: str, name=""):
|
|||||||
def get_transfer_data_owner(
|
def get_transfer_data_owner(
|
||||||
asset_pipe: 'bpy.types.AssetPipeline',
|
asset_pipe: 'bpy.types.AssetPipeline',
|
||||||
td_type_key: str,
|
td_type_key: str,
|
||||||
use_default_owner: bool,
|
|
||||||
name="",
|
name="",
|
||||||
):
|
):
|
||||||
default_tl = get_default_task_layer(td_type_key, name)
|
default_tl = get_default_task_layer(td_type_key, name)
|
||||||
if use_default_owner:
|
|
||||||
return default_tl
|
|
||||||
else:
|
|
||||||
if default_tl in asset_pipe.get_local_task_layers():
|
if default_tl in asset_pipe.get_local_task_layers():
|
||||||
return default_tl
|
return default_tl
|
||||||
else:
|
else:
|
||||||
|
@ -76,34 +76,13 @@ def init_transfer_data(
|
|||||||
task_layer_name (str): Name of task layer
|
task_layer_name (str): Name of task layer
|
||||||
temp_transfer_data: Item of class ASSET_TRANSFER_DATA_TEMP
|
temp_transfer_data: Item of class ASSET_TRANSFER_DATA_TEMP
|
||||||
"""
|
"""
|
||||||
transfer_functions.init_vertex_groups(scene, obj, False)
|
transfer_functions.init_vertex_groups(scene, obj)
|
||||||
transfer_functions.init_material_slots(scene, obj, False)
|
transfer_functions.init_material_slots(scene, obj)
|
||||||
transfer_functions.init_modifiers(scene, obj, False)
|
transfer_functions.init_modifiers(scene, obj)
|
||||||
transfer_functions.init_constraints(scene, obj, False)
|
transfer_functions.init_constraints(scene, obj)
|
||||||
transfer_functions.init_shape_keys(scene, obj, False)
|
transfer_functions.init_shape_keys(scene, obj)
|
||||||
transfer_functions.init_attributes(scene, obj, False)
|
transfer_functions.init_attributes(scene, obj)
|
||||||
transfer_functions.init_parent(scene, obj, False)
|
transfer_functions.init_parent(scene, obj)
|
||||||
|
|
||||||
|
|
||||||
def init_transfer_data_with_defaults(
|
|
||||||
scene: bpy.types.Scene,
|
|
||||||
obj: bpy.types.Object,
|
|
||||||
):
|
|
||||||
"""Collect Transfer Data Items on a given object with default ownership data,
|
|
||||||
this can only be run on new objects
|
|
||||||
|
|
||||||
Args:
|
|
||||||
obj (bpy.types.Object): Target object for transfer data
|
|
||||||
task_layer_name (str): Name of task layer
|
|
||||||
temp_transfer_data: Item of class ASSET_TRANSFER_DATA_TEMP
|
|
||||||
"""
|
|
||||||
transfer_functions.init_vertex_groups(scene, obj, True)
|
|
||||||
transfer_functions.init_material_slots(scene, obj, True)
|
|
||||||
transfer_functions.init_modifiers(scene, obj, True)
|
|
||||||
transfer_functions.init_constraints(scene, obj, True)
|
|
||||||
transfer_functions.init_shape_keys(scene, obj, True)
|
|
||||||
transfer_functions.init_attributes(scene, obj, True)
|
|
||||||
transfer_functions.init_parent(scene, obj, True)
|
|
||||||
|
|
||||||
|
|
||||||
def apply_transfer_data(context: bpy.types.Context, transfer_data_map) -> None:
|
def apply_transfer_data(context: bpy.types.Context, transfer_data_map) -> None:
|
||||||
|
@ -35,13 +35,12 @@ def vertex_group_is_missing(transfer_data_item):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def init_vertex_groups(scene, obj, use_default_owner: bool):
|
def init_vertex_groups(scene, obj):
|
||||||
transfer_data_item_init(
|
transfer_data_item_init(
|
||||||
scene=scene,
|
scene=scene,
|
||||||
obj=obj,
|
obj=obj,
|
||||||
data_list=obj.vertex_groups,
|
data_list=obj.vertex_groups,
|
||||||
td_type_key=constants.VERTEX_GROUP_KEY,
|
td_type_key=constants.VERTEX_GROUP_KEY,
|
||||||
use_default_owner=use_default_owner,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -221,12 +220,13 @@ def modifier_is_missing(transfer_data_item):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def init_modifiers(scene, obj, use_default_owner: bool):
|
def init_modifiers(scene, obj):
|
||||||
asset_pipe = scene.asset_pipeline
|
asset_pipe = scene.asset_pipeline
|
||||||
td_type_key = constants.MODIFIER_KEY
|
td_type_key = constants.MODIFIER_KEY
|
||||||
transfer_data = obj.transfer_data_ownership
|
transfer_data = obj.transfer_data_ownership
|
||||||
task_layer_owner = get_transfer_data_owner(
|
task_layer_owner = get_transfer_data_owner(
|
||||||
asset_pipe, td_type_key, use_default_owner
|
asset_pipe,
|
||||||
|
td_type_key,
|
||||||
)
|
)
|
||||||
for mod in obj.modifiers:
|
for mod in obj.modifiers:
|
||||||
mod.name = task_layer_prefix_name_get(mod.name, task_layer_owner)
|
mod.name = task_layer_prefix_name_get(mod.name, task_layer_owner)
|
||||||
@ -238,7 +238,6 @@ def init_modifiers(scene, obj, use_default_owner: bool):
|
|||||||
owner=task_layer_owner,
|
owner=task_layer_owner,
|
||||||
type=td_type_key,
|
type=td_type_key,
|
||||||
obj=obj,
|
obj=obj,
|
||||||
use_default_owner=use_default_owner,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -321,12 +320,13 @@ def constraint_is_missing(transfer_data_item):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def init_constraints(scene, obj, use_default_owner: bool):
|
def init_constraints(scene, obj):
|
||||||
td_type_key = constants.CONSTRAINT_KEY
|
td_type_key = constants.CONSTRAINT_KEY
|
||||||
transfer_data = obj.transfer_data_ownership
|
transfer_data = obj.transfer_data_ownership
|
||||||
asset_pipe = scene.asset_pipeline
|
asset_pipe = scene.asset_pipeline
|
||||||
task_layer_owner = get_transfer_data_owner(
|
task_layer_owner = get_transfer_data_owner(
|
||||||
asset_pipe, td_type_key, use_default_owner
|
asset_pipe,
|
||||||
|
td_type_key,
|
||||||
)
|
)
|
||||||
for const in obj.constraints:
|
for const in obj.constraints:
|
||||||
const.name = task_layer_prefix_name_get(const.name, task_layer_owner)
|
const.name = task_layer_prefix_name_get(const.name, task_layer_owner)
|
||||||
@ -338,7 +338,6 @@ def init_constraints(scene, obj, use_default_owner: bool):
|
|||||||
owner=task_layer_owner,
|
owner=task_layer_owner,
|
||||||
type=td_type_key,
|
type=td_type_key,
|
||||||
obj=obj,
|
obj=obj,
|
||||||
use_default_owner=use_default_owner,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -417,7 +416,7 @@ def material_slots_is_missing(transfer_data_item):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def init_material_slots(scene, obj, use_default_owner: bool):
|
def init_material_slots(scene, obj):
|
||||||
asset_pipe = scene.asset_pipeline
|
asset_pipe = scene.asset_pipeline
|
||||||
td_type_key = constants.MATERIAL_SLOT_KEY
|
td_type_key = constants.MATERIAL_SLOT_KEY
|
||||||
name = constants.MATERIAL_TRANSFER_DATA_ITEM_NAME
|
name = constants.MATERIAL_TRANSFER_DATA_ITEM_NAME
|
||||||
@ -441,10 +440,9 @@ def init_material_slots(scene, obj, use_default_owner: bool):
|
|||||||
if len(matches) == 0:
|
if len(matches) == 0:
|
||||||
asset_pipe.add_temp_transfer_data(
|
asset_pipe.add_temp_transfer_data(
|
||||||
name=name,
|
name=name,
|
||||||
owner=get_transfer_data_owner(asset_pipe, td_type_key, use_default_owner),
|
owner=get_transfer_data_owner(asset_pipe, td_type_key),
|
||||||
type=td_type_key,
|
type=td_type_key,
|
||||||
obj=obj,
|
obj=obj,
|
||||||
use_default_owner=use_default_owner,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -543,7 +541,7 @@ def shape_key_is_missing(transfer_data_item):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def init_shape_keys(scene, obj, use_default_owner: bool):
|
def init_shape_keys(scene, obj):
|
||||||
if obj.type != "MESH" or obj.data.shape_keys is None:
|
if obj.type != "MESH" or obj.data.shape_keys is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -562,7 +560,6 @@ def init_shape_keys(scene, obj, use_default_owner: bool):
|
|||||||
obj=obj,
|
obj=obj,
|
||||||
data_list=obj.data.shape_keys.key_blocks,
|
data_list=obj.data.shape_keys.key_blocks,
|
||||||
td_type_key=constants.SHAPE_KEY_KEY,
|
td_type_key=constants.SHAPE_KEY_KEY,
|
||||||
use_default_owner=use_default_owner,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -695,7 +692,7 @@ def attribute_is_missing(transfer_data_item):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def init_attributes(scene, obj, use_default_owner: bool):
|
def init_attributes(scene, obj):
|
||||||
asset_pipe = scene.asset_pipeline
|
asset_pipe = scene.asset_pipeline
|
||||||
if obj.type != "MESH":
|
if obj.type != "MESH":
|
||||||
return
|
return
|
||||||
@ -707,12 +704,9 @@ def init_attributes(scene, obj, use_default_owner: bool):
|
|||||||
if len(matches) == 0:
|
if len(matches) == 0:
|
||||||
asset_pipe.add_temp_transfer_data(
|
asset_pipe.add_temp_transfer_data(
|
||||||
name=atttribute.name,
|
name=atttribute.name,
|
||||||
owner=get_transfer_data_owner(
|
owner=get_transfer_data_owner(asset_pipe, td_type_key, atttribute.name),
|
||||||
asset_pipe, td_type_key, use_default_owner, atttribute.name
|
|
||||||
),
|
|
||||||
type=td_type_key,
|
type=td_type_key,
|
||||||
obj=obj,
|
obj=obj,
|
||||||
use_default_owner=use_default_owner,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -768,7 +762,7 @@ def parent_is_missing(transfer_data_item):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def init_parent(scene, obj, use_default_owner: bool):
|
def init_parent(scene, obj):
|
||||||
asset_pipe = scene.asset_pipeline
|
asset_pipe = scene.asset_pipeline
|
||||||
td_type_key = constants.PARENT_KEY
|
td_type_key = constants.PARENT_KEY
|
||||||
name = constants.PARENT_TRANSFER_DATA_ITEM_NAME
|
name = constants.PARENT_TRANSFER_DATA_ITEM_NAME
|
||||||
@ -782,10 +776,9 @@ def init_parent(scene, obj, use_default_owner: bool):
|
|||||||
if len(matches) == 0:
|
if len(matches) == 0:
|
||||||
asset_pipe.add_temp_transfer_data(
|
asset_pipe.add_temp_transfer_data(
|
||||||
name=name,
|
name=name,
|
||||||
owner=get_transfer_data_owner(asset_pipe, td_type_key, use_default_owner),
|
owner=get_transfer_data_owner(asset_pipe, td_type_key),
|
||||||
type=td_type_key,
|
type=td_type_key,
|
||||||
obj=obj,
|
obj=obj,
|
||||||
use_default_owner=use_default_owner,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,7 +48,6 @@ def draw_transfer_data_type(
|
|||||||
draw_task_layer_selection(
|
draw_task_layer_selection(
|
||||||
layout=task_layer_row,
|
layout=task_layer_row,
|
||||||
data=transfer_data_item,
|
data=transfer_data_item,
|
||||||
show_all_task_layers=transfer_data_item.get("use_default_owner"),
|
|
||||||
)
|
)
|
||||||
surrender_icon = (
|
surrender_icon = (
|
||||||
"ORPHAN_DATA" if transfer_data_item.get("surrender") else "HEART"
|
"ORPHAN_DATA" if transfer_data_item.get("surrender") else "HEART"
|
||||||
|
@ -94,7 +94,6 @@ def transfer_data_item_init(
|
|||||||
obj: bpy.types.Object,
|
obj: bpy.types.Object,
|
||||||
data_list: bpy.types.CollectionProperty,
|
data_list: bpy.types.CollectionProperty,
|
||||||
td_type_key: str,
|
td_type_key: str,
|
||||||
use_default_owner=bool,
|
|
||||||
):
|
):
|
||||||
"""_summary_
|
"""_summary_
|
||||||
|
|
||||||
@ -114,9 +113,9 @@ def transfer_data_item_init(
|
|||||||
asset_pipe.add_temp_transfer_data(
|
asset_pipe.add_temp_transfer_data(
|
||||||
name=item.name,
|
name=item.name,
|
||||||
owner=get_transfer_data_owner(
|
owner=get_transfer_data_owner(
|
||||||
asset_pipe, td_type_key, use_default_owner
|
asset_pipe,
|
||||||
|
td_type_key,
|
||||||
),
|
),
|
||||||
type=td_type_key,
|
type=td_type_key,
|
||||||
obj=obj,
|
obj=obj,
|
||||||
use_default_owner=use_default_owner,
|
|
||||||
)
|
)
|
||||||
|
@ -597,9 +597,6 @@ class ASSETPIPE_OT_update_surrendered_transfer_data(bpy.types.Operator):
|
|||||||
draw_task_layer_selection(
|
draw_task_layer_selection(
|
||||||
layout=row,
|
layout=row,
|
||||||
data=self._surrendered_transfer_data,
|
data=self._surrendered_transfer_data,
|
||||||
show_all_task_layers=self._surrendered_transfer_data.get(
|
|
||||||
"use_default_owner"
|
|
||||||
),
|
|
||||||
show_local_task_layers=True,
|
show_local_task_layers=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -47,11 +47,6 @@ class AssetTransferDataTemp(bpy.types.PropertyGroup):
|
|||||||
)
|
)
|
||||||
surrender: bpy.props.BoolProperty(name="Surrender Ownership", default=False)
|
surrender: bpy.props.BoolProperty(name="Surrender Ownership", default=False)
|
||||||
obj: bpy.props.PointerProperty(type=bpy.types.Object)
|
obj: bpy.props.PointerProperty(type=bpy.types.Object)
|
||||||
use_default_owner: bpy.props.BoolProperty(
|
|
||||||
name="Defaults Ownership",
|
|
||||||
description="Default ownership has been used when initializing these properties",
|
|
||||||
default=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TaskLayerSettings(bpy.types.PropertyGroup):
|
class TaskLayerSettings(bpy.types.PropertyGroup):
|
||||||
@ -79,14 +74,13 @@ class AssetPipeline(bpy.types.PropertyGroup):
|
|||||||
|
|
||||||
temp_transfer_data: bpy.props.CollectionProperty(type=AssetTransferDataTemp)
|
temp_transfer_data: bpy.props.CollectionProperty(type=AssetTransferDataTemp)
|
||||||
|
|
||||||
def add_temp_transfer_data(self, name, owner, type, obj, use_default_owner=False):
|
def add_temp_transfer_data(self, name, owner, type, obj):
|
||||||
new_transfer_data = self.temp_transfer_data
|
new_transfer_data = self.temp_transfer_data
|
||||||
transfer_data_item = new_transfer_data.add()
|
transfer_data_item = new_transfer_data.add()
|
||||||
transfer_data_item.name = name
|
transfer_data_item.name = name
|
||||||
transfer_data_item.owner = owner
|
transfer_data_item.owner = owner
|
||||||
transfer_data_item.type = type
|
transfer_data_item.type = type
|
||||||
transfer_data_item.obj = obj
|
transfer_data_item.obj = obj
|
||||||
transfer_data_item.use_default_owner = use_default_owner
|
|
||||||
|
|
||||||
## NEW FILE
|
## NEW FILE
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user