CARLA
Loading...
Searching...
No Matches
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:

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

Detailed Description

Road map of the level.

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

Definition at line 94 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 ( 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.

◆ GetDataAt() [2/2]

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

Retrieve the data stored at a given pixel.

Definition at line 132 of file RoadMap.h.

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

Referenced by GetDataAt(), and Intersect().

◆ GetHeight()

uint32 URoadMap::GetHeight ( ) const
inline

Definition at line 123 of file RoadMap.h.

References Height.

Referenced by SaveAsPNG().

◆ GetIndex()

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

Definition at line 165 of file RoadMap.h.

References Width.

Referenced by GetDataAt(), and SetPixelAt().

◆ GetWidth()

uint32 URoadMap::GetWidth ( ) const
inline

Definition at line 118 of file RoadMap.h.

References Width.

Referenced by SaveAsPNG().

◆ 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.

◆ 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.

◆ IsValid()

bool URoadMap::IsValid ( ) const
inlineprivate

Definition at line 170 of file RoadMap.h.

References Height, RoadMapData, and Width.

Referenced by GetDataAt(), and SaveAsPNG().

◆ 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().

◆ 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 FRoadMapPixelData::EncodeAsColor(), GetHeight(), GetWidth(), Height, IsValid(), MapOffset, PixelsPerCentimeter, RoadMapData, FPixelReader::SavePixelsToDisk(), Width, and WorldToMap.

Referenced by ACityMapGenerator::GenerateRoadMap().

◆ SetPixelAt()

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

Member Data Documentation

◆ Height

uint32 URoadMap::Height
private

Height of the map in pixels.

Definition at line 193 of file RoadMap.h.

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

◆ MapOffset

FVector URoadMap::MapOffset
private

Offset of the map in map coordinates.

Definition at line 181 of file RoadMap.h.

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

◆ PixelsPerCentimeter

float URoadMap::PixelsPerCentimeter
private

Number of pixels per centimeter.

Definition at line 185 of file RoadMap.h.

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

◆ RoadMapData

TArray<uint16> URoadMap::RoadMapData
private

Definition at line 196 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 189 of file RoadMap.h.

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

◆ WorldToMap

FTransform URoadMap::WorldToMap
private

World-to-map transform.

Definition at line 177 of file RoadMap.h.

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


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