CARLA
 
载入中...
搜索中...
未找到
NavigationMesh.cpp
浏览该文件的文档.
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#include "Carla.h"
9#include "Misc/FileHelper.h"
10
11TArray<uint8> FNavigationMesh::Load(FString MapName)
12{
13#if WITH_EDITOR
14 {
15 // When playing in editor the map name gets an extra prefix, here we
16 // remove it.
17 FString CorrectedMapName = MapName;
18 constexpr auto PIEPrefix = TEXT("UEDPIE_0_");
19 CorrectedMapName.RemoveFromStart(PIEPrefix);
20 UE_LOG(LogCarla, Log, TEXT("FNavigationMesh: Corrected map name from %s to %s"), *MapName, *CorrectedMapName);
21 MapName = CorrectedMapName;
22 }
23#endif // WITH_EDITOR
24
25 const auto FileName = MapName + ".bin";
26
27 TArray<FString> Files;
28 IFileManager::Get().FindFilesRecursive(Files, *FPaths::ProjectContentDir(), *FileName, true, false, false);
29
30 TArray<uint8> Content;
31
32 if (!Files.Num())
33 {
34 UE_LOG(LogTemp, Error, TEXT("Failed to find OpenDrive file for map '%s'"), *MapName);
35 }
36 else if (FFileHelper::LoadFileToArray(Content, *Files[0], 0))
37 {
38 UE_LOG(LogCarla, Log, TEXT("Loading Navigation Mesh file '%s'"), *Files[0]);
39 }
40 else
41 {
42 UE_LOG(LogTemp, Error, TEXT("Failed to load Navigation Mesh file '%s'"), *Files[0]);
43 }
44
45 return Content;
46}
static TArray< uint8 > Load(FString MapName)
Return the Navigation Mesh Binary associated to MapName, or empty if the such file wasn't serialized.