UE4 FBXFactory::RecursiveImportNode dublicated mesh handle

When you import a file with one mesh (Blender or 3ds Max) which not located at root FBX node RecursiveImportNode function add them twice:

		if (Node->GetMesh())
		{
			NewObject = ImportANode(VoidFbxImporter, Node, InParent, InName, Flags, NodeIndex, Total);	//<- 1. Importing mesh, in child

			if ( NewObject )
			{
				OutNewAssets.Add(NewObject); 															//<- 2. Import succesful, let's add them to asset list!
			}
		}
		
		for (int32 ChildIndex=0; ChildIndex<Node->GetChildCount(); ++ChildIndex)
		{
			UObject* SubObject = RecursiveImportNode(VoidFbxImporter,Node->GetChild(ChildIndex),InParent,InName,Flags,NodeIndex,Total,OutNewAssets); //<- 4. Now we here, from child node. And we got child pointer.

			if ( SubObject ) 																			//<- 5. And if it's valid (spoiler: it's valid)
			{
				OutNewAssets.Add(SubObject); 															//<- 6. We add same mesh pointer AGAIN!
			}

			if (NewObject==NULL)
			{
				NewObject = SubObject;
			}
		}
	}

	return NewObject; 																					//<- 3. We done, return to top RecursiveImportNode function. Keep in mind: we return same object that we already added to OutNewAssets

It’s a problem, because if mesh contains socket dummies, they will be always ignored by this code:

	TArray<UObject*> AllNewAssets;
	UObject* Object = RecursiveImportNode(FbxImporter,RootNodeToImport,InParent,Name,Flags,NodeIndex,InterestingNodeCount, AllNewAssets); //<- 1. Import all nodes from FBX file, populate AllNewAssets.

	NewStaticMesh = Cast<UStaticMesh>( Object );

	// Make sure to notify the asset registry of all assets created other than the one returned, which will notify the asset registry automatically.
	for ( auto AssetIt = AllNewAssets.CreateConstIterator(); AssetIt; ++AssetIt )
	{
		UObject* Asset = *AssetIt;
		if ( Asset != NewStaticMesh )
		{
			FAssetRegistryModule::AssetCreated(Asset);
			Asset->MarkPackageDirty();
		}
	}

	ImportedMeshCount = AllNewAssets.Num(); //<- 2. Get all asset count, that never be equal one.
}

// Importing static mesh sockets only works if one mesh is being imported
if( ImportedMeshCount == 1 && NewStaticMesh ) //<- 3. This condition will never be executed
{
	FbxImporter->ImportStaticMeshSockets( NewStaticMesh );
}

Hi Giperion -

Can you be more specific as to your FBX setup? We are having an issue duplicating the results you are describing above. If you happen to have a sample FBX asset you can share that would also be of great help.

Thank You

Eric Ketchum

Hi Eric. Thank you for reply. Here a setup:
3ds Max 2015
Blender 2.67
Screenshots: FBX Bug - Album on Imgur
Source Models: FbxBugSrc.rar — RGhost — file sharing
I export default cube with a child dummy.
Bug can be fixed by changing FbxFactory.cpp line 562
from : OutNewAssets.Add(SubObject);
to: OutNewAssets.AddUnique(SubObject);

Hi Eric. Thank you for reply. Here a setup:
3ds Max 2015
Blender 2.67
Screenshots: FBX Bug - Album on Imgur
Source Models: FbxBugSrc.rar — RGhost — file sharing
I export default cube with a child dummy.
Bug can be fixed by changing FbxFactory.cpp line 562
from : OutNewAssets.Add(SubObject);
to: OutNewAssets.AddUnique(SubObject);

Hi Giperion -

It looks like the code will not activate if you check the Combine Meshes checkbox to true on importing.

Eric Ketchum