Unreal/CarlaUE4/Plugins/RoadRunnerImporter/Source/RoadRunnerImporter/Private/RoadRunnerReimportFactory.cpp
////////////////////////////////////////////////////////////////////////////////
// Since we are not using the ReimportFbxSceneFactory, an extra FbxSceneImportData
// will be created in the same package. This function will try to merge the extra
// object and fixup the redirectors.
Since we are not using the ReimportFbxSceneFactory, an extra FbxSceneImportData
will be created in the same package. This function will try to merge the extra
object and fixup the redirectors.
Since we are not using the ReimportFbxSceneFactory an extra FbxSceneImportData will be created in the same package . This function will try to merge the extra object and fixup the redirectors .
void URoadRunnerReimportFactory::PostReimport(UObject* inCreateObject)
{
	if (!inCreateObject)
		return;
	if (!inCreateObject->IsA<UFbxSceneImportData>())
		return;
	UPackage* package = inCreateObject->GetOutermost();
	TArray<UObject*> objects;
	TArray<UPackage*> packages;
	packages.Add(package);
	PackageTools::GetObjectsInPackages(&packages, objects);
	if (objects.Num() > 1)
	{
		FCommentNodeSet extras;
		for (int i = 1; i < objects.Num(); i++)
		{
			extras.Add(objects[i]);
		}
		ObjectTools::FConsolidationResults ConsolidationResults = ObjectTools::ConsolidateObjects(objects[0], extras, false);
	}
	TArray<UObject*> newObjects;
	PackageTools::GetObjectsInPackages(&packages, newObjects);
	if (newObjects.Num() > 1)
	{
		TArray<UObjectRedirector*> redirectors;
		for (int i = 0; i < newObjects.Num(); i++)
		{
			auto& obj = newObjects[i];
			if (!obj->IsA(UObjectRedirector::StaticClass()))
				continue;
			auto objRedirector = Cast<UObjectRedirector>(obj);
			if (!objRedirector)
				continue;
			redirectors.Add(objRedirector);
		}
		FAssetToolsModule& assetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools");
		assetToolsModule.Get().FixupReferencers(redirectors);
	}
	TArray<UObject*> deleteCheck;
	PackageTools::GetObjectsInPackages(&packages, deleteCheck);
	if (deleteCheck.Num() > 1)
	{
		TArray<UObject*> objectsToForceDelete;
		objectsToForceDelete.Add(deleteCheck[1]);
		ObjectTools::ForceDeleteObjects(objectsToForceDelete, false);
	}
	inCreateObject->GetOutermost()->MarkPackageDirty();
}
void URoadRunnerReimportFactory :: PostReimport ( UObject * inCreateObject ) { if ( ! inCreateObject ) return ; if ( ! inCreateObject -> IsA < UFbxSceneImportData > ( ) ) return ; UPackage * package = inCreateObject -> GetOutermost ( ) ; TArray < UObject * > objects ; TArray < UPackage * > packages ; packages . Add ( package ) ; PackageTools :: GetObjectsInPackages ( & packages , objects ) ; if ( objects . Num ( ) > 1 ) { FCommentNodeSet extras ; for ( int i = 1 ; i < objects . Num ( ) ; i ++ ) { extras . Add ( objects [ i ] ) ; } ObjectTools :: FConsolidationResults ConsolidationResults = ObjectTools :: ConsolidateObjects ( objects [ 0 ] , extras , false ) ; } TArray < UObject * > newObjects ; PackageTools :: GetObjectsInPackages ( & packages , newObjects ) ; if ( newObjects . Num ( ) > 1 ) { TArray < UObjectRedirector * > redirectors ; for ( int i = 0 ; i < newObjects . Num ( ) ; i ++ ) { auto & obj = newObjects [ i ] ; if ( ! obj -> IsA ( UObjectRedirector :: StaticClass ( ) ) ) continue ; auto objRedirector = Cast < UObjectRedirector > ( obj ) ; if ( ! objRedirector ) continue ; redirectors . Add ( objRedirector ) ; } FAssetToolsModule & assetToolsModule = FModuleManager :: LoadModuleChecked < FAssetToolsModule > ( " " ) ; assetToolsModule . Get ( ) . FixupReferencers ( redirectors ) ; } TArray < UObject * > deleteCheck ; PackageTools :: GetObjectsInPackages ( & packages , deleteCheck ) ; if ( deleteCheck . Num ( ) > 1 ) { TArray < UObject * > objectsToForceDelete ; objectsToForceDelete . Add ( deleteCheck [ 1 ] ) ; ObjectTools :: ForceDeleteObjects ( objectsToForceDelete , false ) ; } inCreateObject -> GetOutermost ( ) -> MarkPackageDirty ( ) ; }
Since we are not using the ReimportFbxSceneFactory, an extra FbxSceneImportData
will be created in the same package.
Since we are not using the ReimportFbxSceneFactory an extra FbxSceneImportData will be created in the same package .
// Merge references // Consolidate all extra objects in the reimport data package // Reload package and fixup referencers // Ensure referencer was deleted