From c036bc75d9354b836b2aa889771485728b0dfc13 Mon Sep 17 00:00:00 2001 From: Manish Date: Mon, 8 Jul 2019 14:52:38 +0200 Subject: [PATCH] Fixed bugs - All actors from all maps where spawned in each map - World was completely dark when playing imported map --- .../Carla/Commandlet/CookAssetsCommandlet.cpp | 37 ++++++++++--------- .../Carla/Commandlet/CookAssetsCommandlet.h | 5 ++- Util/ImportAssets.sh | 2 +- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.cpp index f726dc137..132df0fc3 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.cpp @@ -66,7 +66,8 @@ void UCookAssetsCommandlet::LoadWorld(FAssetData &AssetData) TArray UCookAssetsCommandlet::AddMeshesToWorld( const TArray &AssetsPaths, - bool bUseCarlaMaterials) + bool bUseCarlaMaterials, + bool bIsPropsMap) { TArray SpawnedMeshes; @@ -74,21 +75,21 @@ TArray UCookAssetsCommandlet::AddMeshesToWorld( // Remove the meshes names from the original path, so LoadAssetDataFromPaths // can be used - TArray AssetsPathsDirectories; - for (auto AssetPath : AssetsPaths) + TArray AssetsPathsDirectories = AssetsPaths; + if (bIsPropsMap) { - FString Dir; - AssetPath.Split( - TEXT("/"), - &Dir, - nullptr, - ESearchCase::Type::IgnoreCase, - ESearchDir::Type::FromEnd); - AssetsPathsDirectories.Add(Dir); + for (auto &AssetPath : AssetsPathsDirectories) + { + AssetPath.Split( + TEXT("/"), + &AssetPath, + nullptr, + ESearchCase::Type::IgnoreCase, + ESearchDir::Type::FromEnd); + } } AssetsObjectLibrary->AddToRoot(); - AssetsObjectLibrary->ClearLoaded(); AssetsObjectLibrary->LoadAssetDataFromPaths(AssetsPathsDirectories); AssetsObjectLibrary->LoadAssetsFromAssetData(); @@ -129,6 +130,7 @@ TArray UCookAssetsCommandlet::AddMeshesToWorld( } } } + AssetsObjectLibrary->ClearLoaded(); World->MarkPackageDirty(); return SpawnedMeshes; @@ -313,13 +315,8 @@ int32 UCookAssetsCommandlet::Main(const FString &Params) MapPathData.Append(WorldDestPath + TEXT("/") + MapName); - // Save Map Path File for further use - FString SaveDirectory = FPaths::ProjectContentDir() + PackageParams.Name + TEXT("/Config"); - FString FileName = FString("MapPaths.txt"); - SaveStringTextToFile(SaveDirectory, FileName, MapPathData, true); - // Add props in a single Base Map - TArray SpawnedActors = AddMeshesToWorld(AssetsPaths.PropsPaths, false); + TArray SpawnedActors = AddMeshesToWorld(AssetsPaths.PropsPaths, false, true); SaveWorld(AssetData, PackageParams.Name, WorldDestPath, MapName); @@ -327,6 +324,10 @@ int32 UCookAssetsCommandlet::Main(const FString &Params) MapObjectLibrary->ClearLoaded(); } + // Save Map Path File for further use + FString SaveDirectory = FPaths::ProjectContentDir() + PackageParams.Name + TEXT("/Config"); + FString FileName = FString("MapPaths.txt"); + SaveStringTextToFile(SaveDirectory, FileName, MapPathData, true); return 0; } #endif diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.h index 2ee44447c..8b7de8878 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.h @@ -82,7 +82,10 @@ public: * materials to fix a known bug * in RoadRunner. */ - TArray AddMeshesToWorld(const TArray &AssetsPaths, bool bUseCarlaMaterials); + TArray AddMeshesToWorld( + const TArray &AssetsPaths, + bool bUseCarlaMaterials, + bool bIsPropsMap = false); /** * Save a given Asset containing a World into a given path with a given name. diff --git a/Util/ImportAssets.sh b/Util/ImportAssets.sh index c603e7594..ae25398d7 100755 --- a/Util/ImportAssets.sh +++ b/Util/ImportAssets.sh @@ -32,7 +32,7 @@ while true; do done #Tar.gz the stuff -for filepath in `find ExportedAssets/ -type f -name "*.tar.gz"`; do +for filepath in `find Import/ -type f -name "*.tar.gz"`; do tar --keep-newer-files -xvf ${filepath} done