9 #include "UObject/NoExportTypes.h" 11 #include "RoadMap.generated.h" 14 USTRUCT(BlueprintType)
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);
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;
157 #endif // WITH_EDITOR 163 return PixelX + Width * PixelY;
172 UPROPERTY(VisibleAnywhere)
173 FTransform WorldToMap;
176 UPROPERTY(VisibleAnywhere)
180 UPROPERTY(VisibleAnywhere)
181 float PixelsPerCentimeter;
184 UPROPERTY(VisibleAnywhere)
188 UPROPERTY(VisibleAnywhere)
TArray< uint16 > RoadMapData
bool IsRoad() const
Whether this pixel lies in-road.
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.
FVector GetWorldLocation(uint32 PixelX, uint32 PixelY) const
Return the world location of a given pixel.
void SetPixelAt(uint32 PixelX, uint32 PixelY, ECityMapMeshTag Tag, const FTransform &Transform, bool bInvertDirection=false)
uint32 Height
Height of the map in pixels.
Road map intersection result. See URoadMap.
FVector GetDirection() const
Get the road direction at this pixel.
ECityMapMeshTag
Tag to identify the meshes used by the ProceduralMapGenerator.
URoadMap(const FObjectInitializer &ObjectInitializer)
Creates a valid empty map (every point is off-road).
static bool IsValid(const ACarlaWheeledVehicle *Vehicle)
FRoadMapPixelData GetDataAt(uint32 PixelX, uint32 PixelY) const
Retrieve the data stored at a given pixel.
Data stored in a road map pixel. See URoadMap.
FRoadMapIntersectionResult Intersect(const FTransform &BoxTransform, const FVector &BoxExtent, float ChecksPerCentimeter) const
Intersect actor bounds with map.
FTransform WorldToMap
World-to-map transform.
float GetDirectionAzimuthalAngle() const
Get the azimuth angle [-PI, PI] of the road direction (in spherical coordinates) at this pixel...
uint32 Width
Width of the map in pixels.
bool SaveAsPNG(const FString &Folder, const FString &MapName) const
Save the current map as PNG with the pixel data encoded as color.
int32 GetIndex(uint32 PixelX, uint32 PixelY) const
FVector MapOffset
Offset of the map in map coordinates.
geom::Transform Transform
FRoadMapPixelData(uint16 inValue)
float PixelsPerCentimeter
Number of pixels per centimeter.
bool HasDirection() const
Whether this pixel has a direction defined (e.g.