From e50140c15acdd9b754e27a9322c9150058ccd8db Mon Sep 17 00:00:00 2001 From: bengHinterland Date: Fri, 25 Nov 2022 15:10:12 +0100 Subject: [PATCH 1/2] Update ingest.py fixing wrong asset path for future get_asset --- send2ue/core/ingest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/send2ue/core/ingest.py b/send2ue/core/ingest.py index 798d3008..eddd0267 100644 --- a/send2ue/core/ingest.py +++ b/send2ue/core/ingest.py @@ -22,7 +22,7 @@ def import_asset(asset_id, property_data): asset_data = bpy.context.window_manager.send2ue.asset_data[asset_id] # import the asset - UnrealRemoteCalls.import_asset(asset_data.get('file_path'), asset_data, property_data) + asset_data['asset_path'] = UnrealRemoteCalls.import_asset(asset_data.get('file_path'), asset_data, property_data)[0] # import fcurves if asset_data.get('fcurve_file_path'): From 45a548435c97da5f296ce9c6b0d75cb94353f3d5 Mon Sep 17 00:00:00 2001 From: bengHinterland Date: Fri, 25 Nov 2022 17:33:08 +0100 Subject: [PATCH 2/2] Update export.py made sockets work with combine mesh --- send2ue/core/export.py | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/send2ue/core/export.py b/send2ue/core/export.py index 4ea4d22c..dfca87a4 100644 --- a/send2ue/core/export.py +++ b/send2ue/core/export.py @@ -404,24 +404,36 @@ def export_file(properties, lod=0): restore_rig_objects(context, properties) -def get_asset_sockets(asset_name, properties): +def get_asset_sockets(mesh_object_param, properties): """ Gets the socket under the given asset. - :param str asset_name: The name of the asset to export. + :param str mesh_object_param: The mesh_object to export. :param object properties: The property group that contains variables that maintain the addon's correct state. """ socket_data = {} - mesh_object = bpy.data.objects.get(asset_name) - if mesh_object: - for child in mesh_object.children: - if child.type == 'EMPTY' and child.name.startswith(f'{PreFixToken.SOCKET.value}_'): - name = utilities.get_asset_name(child.name.replace(f'{PreFixToken.SOCKET.value}_', ''), properties) - socket_data[name] = { - 'relative_location': utilities.convert_blender_to_unreal_location(child.matrix_local.translation), - 'relative_rotation': [math.degrees(i) for i in child.matrix_local.to_euler()], - 'relative_scale': child.matrix_local.to_scale()[:] - } + combined = False + mesh_name = mesh_object_param.name + if hasattr(bpy.context.scene.send2ue.extensions,"combine_meshes"): + if bpy.context.scene.send2ue.extensions.combine_meshes.combine_child_meshes: + combined = True + mesh_name = mesh_object_param.parent.name + + def find_socket_in_chilren(o,iterate): + if o: + for child in o.children: + if child.type == 'EMPTY' and child.name.startswith(f'{PreFixToken.SOCKET.value}_'): + name = utilities.get_asset_name(child.name.replace(f'{PreFixToken.SOCKET.value}_', ''), properties) + socket_data[name] = { + 'relative_location': utilities.convert_blender_to_unreal_location(child.matrix_local.translation), + 'relative_rotation': [math.degrees(i) for i in child.matrix_local.to_euler()], + 'relative_scale': child.matrix_local.to_scale()[:] + } + elif child.type == 'MESH' and iterate: + find_socket_in_chilren(child,iterate) + + mesh_object = bpy.data.objects.get(mesh_name) + find_socket_in_chilren(mesh_object,combined) return socket_data @@ -598,7 +610,7 @@ def create_mesh_data(mesh_objects, rig_objects, properties): 'skeletal_mesh': bool(rig_objects), 'skeleton_asset_path': properties.unreal_skeleton_asset_path, 'lods': export_lods(asset_id, asset_name, properties), - 'sockets': get_asset_sockets(mesh_object.name, properties), + 'sockets': get_asset_sockets(mesh_object, properties), 'import_mesh': True } previous_asset_names.append(asset_name)