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

Fixed an issue where exported sockets on static meshes would be lost … #493

Closed nmaillet closed 2 years ago

nmaillet commented 2 years ago

…after re-opening a project (missing reference causing crashes).

Mentioned in issues #492 and #443

3 unit tests failed for me. They don't seem related to anything I changed, so maybe tests that are currently failing, or I have an issue in my setup.

====================================================================== FAIL [17.620s]: test_materials (test_send2ue_extension_affixes.TestSend2UeExtensionAffixesMannequins) Sends a mannequin with materials to unreal.

AssertionError: False is not true : The material "M_MI_Female_Body" does not exist in unreal.

====================================================================== FAIL [17.249s]: test_textures (test_send2ue_extension_affixes.TestSend2UeExtensionAffixesMannequins) Sends a mannequin with a textured material to unreal.

AssertionError: False is not true : The texture "T_unreal-engine-logo" does not exist in unreal.

====================================================================== FAIL [22.269s]: test_textures (test_send2ue_mannequins.TestSend2UeMannequins) Sends a mannequin with a textured material to unreal.

AssertionError: False is not true : The texture "unreal-engine-logo" does not exist in unreal.

DanMcLaughlin commented 2 years ago

Brilliant @nmaillet, this is wonderful. Yes makes perfect sense, and maybe why James wasn’t able to reproduce before because it will import just fine, but the problem only shows up when you start trying to use the meshes and sockets is the missing relationship a problem.

DanMcLaughlin commented 2 years ago

Hmm, I made this change in my plugin and I'm still getting an error that I've gotten before. Previously this socket crash would happen if you were trying to reimport an existing static mesh with a socket (it imports fine if the asset doesn't already exist). However this time, with the adding of the static_mesh to the constructor, I also get the crash on import every time

StaticMeshImportUtils.cpp image

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000030

UnrealEditor_UnrealEd!StaticMeshImportUtils::RestoreExistingMeshData() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\ImportUtils\StaticMeshImportUtils.cpp:1187]
UnrealEditor_UnrealEd!UnFbx::FFbxImporter::ReimportStaticMesh() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\Fbx\FbxStaticMeshImport.cpp:1607]
UnrealEditor_UnrealEd!UReimportFbxStaticMeshFactory::Reimport() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\Factories\EditorFactories.cpp:6017]
UnrealEditor_UnrealEd!FReimportManager::Reimport() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\Editor.cpp:443]
UnrealEditor_UnrealEd!UFbxFactory::FactoryCreateFile() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\Fbx\FbxFactory.cpp:275]
UnrealEditor_UnrealEd!UFactory::ImportObject() [D:\build\++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\Factories\Factory.cpp:205]
UnrealEditor_AssetTools!UAssetToolsImpl::ImportAssetsInternal() [D:\build\++UE5\Sync\Engine\Source\Developer\AssetTools\Private\AssetTools.cpp:2254]
UnrealEditor_AssetTools!UAssetToolsImpl::ImportAssetTasks() [D:\build\++UE5\Sync\Engine\Source\Developer\AssetTools\Private\AssetTools.cpp:1157]
UnrealEditor_AssetTools!IAssetTools::execImportAssetTasks() [D:\build\++UE5\Sync\Engine\Intermediate\Build\Win64\UnrealEditor\Inc\AssetTools\IAssetTools.gen.cpp:381]
UnrealEditor_CoreUObject!UFunction::Invoke() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:5912]
UnrealEditor_CoreUObject!UObject::ProcessEvent() [D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:2003]
UnrealEditor_PythonScriptPlugin!PyUtil::InvokeFunctionCall() [D:\build\++UE5\Sync\Engine\Plugins\Experimental\PythonScriptPlugin\Source\PythonScriptPlugin\Private\PyUtil.cpp:557]
UnrealEditor_PythonScriptPlugin!FPyWrapperObject::CallFunction_Impl() [D:\build\++UE5\Sync\Engine\Plugins\Experimental\PythonScriptPlugin\Source\PythonScriptPlugin\Private\PyWrapperObject.cpp:301]
UnrealEditor_PythonScriptPlugin!FPyWrapperObject::CallFunction() [D:\build\++UE5\Sync\Engine\Plugins\Experimental\PythonScriptPlugin\Source\PythonScriptPlugin\Private\PyWrapperObject.cpp:225]
UnrealEditor_PythonScriptPlugin!FPyWrapperObject::CallMethodWithArgs_Impl() [D:\build\++UE5\Sync\Engine\Plugins\Experimental\PythonScriptPlugin\Source\PythonScriptPlugin\Private\PyWrapperObject.cpp:333]
UnrealEditor_PythonScriptPlugin!FPyMethodWithClosureDef::Call() [D:\build\++UE5\Sync\Engine\Plugins\Experimental\PythonScriptPlugin\Source\PythonScriptPlugin\Private\PyMethodWithClosure.cpp:152]
python39

So while this is one of the existing crashes, now it happens on every import when there's no existing asset already in Unreal. I'm puzzled why this is happening, it seems to imply that the send2ue plugin logic is such that it's reusing the static_mesh variable improperly, or something along those lines. What might be relevant is that my use case is sending over several static meshes, all with sockets.

nmaillet commented 2 years ago

@DanMcLaughlin I wasn't able to reproduce your issue (don't have a lot of time currently to try). One thing I noticed, was the sockets you were using had periods in their names (SOCKET_curtain_00.001). When I tried that, the imported meshes had the periods replaced with underscores (curtain_00_001). Not sure if that would have anything to do with your issue or not, but maybe try limiting your socket names to alphanumeric and underscores?

DanMcLaughlin commented 2 years ago

Hmmm, possibly, but previously without the fix it did import with those names, as long as it wasn’t replacing the asset. I’ll do some more testing tomorrow, perhaps there’s some old pollution in the from the previous stuff.

DanMcLaughlin commented 2 years ago

Ah ha @nmaillet yes it works perfectly! I can import, re-import, and load up the mesh in the editor without crashes and the sockets show up fine. The period isn't a problem as James goes and changes that to an underscore anyhow. The problem was due to another issue I submitted 491 which is that the extension settings are not saved. So if I forget to re-check "Use collections as subfolders" (frequently), well it turned out I had some old poisoned meshes in a different location, so with the fix was tripping over the same problem.

Ship it!

nmaillet commented 2 years ago

Excellent, glad your up and running!

DanMcLaughlin commented 2 years ago

BTW finally getting to the main import we've been trying to do, which is a nice torture test. Twenty nanite 1M poly static meshes with upwards of 70 sockets per mesh, and in this case half those sockets were added after the first test import, so it's re-importing with a new socket collection - no issues. The Blender messaging is nice too, useful to see it telling us when it's exporting the mesh and when it's working on the sockets.

james-baber commented 2 years ago

@nmaillet thanks for submitting this. I am intermittently getting those 3 failures in the tests as well. Ill fix the test cases, but the failures are unrelated to this current PR. Thanks!