CARLA
MoveAssetsCommandlet.h
Go to the documentation of this file.
1 // Copyright (c) 2019 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
7 #pragma once
8 
10 #include "Commandlets/Commandlet.h"
11 #include "Runtime/Engine/Classes/Engine/ObjectLibrary.h"
12 
13 #if WITH_EDITORONLY_DATA
14 #include "AssetRegistry/Public/AssetRegistryModule.h"
15 #include "Developer/AssetTools/Public/AssetToolsModule.h"
16 #endif // WITH_EDITORONLY_DATA
17 #include "MoveAssetsCommandlet.generated.h"
18 
19 /// Struct containing Package Params, used for storing the parsed arguments when
20 /// invoking this commandlet
21 USTRUCT()
22 struct CARLA_API FMovePackageParams
23 {
24  GENERATED_USTRUCT_BODY()
25 
26  FString Name;
27 
28  TArray<FString> MapNames;
29 };
30 
31 UCLASS()
33 {
34  GENERATED_BODY()
35 
36 public:
37 
38  /// Default constructor.
40 #if WITH_EDITORONLY_DATA
41 
42  /// Parses the command line parameters provided through @a InParams The
43  /// arguments to parse are the package name and a list of map names
44  /// concatenated in a string.
45  FMovePackageParams ParseParams(const FString &InParams) const;
46 
47  /// Moves all the assets contained in a map from @a SrcPath to @a DestPath
48  void MoveAssetsFromMapForSemanticSegmentation(const FString &PackageName, const FString &MapName);
49 
50  /// Moves the meshes of all maps listed in a @PackageParams
51  void MoveAssets(const FMovePackageParams &PackageParams);
52 
53 public:
54 
55  /// Main method and entry of the commandlet, taking as input parameters @a
56  /// Params.
57  virtual int32 Main(const FString &Params) override;
58 
59 #endif // WITH_EDITORONLY_DATA
60 
61 private:
62 
63  /// The following data structures are declared as class members and with
64  /// UPROPERTY macro to avoid UE4 to garbage collect them.
65 
66  /// Loaded assets from any object library
67  UPROPERTY()
68  TArray<FAssetData> AssetDatas;
69 
70  /// Loaded maps from any object library
71  UPROPERTY()
72  TArray<FAssetData> MapContents;
73 
74  /// Used for loading assets in object library. Loaded Data is stored in
75  /// AssetDatas.
76  UPROPERTY()
77  UObjectLibrary *AssetsObjectLibrary;
78 };
Struct containing Package Params, used for storing the parsed arguments when invoking this commandlet...