From 98c01451200498d39b716e58d3181ba304a48453 Mon Sep 17 00:00:00 2001 From: Axel Date: Thu, 9 Mar 2023 14:17:41 +0100 Subject: [PATCH] Added patch for omniverse importer --- .../CarlaTools/Private/USDImporterWidget.cpp | 9 ++------- .../Source/CarlaTools/Public/USDImporterWidget.h | 2 -- Util/BuildTools/BuildCarlaUE4.bat | 6 ++++++ Util/Patches/omniverse_4.26/USDCARLAInterface.cpp | 14 ++++++++++++++ Util/Patches/omniverse_4.26/USDCARLAInterface.h | 10 ++++++++++ 5 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 Util/Patches/omniverse_4.26/USDCARLAInterface.cpp create mode 100644 Util/Patches/omniverse_4.26/USDCARLAInterface.h diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/USDImporterWidget.cpp b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/USDImporterWidget.cpp index b2f1412b2..303a3a588 100644 --- a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/USDImporterWidget.cpp +++ b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/USDImporterWidget.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2023 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB). This work is licensed under the terms of the MIT license. For a copy, see . #include "USDImporterWidget.h" -#include "USDAlternateImporter.h" +#include "USDCARLAInterface.h" #include "Kismet/GameplayStatics.h" #include "Modules/ModuleManager.h" #include "IMeshMergeUtilities.h" @@ -12,7 +12,7 @@ void UUSDImporterWidget::ImportUSDProp( const FString& USDPath, const FString& DestinationAssetPath, bool bAsBlueprint) { - FUSDAlternateImporter::ImportUSD(USDPath, DestinationAssetPath, false, bAsBlueprint); + FUSDCARLAInterface::ImportUSD(USDPath, DestinationAssetPath, false, bAsBlueprint); } void UUSDImporterWidget::ImportUSDVehicle( @@ -61,8 +61,3 @@ bool UUSDImporterWidget::MergeStaticMeshComponents( MeshUtilities.MergeComponentsToStaticMesh(ComponentsToMerge, World, MeshMergeSettings, nullptr, nullptr, DestMesh, AssetsToSync, NewLocation, ScreenAreaSize, true); return true; } - -FString UUSDImporterWidget::GetFileName(FString& FullPath) -{ - return FPaths::GetBaseFilename(FullPath, true); -} diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/USDImporterWidget.h b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/USDImporterWidget.h index 96fdfb23a..fedc8be17 100644 --- a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/USDImporterWidget.h +++ b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/USDImporterWidget.h @@ -22,6 +22,4 @@ class CARLATOOLS_API UUSDImporterWidget : public UUserWidget static AActor* GetGeneratedBlueprint(UWorld* World, const FString& USDPath); UFUNCTION(BlueprintCallable, Category="USD Importer") static bool MergeStaticMeshComponents(TArray Actors, const FString& DestMesh); - UFUNCTION(BlueprintPure, Category="USD Importer") - static FString GetFileName(const FString& FullPath); }; diff --git a/Util/BuildTools/BuildCarlaUE4.bat b/Util/BuildTools/BuildCarlaUE4.bat index 6a5d922af..8d22589bb 100644 --- a/Util/BuildTools/BuildCarlaUE4.bat +++ b/Util/BuildTools/BuildCarlaUE4.bat @@ -141,6 +141,12 @@ if %USE_CHRONO% == true ( set OPTIONAL_MODULES_TEXT=%CARSIM_STATE% %CHRONO_STATE% echo %OPTIONAL_MODULES_TEXT% > "%ROOT_PATH%Unreal/CarlaUE4/Config/OptionalModules.ini" +set OMNIVERSE_PATCH_FOLDER=%ROOT_PATH%Util\Patches\omniverse_4.26\ +set OMNIVERSE_PLUGIN_FOLDER=%UE4_ROOT%Engine\Plugins\Marketplace\NVIDIA\Omniverse\ + +xcopy /Y /S /I "%OMNIVERSE_PATCH_FOLDER%USDCARLAInterface.h" "%OMNIVERSE_PLUGIN_FOLDER%Source\OmniverseUSD\Public\" > NUL +xcopy /Y /S /I "%OMNIVERSE_PATCH_FOLDER%USDCARLAInterface.cpp" "%OMNIVERSE_PLUGIN_FOLDER%Source\OmniverseUSD\Private\" > NUL + if %BUILD_UE4_EDITOR% == true ( echo %FILE_N% Building Unreal Editor... diff --git a/Util/Patches/omniverse_4.26/USDCARLAInterface.cpp b/Util/Patches/omniverse_4.26/USDCARLAInterface.cpp new file mode 100644 index 000000000..db991d7c2 --- /dev/null +++ b/Util/Patches/omniverse_4.26/USDCARLAInterface.cpp @@ -0,0 +1,14 @@ + +#include "USDCARLAInterface.h" +#include "OmniverseUSDImporter.h" + + +bool FUSDCARLAInterface::ImportUSD( + const FString& Path, const FString& Dest, + bool bImportUnusedReferences, bool bImportAsBlueprint) +{ + FOmniverseImportSettings Settings; + Settings.bImportUnusedReferences = bImportUnusedReferences; + Settings.bImportAsBlueprint = bImportAsBlueprint; + return FOmniverseUSDImporter::LoadUSD(Path, Dest, Settings); +} diff --git a/Util/Patches/omniverse_4.26/USDCARLAInterface.h b/Util/Patches/omniverse_4.26/USDCARLAInterface.h new file mode 100644 index 000000000..5d1af7c41 --- /dev/null +++ b/Util/Patches/omniverse_4.26/USDCARLAInterface.h @@ -0,0 +1,10 @@ + +#pragma once + +#include "CoreMinimal.h" + +class OMNIVERSEUSD_API FUSDCARLAInterface +{ +public: + static bool ImportUSD(const FString& Path, const FString& Dest, bool bImportUnusedReferences, bool bImportAsBlueprint); +};