CARLA
Public Member Functions | Private Member Functions | Private Attributes | List of all members
URoadMap Class Reference

Road map of the level. More...

#include <RoadMap.h>

+ Inheritance diagram for URoadMap:
+ Collaboration diagram for URoadMap:

Public Member Functions

FRoadMapPixelData GetDataAt (uint32 PixelX, uint32 PixelY) const
 Retrieve the data stored at a given pixel. More...
 
FRoadMapPixelData GetDataAt (const FVector &WorldLocation) const
 Clamps value if lies outside map limits. More...
 
uint32 GetHeight () const
 
uint32 GetWidth () const
 
FVector GetWorldLocation (uint32 PixelX, uint32 PixelY) const
 Return the world location of a given pixel. More...
 
FRoadMapIntersectionResult Intersect (const FTransform &BoxTransform, const FVector &BoxExtent, float ChecksPerCentimeter) const
 Intersect actor bounds with map. More...
 
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. More...
 
bool SaveAsPNG (const FString &Folder, const FString &MapName) const
 Save the current map as PNG with the pixel data encoded as color. More...
 
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). More...
 

Private Member Functions

int32 GetIndex (uint32 PixelX, uint32 PixelY) const
 
bool IsValid () const
 

Private Attributes

uint32 Height
 Height of the map in pixels. More...
 
FVector MapOffset
 Offset of the map in map coordinates. More...
 
float PixelsPerCentimeter
 Number of pixels per centimeter. More...
 
TArray< uint16 > RoadMapData
 
uint32 Width
 Width of the map in pixels. More...
 
FTransform WorldToMap
 World-to-map transform. More...
 

Detailed Description

Road map of the level.

Contains information in 2D of which areas are road and lane directions.

Definition at line 90 of file RoadMap.h.

Constructor & Destructor Documentation

◆ URoadMap()

URoadMap::URoadMap ( const FObjectInitializer &  ObjectInitializer)

Creates a valid empty map (every point is off-road).

Definition at line 71 of file RoadMap.cpp.

References RoadMapData, and FRoadMapPixelData::Value.

Member Function Documentation

◆ GetDataAt() [1/2]

FRoadMapPixelData URoadMap::GetDataAt ( uint32  PixelX,
uint32  PixelY 
) const
inline

Retrieve the data stored at a given pixel.

Definition at line 128 of file RoadMap.h.

References GetIndex(), Intersect(), IsValid(), RoadMapData, and SaveAsPNG().

Referenced by GetDataAt(), Intersect(), and SaveAsPNG().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDataAt() [2/2]

FRoadMapPixelData URoadMap::GetDataAt ( const FVector &  WorldLocation) const

Clamps value if lies outside map limits.

Definition at line 210 of file RoadMap.cpp.

References ClampFloatToUInt(), GetDataAt(), Height, IsValid(), MapOffset, PixelsPerCentimeter, Width, and WorldToMap.

+ Here is the call graph for this function:

◆ GetHeight()

uint32 URoadMap::GetHeight ( ) const
inline

Definition at line 119 of file RoadMap.h.

References GetWorldLocation(), and Height.

Referenced by SaveAsPNG().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetIndex()

int32 URoadMap::GetIndex ( uint32  PixelX,
uint32  PixelY 
) const
inlineprivate

Definition at line 161 of file RoadMap.h.

Referenced by GetDataAt(), and SetPixelAt().

+ Here is the caller graph for this function:

◆ GetWidth()

uint32 URoadMap::GetWidth ( ) const
inline

Definition at line 114 of file RoadMap.h.

References Width.

Referenced by SaveAsPNG().

+ Here is the caller graph for this function:

◆ GetWorldLocation()

FVector URoadMap::GetWorldLocation ( uint32  PixelX,
uint32  PixelY 
) const

Return the world location of a given pixel.

Definition at line 201 of file RoadMap.cpp.

References MapOffset, PixelsPerCentimeter, and WorldToMap.

Referenced by GetHeight(), and SaveAsPNG().

+ Here is the caller graph for this function:

◆ Intersect()

FRoadMapIntersectionResult URoadMap::Intersect ( const FTransform &  BoxTransform,
const FVector &  BoxExtent,
float  ChecksPerCentimeter 
) const

Intersect actor bounds with map.

Bounds box is projected to the map and checked against it for possible intersections with off-road areas and opposite lanes.

Definition at line 219 of file RoadMap.cpp.

References GetDataAt(), FRoadMapIntersectionResult::OffRoad, and FRoadMapIntersectionResult::OppositeLane.

Referenced by GetDataAt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsValid()

bool URoadMap::IsValid ( ) const
inlineprivate

Definition at line 166 of file RoadMap.h.

References RoadMapData, and Width.

Referenced by GetDataAt(), and SaveAsPNG().

+ Here is the caller graph for this function:

◆ Reset()

void URoadMap::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.

Definition at line 83 of file RoadMap.cpp.

References Height, MapOffset, PixelsPerCentimeter, RoadMapData, Width, and WorldToMap.

Referenced by ACityMapGenerator::GenerateRoadMap().

+ Here is the caller graph for this function:

◆ SaveAsPNG()

bool URoadMap::SaveAsPNG ( const FString &  Folder,
const FString &  MapName 
) const

Save the current map as PNG with the pixel data encoded as color.

Definition at line 251 of file RoadMap.cpp.

References GetDataAt(), GetHeight(), GetWidth(), GetWorldLocation(), Height, IsValid(), MapOffset, PixelsPerCentimeter, RoadMapData, FPixelReader::SavePixelsToDisk(), Width, and WorldToMap.

Referenced by ACityMapGenerator::GenerateRoadMap(), and GetDataAt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetPixelAt()

void URoadMap::SetPixelAt ( uint32  PixelX,
uint32  PixelY,
ECityMapMeshTag  Tag,
const FTransform &  Transform,
bool  bInvertDirection = false 
)

Definition at line 98 of file RoadMap.cpp.

References FRoadMapPixelData::Encode(), GetIndex(), and RoadMapData.

Referenced by ACityMapGenerator::GenerateRoadMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ Height

uint32 URoadMap::Height
private

Height of the map in pixels.

Definition at line 189 of file RoadMap.h.

Referenced by GetDataAt(), GetHeight(), Reset(), and SaveAsPNG().

◆ MapOffset

FVector URoadMap::MapOffset
private

Offset of the map in map coordinates.

Definition at line 177 of file RoadMap.h.

Referenced by GetDataAt(), GetWorldLocation(), Reset(), and SaveAsPNG().

◆ PixelsPerCentimeter

float URoadMap::PixelsPerCentimeter
private

Number of pixels per centimeter.

Definition at line 181 of file RoadMap.h.

Referenced by GetDataAt(), GetWorldLocation(), Reset(), and SaveAsPNG().

◆ RoadMapData

TArray<uint16> URoadMap::RoadMapData
private

Definition at line 192 of file RoadMap.h.

Referenced by GetDataAt(), IsValid(), Reset(), SaveAsPNG(), SetPixelAt(), and URoadMap().

◆ Width

uint32 URoadMap::Width
private

Width of the map in pixels.

Definition at line 185 of file RoadMap.h.

Referenced by GetDataAt(), GetWidth(), IsValid(), Reset(), and SaveAsPNG().

◆ WorldToMap

FTransform URoadMap::WorldToMap
private

World-to-map transform.

Definition at line 173 of file RoadMap.h.

Referenced by GetDataAt(), GetWorldLocation(), Reset(), and SaveAsPNG().


The documentation for this class was generated from the following files: