CARLA
 
载入中...
搜索中...
未找到
RoadMap.cpp
浏览该文件的文档.
1// Copyright (c) 2017 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
11
12#include "FileHelper.h"
13#include "HighResScreenshot.h"
14
15// 仅在编辑器环境下包含相关调试绘制头文件,用于在编辑器中进行一些辅助的可视化调试操作
16#if WITH_EDITOR
17#include "DrawDebugHelpers.h"
18#endif // WITH_EDITOR
19
20#include <type_traits>
21
22// 定义本地化文本命名空间,这里命名为"CarlaRoadMap",用于处理与道路地图相关的本地化文本信息
23#define LOCTEXT_NAMESPACE "CarlaRoadMap"
24
25// =============================================================================
26// -- Static local methods -----------------------------------------------------
27// =============================================================================
28
29// 静态函数:将浮点数限制在指定的整数范围内并转换为无符号整数
30// @param Value 要进行转换的浮点数
31// @param Min 限制范围的下限(整数)
32// @param Max 限制范围的上限(整数)
33// @return 转换后的无符号32位整数,该整数在[Min, Max]范围内
34static uint32 ClampFloatToUInt(const float Value, int32 Min, int32 Max)
35// 使用FMath库中的Clamp函数先将浮点数转换为整数并限制在[Min, Max]范围内,然后返回无符号32位整数形式
36{
37 return FMath::Clamp(FMath::FloorToInt(Value), Min, Max);
38}
39// 静态函数:返回旋转后的方位角(在球坐标下),使其范围在[0, 2*PI]
40// @param Direction 输入的方向向量,用于计算其方位角
41// @return 旋转后的方位角(浮点数),范围在[0, 2*PI]
42
43// 返回经过 π 弧度旋转后的方位角(在球坐标系下),使其处于 [0, 2π] 这个区间范围内。
44// 处于 [0, 2π] 这个区间范围内。
45static float GetRotatedAzimuthAngle(const FVector &Direction)
46{
47 // 将输入的笛卡尔坐标形式的方向向量转换为球坐标形式,得到球坐标的向量表示
48 const FVector2D SphericalCoords = Direction.UnitCartesianToSpherical();
49 // 将球坐标中的方位角(Y分量)加上PI,实现旋转效果,并返回旋转后的方位角
50 return SphericalCoords.Y + PI;
51}
52
53// =============================================================================
54// -- FRoadMapPixelData --------------------------------------------------------
55// =============================================================================
56
57// FRoadMapPixelData类的成员函数:对道路地图像素数据进行编码
58// @param IsRoad 表示该像素是否对应道路的布尔值
59// @param HasDirection 表示该像素对应的道路是否有方向信息的布尔值
60// @param Direction 若HasDirection为真,则为对应的道路方向向量,否则为零向量
61// @return 编码后的无符号16位整数,包含了道路、方向及角度等信息
62uint16 FRoadMapPixelData::Encode(bool IsRoad, bool HasDirection, const FVector &Direction)
63{
64 // 根据输入的方向向量计算对应的角度,并将其转换为无符号整数形式,用于编码
65 const uint16 AngleAsUInt = MaximumEncodedAngle * GetRotatedAzimuthAngle(Direction) / (2.0f * PI);
66 // 检查编码后的角度是否符合特定条件,即不与表示道路行的标志位冲突(通过位运算判断)
67 check(!(AngleAsUInt & (1 << IsRoadRow)));
68 // 检查编码后的角度是否符合特定条件,即不与表示方向行的标志位冲突(通过位运算判断)
69 check(!(AngleAsUInt & (1 << HasDirectionRow)));
70 // 将道路、方向和角度信息通过位运算进行编码组合,返回最终的编码值
71 return (IsRoad << IsRoadRow) | (HasDirection << HasDirectionRow) | (AngleAsUInt);
72}
73
74// FRoadMapPixelData类的成员函数:将道路地图像素数据编码为颜色值
75// @return 编码后的颜色值,用于在可视化等场景中表示像素信息
77{
78 // 如果该像素不对应道路
79 if (!IsRoad()) {
80 // 返回黑色(RGB值都为0,透明度为255,即完全不透明)作为表示非道路像素的颜色
81 return FColor(0u, 0u, 0u, 255u);
82 } else if (!HasDirection()) {
83 // 如果该像素对应道路但没有方向信息
84 // 返回白色(RGB值都为255,透明度为255,即完全不透明)作为表示无方向道路像素的颜色
85 return FColor(255u, 255u, 255u, 255u);
86 } else {
87 // 定义一个lambda函数,用于将输入的浮点数转换为适合作为颜色分量的值(范围在0 - 255)
88 auto ToColor = [](float X){
89 return FMath::FloorToInt(256.0 * (X + PI) / (2.0f * PI)) % 256;
90 };
91 // 获取道路方向的方位角
92 const float Azimuth = GetDirectionAzimuthalAngle();
93 // 根据上述转换规则,生成一个表示有方向道路像素的颜色值,其中蓝色分量根据方位角变化,红色为0,绿色为255
94 return FColor(0u, 255u, ToColor(Azimuth), 255u);
95 }
96}
97
98// =============================================================================
99// -- URoadMap -----------------------------------------------------------------
100// =============================================================================
101
102// URoadMap类的构造函数,用于初始化道路地图对象的一些默认属性
103// @param ObjectInitializer 对象初始化参数,用于传递给父类构造函数等初始化操作
104URoadMap::URoadMap(const FObjectInitializer& ObjectInitializer) :
105 Super(ObjectInitializer),
106 // 每厘米对应的像素数,初始化为1.0f
107 PixelsPerCentimeter(1.0f),
108 // 地图的宽度,初始化为1个单位(这里单位未明确指定,可能根据具体应用场景而定)
109 Width(1u),
110 // 地图的高度,初始化为1个单位(这里单位未明确指定,可能根据具体应用场景而定)
111 Height(1u)
112{
113 // 向道路地图数据容器中添加一个初始值为0的数据元素,可能用于后续的填充或初始化操作
114 RoadMapData.Add(0u);
115 static_assert(
116 // 静态断言,用于在编译时检查FRoadMapPixelData::Value的类型与RoadMapData容器中元素类型是否匹配
117 // 如果不匹配,编译器会给出相应的错误提示信息
118 std::is_same<decltype(FRoadMapPixelData::Value), typename decltype(RoadMapData)::ElementType>::value,
119 "Declaration map of FRoadMapPixelData's value does not match current serialization type");
120}
121
122// URoadMap类的成员函数:重置道路地图的相关参数和数据
123// @param inWidth 新的地图宽度(无符号32位整数)
124// @param inHeight 新的地图高度(无符号32位整数)
125// @param inPixelsPerCentimeter 新的每厘米对应的像素数(浮点数)
126// @param inWorldToMap 世界坐标到地图坐标的变换信息(FTransform类型)
127// @param inMapOffset 地图在世界坐标中的偏移量(FVector类型)
129 const uint32 inWidth,
130 const uint32 inHeight,
131 const float inPixelsPerCentimeter,
132 const FTransform &inWorldToMap,
133 const FVector &inMapOffset)
134{
135 // 初始化道路地图数据容器,将其中的元素都设置为0,容器大小为新的宽度和高度的乘积
136 RoadMapData.Init(0u, inWidth * inHeight);
137 Width = inWidth;
138 Height = inHeight;
139 PixelsPerCentimeter = inPixelsPerCentimeter;
140 WorldToMap = inWorldToMap;
141 MapOffset = inMapOffset;
142}
143
144// URoadMap类的成员函数:在指定像素位置设置道路地图的像素数据
145// @param PixelX 要设置像素数据的像素在X轴上的坐标(无符号32位整数)
146// @param PixelY 要设置像素数据的像素在Y轴上的坐标(无符号32位整数)
147// @param Tag 城市地图网格标签,用于确定道路类型等相关信息(ECityMapMeshTag类型)
148// @param Transform 与该像素相关的变换信息(FTransform类型)
149// @param bInvertDirection 是否反转方向的布尔值,用于根据具体情况调整道路方向
151 const uint32 PixelX,
152 const uint32 PixelY,
153 const ECityMapMeshTag Tag,
154 const FTransform &Transform,
155 const bool bInvertDirection)
156{
157 bool bIsRoad = false;
158 bool bHasDirection = false;
159 FVector Direction(0.0f, 0.0f, 0.0f);
160
161 // 获取输入的变换信息中的旋转部分,并将其转换为旋转器(Rotator)类型,以便后续处理角度等信息
162 auto Rotator = Transform.GetRotation().Rotator();
163
164 switch (Tag) {
165 default:
166 // 如果标签为默认情况(未在下面的具体分支中匹配到),则认为该像素位置不是道路
167 break;
168 // 以下是各种道路类型对应的处理分支,根据不同的道路类型设置是否为道路、是否有方
169 case ECityMapMeshTag::RoadTwoLanes_LaneRight:
170 case ECityMapMeshTag::Road90DegTurn_Lane1:
171 case ECityMapMeshTag::RoadTIntersection_Lane1:
172 case ECityMapMeshTag::RoadTIntersection_Lane9:
173 case ECityMapMeshTag::RoadXIntersection_Lane1:
174 case ECityMapMeshTag::RoadXIntersection_Lane9:
175 bIsRoad = true;
176 bHasDirection = true;
177 // 对于这些道路类型,将旋转器的偏航角(Yaw)增加180.0f,以调整方向向量的方向
178 Rotator.Yaw += 180.0f;
179 break;
180 case ECityMapMeshTag::RoadTwoLanes_LaneLeft:
181 case ECityMapMeshTag::Road90DegTurn_Lane0:
182 case ECityMapMeshTag::RoadTIntersection_Lane0:
183 case ECityMapMeshTag::RoadTIntersection_Lane2:
184 case ECityMapMeshTag::RoadTIntersection_Lane5:
185 case ECityMapMeshTag::RoadTIntersection_Lane8:
186 case ECityMapMeshTag::RoadXIntersection_Lane0:
187 case ECityMapMeshTag::RoadXIntersection_Lane8:
188 bIsRoad = true;
189 bHasDirection = true;
190 break;
191 case ECityMapMeshTag::Road90DegTurn_Lane9:
192 case ECityMapMeshTag::RoadTIntersection_Lane7:
193 case ECityMapMeshTag::RoadXIntersection_Lane7:
194 case ECityMapMeshTag::RoadXIntersection_Lane5:
195 bIsRoad = true;
196 bHasDirection = true;
197 // 对于这些道路类型,将旋转器的偏航角(Yaw)增加90.0f,以调整方向向量的方向
198 Rotator.Yaw += 90.0f;
199 break;
200 case ECityMapMeshTag::Road90DegTurn_Lane7:
201 bIsRoad = true;
202 bHasDirection = true;
203 // 对于这种道路类型,将旋转器的偏航角(Yaw)增加90.0f(可能还需要进一步调整,注释中有 + 15.5f 的提示,但未实际应用)
204 Rotator.Yaw += 90.0f; //+ 15.5f;
205 break;
206 case ECityMapMeshTag::Road90DegTurn_Lane5:
207 bIsRoad = true;
208 bHasDirection = true;
209 // 对于这种道路类型,将旋转器的偏航角(Yaw)增加90.0f + 35.0f,以调整方向向量的方向
210 Rotator.Yaw += 90.0f + 35.0f;
211 break;
212 case ECityMapMeshTag::Road90DegTurn_Lane3:
213 bIsRoad = true;
214 bHasDirection = true;
215 // 对于这种道路类型,将旋转器的偏航角(Yaw)增加90.0f + 45.0f + 20.5f,以调整方向向量的方向
216 Rotator.Yaw += 90.0f + 45.0f + 20.5f;
217 break;
218 case ECityMapMeshTag::Road90DegTurn_Lane8:
219 case ECityMapMeshTag::RoadTIntersection_Lane4:
220 case ECityMapMeshTag::RoadXIntersection_Lane2:
221 case ECityMapMeshTag::RoadXIntersection_Lane4:
222 bIsRoad = true;
223 bHasDirection = true;
224 // 对于这些道路类型,将旋转器的偏航角(Yaw)增加270.0f,以调整方向向量的方向
225 Rotator.Yaw += 270.0f;
226 break;
227 case ECityMapMeshTag::Road90DegTurn_Lane6:
228 bIsRoad = true;
229 bHasDirection = true;
230 // 对于这种道路类型,将旋转器的偏航角(Yaw)增加270.0f + 50.0f,以调整方向向量的方向
231 Rotator.Yaw += 270.0f + 50.0f;
232 break;
233 case ECityMapMeshTag::Road90DegTurn_Lane4:
234 bIsRoad = true;
235 bHasDirection = true;
236 // 对于这种道路类型,将旋转器的偏航角(Yaw)增加270.0f + 80.0f,以调整方向向量的方向
237 Rotator.Yaw += 270.0f + 80.0f;
238 break;
239 case ECityMapMeshTag::Road90DegTurn_Lane2:
240 bIsRoad = true;
241 bHasDirection = true;
242 //Rotator.Yaw += 270.0f + 70.0f;
243 break;
244 case ECityMapMeshTag::RoadTIntersection_Lane3:
245 case ECityMapMeshTag::RoadTIntersection_Lane6:
246 case ECityMapMeshTag::RoadXIntersection_Lane3:
247 case ECityMapMeshTag::RoadXIntersection_Lane6:
248 bIsRoad = true;
249 bHasDirection = false;
250 break;
251 }
252 if (bHasDirection) {
253 // 如果该像素对应的道路有方向信息,则根据旋转器创建一个四元数(Quat)表示的旋转
254 FQuat Rotation(Rotator);
255 // 获取旋转后的方向向量,即四元数的前向向量
256 Direction = Rotation.GetForwardVector();
257 if (bInvertDirection) {
258 // 如果需要反转方向,则将方向向量取反
259 Direction *= -1.0f;
260 }
261 }
262 const auto Value = FRoadMapPixelData::Encode(bIsRoad, bHasDirection, Direction);
263 RoadMapData[GetIndex(PixelX, PixelY)] = Value;
264}
265
266// URoadMap类的成员函数:根据像素坐标获取对应的世界坐标位置
267// @param PixelX 像素在X轴上的坐标(无符号32位整数)
268// @param PixelY 像素在Y轴上的坐标(无符号32位整数)
269// @return 对应的世界坐标位置(FVector类型)
270FVector URoadMap::GetWorldLocation(uint32 PixelX, uint32 PixelY) const
271{
272 const FVector RelativePosition(
273 static_cast<float>(PixelX) / PixelsPerCentimeter,
274 static_cast<float>(PixelY) / PixelsPerCentimeter,
275 0.0f);
276 return WorldToMap.InverseTransformPosition(RelativePosition + MapOffset);
277}
278
279// URoadMap类的成员函数:根据世界坐标位置获取对应的道路地图像素数据
280// @param WorldLocation 要获取像素数据对应的世界坐标位置(FVector类型)
281// @return 对应的道路地图像素数据(FRoadMapPixelData类型)
282FRoadMapPixelData URoadMap::GetDataAt(const FVector &WorldLocation) const
283{
284 check(IsValid());
285 const FVector Location = WorldToMap.TransformPosition(WorldLocation) - MapOffset;
286 uint32 X = ClampFloatToUInt(PixelsPerCentimeter * Location.X, 0, Width - 1);
287 uint32 Y = ClampFloatToUInt(PixelsPerCentimeter * Location.Y, 0, Height - 1);
288 return GetDataAt(X, Y);
289}
290
291// URoadMap类的成员函数:计算道路地图与一个长方体的相交情况
292// @param BoxTransform 长方体的变换信息(FTransform类型),用于确定长方体在世界坐标中的位置和姿态
293// @param BoxExtent 长方体的范围(FVector类型),表示长方体在各个坐标轴方向上的尺寸大小
294// @param ChecksPerCentimeter 每厘米的检查次数(浮点数),用于控制相交检测的精度
295// @return 相交结果结构体
297 const FTransform &BoxTransform,
298 const FVector &BoxExtent,
299 float ChecksPerCentimeter) const
300{
301 auto DirectionOfMovement = BoxTransform.GetRotation().GetForwardVector();
302 DirectionOfMovement.Z = 0.0f; // Project to XY plane (won't be normalized anymore).
303 uint32 CheckCount = 0u;
304 FRoadMapIntersectionResult Result = {0.0f, 0.0f};
305 const float Step = 1.0f / ChecksPerCentimeter;
306 for (float X = -BoxExtent.X; X < BoxExtent.X; X += Step) {
307 for (float Y = -BoxExtent.Y; Y < BoxExtent.Y; Y += Step) {
308 ++CheckCount;
309 auto Location = BoxTransform.TransformPosition(FVector(X, Y, 0.0f));
310 const auto &Data = GetDataAt(Location);
311 if (!Data.IsRoad()) {
312 Result.OffRoad += 1.0f;
313 } else if (Data.HasDirection() &&
314 0.0f > FVector::DotProduct(Data.GetDirection(), DirectionOfMovement)) {
315 Result.OppositeLane += 1.0f;
316 }
317 }
318 }
319 // 如果CheckCount大于0(这里的0u表示无符号的0)
320 if (CheckCount > 0u) {
321 // 将Result结构体中的OffRoad成员除以CheckCount(先将CheckCount转换为float类型)
322 Result.OffRoad /= static_cast<float>(CheckCount);
323 // 将Result结构体中的OppositeLane成员除以CheckCount(同样先转换类型)
324 Result.OppositeLane /= static_cast<float>(CheckCount);
325 } else {
326 UE_LOG(LogCarla, Warning, TEXT("URoadMap::Intersect did zero checks"));
327 }
328 return Result;
329}
330
331// 声明一个函数,用于将道路地图数据保存为PNG图片和元数据文件。
332bool URoadMap::SaveAsPNG(const FString &Folder, const FString &MapName) const
333{
334 // 如果道路地图数据无效,则记录错误日志并返回false
335 if (!IsValid()) {
336 UE_LOG(LogCarla, Error, TEXT("Cannot save invalid road map to disk"));
337 return false;
338 }
339
340 // 构造PNG图片文件的完整路径。
341 const FString ImagePath = FPaths::Combine(Folder, MapName + TEXT(".png"));
342 // 构造元数据文件的完整路径。
343 const FString MetadataPath = FPaths::Combine(Folder, MapName + TEXT(".txt"));
344
345 // 设置目标图像的尺寸。
346 const FIntPoint DestSize(Width, Height);
347 // 创建一个指向TImagePixelData<FColor>的智能指针,用于存储像素数据。
348 TUniquePtr<TImagePixelData<FColor>> PixelData = MakeUnique<TImagePixelData<FColor>>(DestSize);
349 // 为像素数据预留空间。
350 PixelData->Pixels.Reserve(RoadMapData.Num());
351 // 遍历道路地图数据,将每个数据点转换为颜色,并添加到像素数据中。
352 for (auto Value : RoadMapData) {
353 PixelData->Pixels.Emplace(FRoadMapPixelData(Value).EncodeAsColor());
354 }
355 // 将像素数据保存到磁盘上的PNG文件。
356 FPixelReader::SavePixelsToDisk(std::move(PixelData), ImagePath);
357
358 // 保存元数据
359 FFormatNamedArguments Args;
360 Args.Add("MapName", FText::FromString(MapName));
361 Args.Add("Width", GetWidth());
362 Args.Add("Height", GetHeight());
363 Args.Add("CmPerPixel", 1.0f / PixelsPerCentimeter);
364 Args.Add("Transform", FText::FromString(WorldToMap.ToString()));
365 Args.Add("Offset", FText::FromString(MapOffset.ToString()));
366
367 // 使用格式化参数对象和格式化字符串来创建元数据内容。
368 const auto Contents = FText::Format(
369 LOCTEXT("RoadMapMetadata",
370 "Map name = {MapName}\n"
371 "Size = {Width}x{Height} pixels\n"
372 "Density = {CmPerPixel} cm/pixel\n"
373 "World-To-Map Transform (T|R|S) = ({Transform})\n"
374 "Map Offset = ({Offset})\n"),
375 Args);
376 // 将元数据内容保存到文本文件,如果失败则记录错误日志。
377 if (!FFileHelper::SaveStringToFile(Contents.ToString(), *MetadataPath)) {
378 UE_LOG(LogCarla, Error, TEXT("Failed to save map metadata"));
379 }
380
381 // 记录日志,表示道路地图已保存。
382 UE_LOG(LogCarla, Log, TEXT("Saved road map to \"%s\""), *ImagePath);
383 return true;
384}
385
386#if WITH_EDITOR
387
388// 一个成员函数,用于在编辑器中记录道路地图的相关信息。
389void URoadMap::Log() const
390{
391 // 计算地图数据的大小(以MB为单位)。
392 const float MapSizeInMB = // Only map data, not the class itself.
393 static_cast<float>(sizeof(decltype(RoadMapData)::ElementType) * RoadMapData.Num()) /
394 (1024.0f * 1024.0f);
395 // 记录地图的尺寸、大小和比例尺信息。
396 UE_LOG(
397 LogCarla,
398 Log,
399 TEXT("Generated road map %dx%d (%.2fMB) with %.2f cm/pixel"),
400 GetWidth(),
401 GetHeight(),
402 MapSizeInMB,
403 1.0f / PixelsPerCentimeter);
404
405 // 如果道路地图数据无效,则记录错误日志并返回。
406 if (!IsValid()) {
407 UE_LOG(LogCarla, Error, TEXT("Error generating road map"));
408 return;
409 }
410}
411
412// 一个成员函数,用于在编辑器中绘制调试像素。
413void URoadMap::DrawDebugPixelsToLevel(UWorld *World, const bool bJustFlushDoNotDraw) const
414{
415 // 定义Z轴偏移量。
416 const FVector ZOffset(0.0f, 0.0f, 50.0f);
417 // 清除持久的调试线条。
418 FlushPersistentDebugLines(World);
419 // 如果不只刷新而不绘制,则直接返回。
420 if (!bJustFlushDoNotDraw) {
421 // 遍历地图的每个像素点。
422 for (auto X = 0u; X < Width; ++X) {
423 for (auto Y = 0u; Y < Height; ++Y) {
424 // 获取当前像素点的世界位置,并添加Z轴偏移量。
425 auto Location = GetWorldLocation(X, Y) + ZOffset;
426 // 获取当前像素点的数据。
427 const auto &Data = GetDataAt(X, Y);
428 // 获取当前像素点的颜色。
429 auto Color = Data.EncodeAsColor();
430 // 如果数据包含方向信息,则绘制方向箭头,否则绘制点。
431 if (Data.HasDirection()) {
432 const FVector ArrowEnd = Location + 50.0f * Data.GetDirection();
433 DrawDebugDirectionalArrow(World, Location, ArrowEnd, 60.0f, Color, true);
434 } else {
435 DrawDebugPoint(World, Location, 6.0f, Color, true);
436 }
437 }
438 }
439 }
440}
441
442#endif // WITH_EDITOR
443
444#undef LOCTEXT_NAMESPACE
UE_LOG(LogCarla, Log, TEXT("UActorDispatcher::Destroying actor: '%s' %x"), *Id, Actor)
TSharedPtr< const FActorInfo > carla::rpc::ActorState UWorld * World
ECityMapMeshTag
用于标识ProceduralMapGenerator所使用的网格的标签
static uint32 ClampFloatToUInt(const float Value, int32 Min, int32 Max)
Definition RoadMap.cpp:34
static float GetRotatedAzimuthAngle(const FVector &Direction)
Definition RoadMap.cpp:45
static TFuture< bool > SavePixelsToDisk(UTextureRenderTarget2D &RenderTarget, const FString &FilePath)
异步保存 RenderTarget 中的像素到磁盘。
uint32 Height
地图的高度(以像素为单位)。
Definition RoadMap.h:189
FVector GetWorldLocation(uint32 PixelX, uint32 PixelY) const
返回给定像素的世界位置。
Definition RoadMap.cpp:270
int32 GetIndex(uint32 PixelX, uint32 PixelY) const
Definition RoadMap.h:161
void Reset(uint32 Width, uint32 Height, float PixelsPerCentimeter, const FTransform &WorldToMap, const FVector &MapOffset)
重置当前映射 - 初始化给定大小的空映射。
Definition RoadMap.cpp:128
bool IsValid() const
Definition RoadMap.h:166
void SetPixelAt(uint32 PixelX, uint32 PixelY, ECityMapMeshTag Tag, const FTransform &Transform, bool bInvertDirection=false)
Definition RoadMap.cpp:150
URoadMap(const FObjectInitializer &ObjectInitializer)
创建有效的空地图(每个点都是越野的)。
Definition RoadMap.cpp:104
float PixelsPerCentimeter
每厘米像素数。
Definition RoadMap.h:181
TArray< uint16 > RoadMapData
Definition RoadMap.h:192
FVector MapOffset
地图坐标中的偏移量。
Definition RoadMap.h:177
uint32 Width
地图的宽度(以像素为单位)。
Definition RoadMap.h:185
FTransform WorldToMap
世界到地图的转换。
Definition RoadMap.h:173
uint32 GetHeight() const
Definition RoadMap.h:119
bool SaveAsPNG(const FString &Folder, const FString &MapName) const
将当前地图另存为 PNG,并将像素数据编码为颜色。
Definition RoadMap.cpp:332
uint32 GetWidth() const
Definition RoadMap.h:114
FRoadMapIntersectionResult Intersect(const FTransform &BoxTransform, const FVector &BoxExtent, float ChecksPerCentimeter) const
将角色边界与地图相交。
Definition RoadMap.cpp:296
FRoadMapPixelData GetDataAt(uint32 PixelX, uint32 PixelY) const
检索存储在给定像素处的数据。
Definition RoadMap.h:128
Vector3D GetForwardVector() const
Definition Rotation.h:64
geom::Location Location
路线图交叉路口结果。请参阅 URoadMap。
Definition RoadMap.h:16
float OppositeLane
框侵入对面车道的百分比(方向错误)。
Definition RoadMap.h:25
float OffRoad
箱子在越野时的百分比。
Definition RoadMap.h:21
数据存储在路线图像素中。请参阅 URoadMap。
Definition RoadMap.h:30
float GetDirectionAzimuthalAngle() const
获取道路方向的方位角 [-PI, PI](球面 坐标)的 S Package。
Definition RoadMap.h:62
bool HasDirection() const
此像素是否定义了方向(例如,道路交叉口为 不是越野,但都没有明确的方向)。
Definition RoadMap.h:53
static constexpr uint16 MaximumEncodedAngle
Definition RoadMap.h:37
static uint16 Encode(bool IsRoad, bool HasDirection, const FVector &Direction)
Definition RoadMap.cpp:62
bool IsRoad() const
此像素是否位于道路上。
Definition RoadMap.h:46
static constexpr int HasDirectionRow
Definition RoadMap.h:35
static constexpr int IsRoadRow
Definition RoadMap.h:33
FColor EncodeAsColor() const
Definition RoadMap.cpp:76