EpicGamesExt / BlenderTools

Blender addons that improve the game development workflow between Blender and Unreal.
https://epicgamesext.github.io/BlenderTools/
MIT License
2.81k stars 61 forks source link

Send2UE: Nanite Static Mesh sockets sent to UE5 crash #492

Closed DanMcLaughlin closed 2 years ago

DanMcLaughlin commented 2 years ago

image


UnrealEditor_UnrealEd!TMulticastDelegateBase<FDefaultDelegateUserPolicy>::CompactInvocationList() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\MulticastDelegateBase.h:191]
UnrealEditor_UnrealEd!TMulticastDelegateBase<FDefaultDelegateUserPolicy>::AddDelegateInstance() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\MulticastDelegateBase.h:154]
UnrealEditor_UnrealEd!SSocketManager::AddPropertyChangeListenerToSockets() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\SSocketManager.cpp:726]
UnrealEditor_UnrealEd!SSocketManager::Construct() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\SSocketManager.cpp:391]
UnrealEditor_UnrealEd!ISocketManager::CreateSocketManager() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\SSocketManager.cpp:219]

I've been struggling with this, static mesh sockets just aren't working when exported over by the plugin. Initially my belief was that this is a Unreal import issue and it may well be, but look at this debug from the stack trace above (e.g. SSocketManager.cpp:724) - the operation is opening the mesh in an editor and its setting up change delegates for clients

image

If the debugger is reading this right (debuggers don't always get it right) the socket is set up but there is something not initialized. Is there something that needs to happen on the plugin side that isn't? I have a hard time believing that sockets are this broken in UE5, so am suspecting some missing step.

Note on occasion I've gotten to see the mesh and the sockets are there properly, but the issue being the crashes.

DanMcLaughlin commented 2 years ago

Testing sockets created in UN5 with Nanite meshes is fine - no issues. Somehow these imported sockets are not fully initialized.

Any inside you can give James is greatly appreciated - this is a show stopper for us. Thanks -

DanMcLaughlin commented 2 years ago

OK, this isn't news to you but I imported a same mesh from drag-drop and it is fine, but without sockets, so you're doing some post import magic. Doing a little checking ...

   @staticmethod
    def set_static_mesh_sockets(asset_path, asset_data):
        """
        Sets sockets on a static mesh.

        :param str asset_path: The project path to the skeletal mesh in unreal.
        :param dict asset_data: A dictionary of import parameters.
        """
        static_mesh = Unreal.get_asset(asset_path)
        for socket_name, socket_data in asset_data.get('sockets').items():
            socket = unreal.StaticMeshSocket()

            # apply the socket settings
            socket.set_editor_property('relative_location', socket_data.get('relative_location'))
            socket.set_editor_property('relative_rotation', socket_data.get('relative_rotation'))
            socket.set_editor_property('relative_scale', socket_data.get('relative_scale'))
            socket.set_editor_property('socket_name', socket_name)

            # if that socket already exists remove it
            existing_socket = static_mesh.find_socket(socket_name)
            if existing_socket:
                static_mesh.remove_socket(existing_socket)

            # create a new socket
            static_mesh.add_socket(socket)

OK this is great - it's in our demesne. I don't know if I'll have any more time to look into this but maybe I can test some code later, but @james-baber I'll suspect that in addition to adding the socket we also need to parent it, or a similar operation. The few times I was able to view the mesh without it crashing I could see everything looked fine, but there is some kind of relationship between the mesh and the sockets that hasn't been established, as you can see from the debugger above. What do you think?

james-baber commented 2 years ago

Should be fixed in latest release https://github.com/EpicGames/BlenderTools/releases/tag/20221014010625