9#include "UObject/NoExportTypes.h"
11#include "RoadMap.generated.h"
20 UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
24 UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
33 constexpr static int IsRoadRow = 15;
35 constexpr static int HasDirectionRow = 14;
37 constexpr static uint16 MaximumEncodedAngle = (1 << 14) - 1;
39 constexpr static uint16 AngleMask = (0xFFFF >> 2);
48 return (Value & (1 << IsRoadRow)) != 0;
55 return (Value & (1 << HasDirectionRow)) != 0;
64 const float Angle = AngleMask & Value;
66 return (Angle * 2.0f * PI / MaximumEncodedAngle) - PI;
74 const FVector2D SphericalCoords(HALF_PI, GetDirectionAzimuthalAngle());
75 return SphericalCoords.SphericalToUnitCartesian();
78 FColor EncodeAsColor()
const;
82 static uint16 Encode(
bool IsRoad,
bool HasDirection,
const FVector &Direction);
97 URoadMap(
const FObjectInitializer& ObjectInitializer);
111 const FTransform &Transform,
112 bool bInvertDirection =
false);
142 const FTransform &BoxTransform,
143 const FVector &BoxExtent,
144 float ChecksPerCentimeter)
const;
147 bool SaveAsPNG(
const FString &Folder,
const FString &MapName)
const;
155 void DrawDebugPixelsToLevel(UWorld *World,
bool bJustFlushDoNotDraw =
false)
const;
163 return PixelX +
Width * PixelY;
172 UPROPERTY(VisibleAnywhere)
176 UPROPERTY(VisibleAnywhere)
180 UPROPERTY(VisibleAnywhere)
184 UPROPERTY(VisibleAnywhere)
188 UPROPERTY(VisibleAnywhere)
ECityMapMeshTag
Tag to identify the meshes used by the ProceduralMapGenerator.
static bool IsValid(const ACarlaWheeledVehicle *Vehicle)
uint32 Height
Height of the map in pixels.
FVector GetWorldLocation(uint32 PixelX, uint32 PixelY) const
Return the world location of a given pixel.
int32 GetIndex(uint32 PixelX, uint32 PixelY) const
void Reset(uint32 Width, uint32 Height, float PixelsPerCentimeter, const FTransform &WorldToMap, const FVector &MapOffset)
Resets current map an initializes an empty map of the given size.
void SetPixelAt(uint32 PixelX, uint32 PixelY, ECityMapMeshTag Tag, const FTransform &Transform, bool bInvertDirection=false)
URoadMap(const FObjectInitializer &ObjectInitializer)
Creates a valid empty map (every point is off-road).
float PixelsPerCentimeter
Number of pixels per centimeter.
TArray< uint16 > RoadMapData
FVector MapOffset
Offset of the map in map coordinates.
uint32 Width
Width of the map in pixels.
FTransform WorldToMap
World-to-map transform.
bool SaveAsPNG(const FString &Folder, const FString &MapName) const
Save the current map as PNG with the pixel data encoded as color.
FRoadMapIntersectionResult Intersect(const FTransform &BoxTransform, const FVector &BoxExtent, float ChecksPerCentimeter) const
Intersect actor bounds with map.
FRoadMapPixelData GetDataAt(uint32 PixelX, uint32 PixelY) const
Retrieve the data stored at a given pixel.
Road map intersection result. See URoadMap.
Data stored in a road map pixel. See URoadMap.
float GetDirectionAzimuthalAngle() const
Get the azimuth angle [-PI, PI] of the road direction (in spherical coordinates) at this pixel.
bool HasDirection() const
Whether this pixel has a direction defined (e.g.
FVector GetDirection() const
Get the road direction at this pixel.
bool IsRoad() const
Whether this pixel lies in-road.
FRoadMapPixelData(uint16 inValue)