Asset Pipeline: Improve Performance #235
@ -10,7 +10,7 @@ from .transfer_functions import (
|
|||||||
materials,
|
materials,
|
||||||
)
|
)
|
||||||
from typing import List
|
from typing import List
|
||||||
from ... import constants
|
from ... import constants, logging
|
||||||
from .transfer_util import (
|
from .transfer_util import (
|
||||||
transfer_data_add_entry,
|
transfer_data_add_entry,
|
||||||
check_transfer_data_entry,
|
check_transfer_data_entry,
|
||||||
@ -108,9 +108,10 @@ def apply_transfer_data_items(
|
|||||||
td_type_key: str,
|
td_type_key: str,
|
||||||
transfer_data_dicts: List[dict],
|
transfer_data_dicts: List[dict],
|
||||||
):
|
):
|
||||||
|
logger = logging.get_logger()
|
||||||
# Get source/target from first item in list, because all items in list are same object/type
|
# Get source/target from first item in list, because all items in list are same object/type
|
||||||
if target_obj is None:
|
if target_obj is None:
|
||||||
print(f"Failed to Transfer Data for {transfer_data_dict.id_data.name}")
|
logger.warning(f"Failed to Transfer {td_type_key.title()} from {source_obj.name}")
|
||||||
return
|
return
|
||||||
|
|
||||||
for transfer_data_dict in transfer_data_dicts:
|
for transfer_data_dict in transfer_data_dicts:
|
||||||
@ -122,7 +123,7 @@ def apply_transfer_data_items(
|
|||||||
|
|
||||||
if td_type_key == constants.VERTEX_GROUP_KEY:
|
if td_type_key == constants.VERTEX_GROUP_KEY:
|
||||||
# Transfer All Vertex Groups in one go
|
# Transfer All Vertex Groups in one go
|
||||||
print(f"Transferring all Vertex Groups from {source_obj.name} to {target_obj.name}")
|
logger.debug(f"Transferring All Vertex Groups from {source_obj.name} to {target_obj.name}.")
|
||||||
vertex_groups.transfer_vertex_groups(
|
vertex_groups.transfer_vertex_groups(
|
||||||
vertex_group_names=[item["name"] for item in transfer_data_dicts],
|
vertex_group_names=[item["name"] for item in transfer_data_dicts],
|
||||||
target_obj=target_obj,
|
target_obj=target_obj,
|
||||||
@ -130,6 +131,9 @@ def apply_transfer_data_items(
|
|||||||
)
|
)
|
||||||
if td_type_key == constants.MODIFIER_KEY:
|
if td_type_key == constants.MODIFIER_KEY:
|
||||||
for transfer_data_dict in transfer_data_dicts:
|
for transfer_data_dict in transfer_data_dicts:
|
||||||
|
logger.debug(
|
||||||
|
f"Transferring Modifier {transfer_data_dict['name']} from {source_obj.name} to {target_obj.name}."
|
||||||
|
)
|
||||||
modifers.transfer_modifier(
|
modifers.transfer_modifier(
|
||||||
modifier_name=transfer_data_dict["name"],
|
modifier_name=transfer_data_dict["name"],
|
||||||
target_obj=target_obj,
|
target_obj=target_obj,
|
||||||
@ -137,12 +141,16 @@ def apply_transfer_data_items(
|
|||||||
)
|
)
|
||||||
if td_type_key == constants.CONSTRAINT_KEY:
|
if td_type_key == constants.CONSTRAINT_KEY:
|
||||||
for transfer_data_dict in transfer_data_dicts:
|
for transfer_data_dict in transfer_data_dicts:
|
||||||
|
logger.debug(
|
||||||
|
f"Transferring Constraint {transfer_data_dict['name']} from {source_obj.name} to {target_obj.name}."
|
||||||
|
)
|
||||||
constraints.transfer_constraint(
|
constraints.transfer_constraint(
|
||||||
constraint_name=transfer_data_dict["name"],
|
constraint_name=transfer_data_dict["name"],
|
||||||
target_obj=target_obj,
|
target_obj=target_obj,
|
||||||
source_obj=source_obj,
|
source_obj=source_obj,
|
||||||
)
|
)
|
||||||
if td_type_key == constants.MATERIAL_SLOT_KEY:
|
if td_type_key == constants.MATERIAL_SLOT_KEY:
|
||||||
|
logger.debug(f"Transferring Materials from {source_obj.name} to {target_obj.name}.")
|
||||||
for transfer_data_dict in transfer_data_dicts:
|
for transfer_data_dict in transfer_data_dicts:
|
||||||
materials.transfer_materials(
|
materials.transfer_materials(
|
||||||
target_obj=target_obj,
|
target_obj=target_obj,
|
||||||
@ -150,6 +158,9 @@ def apply_transfer_data_items(
|
|||||||
)
|
)
|
||||||
if td_type_key == constants.SHAPE_KEY_KEY:
|
if td_type_key == constants.SHAPE_KEY_KEY:
|
||||||
for transfer_data_dict in transfer_data_dicts:
|
for transfer_data_dict in transfer_data_dicts:
|
||||||
|
logger.debug(
|
||||||
|
f"Transferring Shape Key {transfer_data_dict['name']} from {source_obj.name} to {target_obj.name}."
|
||||||
|
)
|
||||||
shape_keys.transfer_shape_key(
|
shape_keys.transfer_shape_key(
|
||||||
context=context,
|
context=context,
|
||||||
target_obj=target_obj,
|
target_obj=target_obj,
|
||||||
@ -158,6 +169,9 @@ def apply_transfer_data_items(
|
|||||||
)
|
)
|
||||||
if td_type_key == constants.ATTRIBUTE_KEY:
|
if td_type_key == constants.ATTRIBUTE_KEY:
|
||||||
for transfer_data_dict in transfer_data_dicts:
|
for transfer_data_dict in transfer_data_dicts:
|
||||||
|
logger.debug(
|
||||||
|
f"Transferring Attribute {transfer_data_dict['name']} from {source_obj.name} to {target_obj.name}."
|
||||||
|
)
|
||||||
attributes.transfer_attribute(
|
attributes.transfer_attribute(
|
||||||
target_obj=target_obj,
|
target_obj=target_obj,
|
||||||
source_obj=source_obj,
|
source_obj=source_obj,
|
||||||
@ -165,6 +179,9 @@ def apply_transfer_data_items(
|
|||||||
)
|
)
|
||||||
if td_type_key == constants.PARENT_KEY:
|
if td_type_key == constants.PARENT_KEY:
|
||||||
for transfer_data_dict in transfer_data_dicts:
|
for transfer_data_dict in transfer_data_dicts:
|
||||||
|
logger.debug(
|
||||||
|
f"Transferring Parent Relationship from {source_obj.name} to {target_obj.name}."
|
||||||
|
)
|
||||||
parent.transfer_parent(
|
parent.transfer_parent(
|
||||||
target_obj=target_obj,
|
target_obj=target_obj,
|
||||||
source_obj=source_obj,
|
source_obj=source_obj,
|
||||||
|
@ -40,9 +40,10 @@ def transfer_vertex_groups(
|
|||||||
target_obj: bpy.types.Object,
|
target_obj: bpy.types.Object,
|
||||||
source_obj: bpy.types.Object,
|
source_obj: bpy.types.Object,
|
||||||
):
|
):
|
||||||
|
logger = logging.get_logger()
|
||||||
for vertex_group_name in vertex_group_names:
|
for vertex_group_name in vertex_group_names:
|
||||||
if not source_obj.vertex_groups.get(vertex_group_name):
|
if not source_obj.vertex_groups.get(vertex_group_name):
|
||||||
print(f"ERROR Vertex Group {vertex_group_name} not found in {source_obj.name}")
|
logger.error(f"Vertex Group {vertex_group_name} not found in {source_obj.name}")
|
||||||
return
|
return
|
||||||
|
|
||||||
# If topology matches transfer directly, otherwise use vertex proximity
|
# If topology matches transfer directly, otherwise use vertex proximity
|
||||||
|
Loading…
Reference in New Issue
Block a user