Asset Pipeline v2 #145
@ -4,12 +4,18 @@ from .. import constants
|
||||
from .. import config
|
||||
|
||||
|
||||
def get_default_task_layer(td_type: str, name=""):
|
||||
def get_default_task_layer_owner(td_type: str, name="") -> [str, bool]:
|
||||
if td_type == constants.ATTRIBUTE_KEY:
|
||||
if name in config.DEFAULT_OWNERSHIP_ATTRIBUTES:
|
||||
return config.DEFAULT_OWNERSHIP_ATTRIBUTES[name]['default_owner']
|
||||
return (
|
||||
config.DEFAULT_OWNERSHIP_ATTRIBUTES[name]['default_owner'],
|
||||
config.DEFAULT_OWNERSHIP_ATTRIBUTES[name]['auto_surrender'],
|
||||
)
|
||||
print(config.DEFAULT_OWNERSHIP[td_type]['default_owner'])
|
||||
return config.DEFAULT_OWNERSHIP[td_type]['default_owner']
|
||||
return (
|
||||
config.DEFAULT_OWNERSHIP[td_type]['default_owner'],
|
||||
config.DEFAULT_OWNERSHIP[td_type]['auto_surrender'],
|
||||
)
|
||||
|
||||
|
||||
def get_transfer_data_owner(
|
||||
@ -17,11 +23,13 @@ def get_transfer_data_owner(
|
||||
td_type_key: str,
|
||||
name="",
|
||||
):
|
||||
default_tl = get_default_task_layer(td_type_key, name)
|
||||
default_tl, auto_surrender = get_default_task_layer_owner(td_type_key, name)
|
||||
if default_tl in asset_pipe.get_local_task_layers():
|
||||
return default_tl
|
||||
# If the default owner is local to the file, don't use auto_surrender
|
||||
return default_tl, False
|
||||
else:
|
||||
return asset_pipe.get_local_task_layers()[0]
|
||||
# If the default owner is not local, pass auto surrender value
|
||||
return asset_pipe.get_local_task_layers()[0], auto_surrender
|
||||
|
||||
|
||||
def draw_task_layer_selection(
|
||||
|
@ -224,10 +224,11 @@ def init_modifiers(scene, obj):
|
||||
asset_pipe = scene.asset_pipeline
|
||||
td_type_key = constants.MODIFIER_KEY
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
task_layer_owner = get_transfer_data_owner(
|
||||
task_layer_owner, auto_surrender = get_transfer_data_owner(
|
||||
asset_pipe,
|
||||
td_type_key,
|
||||
)
|
||||
|
||||
for mod in obj.modifiers:
|
||||
mod.name = task_layer_prefix_name_get(mod.name, task_layer_owner)
|
||||
# Only add new ownership transfer_data_item if vertex group doesn't have an owner
|
||||
@ -238,6 +239,7 @@ def init_modifiers(scene, obj):
|
||||
owner=task_layer_owner,
|
||||
type=td_type_key,
|
||||
obj=obj,
|
||||
surrender=auto_surrender,
|
||||
)
|
||||
|
||||
|
||||
@ -324,7 +326,7 @@ def init_constraints(scene, obj):
|
||||
td_type_key = constants.CONSTRAINT_KEY
|
||||
transfer_data = obj.transfer_data_ownership
|
||||
asset_pipe = scene.asset_pipeline
|
||||
task_layer_owner = get_transfer_data_owner(
|
||||
task_layer_owner, auto_surrender = get_transfer_data_owner(
|
||||
asset_pipe,
|
||||
td_type_key,
|
||||
)
|
||||
@ -338,6 +340,7 @@ def init_constraints(scene, obj):
|
||||
owner=task_layer_owner,
|
||||
type=td_type_key,
|
||||
obj=obj,
|
||||
surrender=auto_surrender,
|
||||
)
|
||||
|
||||
|
||||
@ -438,11 +441,16 @@ def init_material_slots(scene, obj):
|
||||
matches = check_transfer_data_entry(transfer_data, name, td_type_key)
|
||||
# Only add new ownership transfer_data_item if vertex group doesn't have an owner
|
||||
if len(matches) == 0:
|
||||
task_layer_owner, auto_surrender = get_transfer_data_owner(
|
||||
asset_pipe,
|
||||
td_type_key,
|
||||
)
|
||||
asset_pipe.add_temp_transfer_data(
|
||||
name=name,
|
||||
owner=get_transfer_data_owner(asset_pipe, td_type_key),
|
||||
owner=task_layer_owner,
|
||||
type=td_type_key,
|
||||
obj=obj,
|
||||
surrender=auto_surrender,
|
||||
)
|
||||
|
||||
|
||||
@ -702,11 +710,15 @@ def init_attributes(scene, obj):
|
||||
# Only add new ownership transfer_data_item if vertex group doesn't have an owner
|
||||
matches = check_transfer_data_entry(transfer_data, atttribute.name, td_type_key)
|
||||
if len(matches) == 0:
|
||||
task_layer_owner, auto_surrender = get_transfer_data_owner(
|
||||
asset_pipe, td_type_key, atttribute.name
|
||||
)
|
||||
asset_pipe.add_temp_transfer_data(
|
||||
name=atttribute.name,
|
||||
owner=get_transfer_data_owner(asset_pipe, td_type_key, atttribute.name),
|
||||
owner=task_layer_owner,
|
||||
type=td_type_key,
|
||||
obj=obj,
|
||||
surrender=auto_surrender,
|
||||
)
|
||||
|
||||
|
||||
@ -774,11 +786,16 @@ def init_parent(scene, obj):
|
||||
matches = check_transfer_data_entry(transfer_data, name, td_type_key)
|
||||
# Only add new ownership transfer_data_item if vertex group doesn't have an owner
|
||||
if len(matches) == 0:
|
||||
task_layer_owner, auto_surrender = get_transfer_data_owner(
|
||||
asset_pipe,
|
||||
td_type_key,
|
||||
)
|
||||
asset_pipe.add_temp_transfer_data(
|
||||
name=name,
|
||||
owner=get_transfer_data_owner(asset_pipe, td_type_key),
|
||||
owner=task_layer_owner,
|
||||
type=td_type_key,
|
||||
obj=obj,
|
||||
surrender=auto_surrender,
|
||||
)
|
||||
|
||||
|
||||
|
@ -110,12 +110,14 @@ def transfer_data_item_init(
|
||||
# Only add new ownership transfer_data_item if vertex group doesn't have an owner
|
||||
matches = check_transfer_data_entry(transfer_data, item.name, td_type_key)
|
||||
if len(matches) == 0:
|
||||
asset_pipe.add_temp_transfer_data(
|
||||
name=item.name,
|
||||
owner=get_transfer_data_owner(
|
||||
task_layer_owner, auto_surrender = get_transfer_data_owner(
|
||||
asset_pipe,
|
||||
td_type_key,
|
||||
),
|
||||
)
|
||||
asset_pipe.add_temp_transfer_data(
|
||||
name=item.name,
|
||||
owner=task_layer_owner,
|
||||
type=td_type_key,
|
||||
obj=obj,
|
||||
surrender=auto_surrender,
|
||||
)
|
||||
|
@ -74,13 +74,14 @@ class AssetPipeline(bpy.types.PropertyGroup):
|
||||
|
||||
temp_transfer_data: bpy.props.CollectionProperty(type=AssetTransferDataTemp)
|
||||
|
||||
def add_temp_transfer_data(self, name, owner, type, obj):
|
||||
def add_temp_transfer_data(self, name, owner, type, obj, surrender):
|
||||
new_transfer_data = self.temp_transfer_data
|
||||
transfer_data_item = new_transfer_data.add()
|
||||
transfer_data_item.name = name
|
||||
transfer_data_item.owner = owner
|
||||
transfer_data_item.type = type
|
||||
transfer_data_item.obj = obj
|
||||
transfer_data_item.surrender = surrender
|
||||
|
||||
## NEW FILE
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user