CARLA
List of all members
ACityMapGenerator Class Reference

Generates a random city using the meshes provided. More...

#include <CityMapGenerator.h>

+ Inheritance diagram for ACityMapGenerator:
+ Collaboration diagram for ACityMapGenerator:

Public Member Functions

Constructor and destructor
 ACityMapGenerator (const FObjectInitializer &ObjectInitializer)
 
 ~ACityMapGenerator ()
 
Overriden from UObject
virtual void PreSave (const ITargetPlatform *TargetPlatform) override
 
- Public Member Functions inherited from ACityMapMeshHolder
 ACityMapMeshHolder (const FObjectInitializer &ObjectInitializer)
 Initializes the mesh holders. More...
 

Private Member Functions

Overriden from ACityMapMeshHolder
virtual void UpdateMap () override
 Here does nothing, implement in derived classes. More...
 
Map construction and update related methods
void UpdateSeeds ()
 Update the random seeds. Generate random if no fixed seed is used. More...
 
void GenerateGraph ()
 Regenerate the DCEL. More...
 
void GenerateRoads ()
 Add the road meshes to the scene based on the current DCEL. More...
 
void GenerateRoadMap ()
 Generate the road map image and save to disk if requested. More...
 

Private Attributes

Map generation properties
uint32 MapSizeX = 20u
 Size X of the map in map units. More...
 
uint32 MapSizeY = 20u
 Size Y of the map in map units. More...
 
bool bGenerateRoads = true
 If false, no mesh is added, only the internal representation of road is generated. More...
 
bool bUseFixedSeed = true
 If false, a random seed is generated each time. More...
 
int32 Seed = 123456789
 Seed of the random map generated. More...
 
Other private members
TUniquePtr< MapGen::DoublyConnectedEdgeListDcel
 
TUniquePtr< MapGen::GraphParserDcelParser
 

Road Map

bool bTriggerRoadMapGeneration = false
 Trigger the generation a the road map image of the current layout (used for off-road and opposite lane invasion detection). More...
 
uint32 PixelsPerMapUnit = 50u
 The resolution in pixels per map unit of the road map. More...
 
bool bLeftHandTraffic = false
 Whether the road map should be generated based on left-hand traffic. More...
 
bool bSaveRoadMapToDisk = true
 If true, the road map encoded as an image is saved to disk. More...
 
bool bDrawDebugPixelsToLevel = false
 If true, a debug point is drawn in the level for each pixel of the road map. More...
 
bool bGenerateRoadMapOnSave = true
 The road map is re-computed on save so we always store an up-to-date version. More...
 
bool bTagForSemanticSegmentation = false
 If true, activate the custom depth pass of each tagged actor in the level. More...
 
URoadMapRoadMap
 
URoadMapGetRoadMap ()
 

Additional Inherited Members

- Protected Member Functions inherited from ACityMapMeshHolder
void AddInstance (ECityMapMeshTag Tag, uint32 X, uint32 Y)
 Add an instance of a mesh with a given tile location. More...
 
void AddInstance (ECityMapMeshTag Tag, uint32 X, uint32 Y, float Angle)
 Add an instance of a mesh with a given tile location and rotation. More...
 
void AddInstance (ECityMapMeshTag Tag, FTransform Transform)
 Add an instance of a mesh with a given transform. More...
 
float GetMapScale () const
 
UStaticMesh * GetStaticMesh (ECityMapMeshTag Tag)
 Return the static mesh corresponding to Tag. More...
 
const UStaticMesh * GetStaticMesh (ECityMapMeshTag Tag) const
 Return the static mesh corresponding to Tag. More...
 
ECityMapMeshTag GetTag (const UStaticMesh &StaticMesh) const
 Return the tag corresponding to StaticMesh. More...
 
FVector GetTileLocation (uint32 X, uint32 Y) const
 Return the 3D world location (relative to this actor) of the given 2D tile. More...
 
virtual void OnConstruction (const FTransform &Transform) override
 Initializes the instantiators. More...
 
virtual void PostInitializeComponents () override
 
void SetStaticMesh (ECityMapMeshTag Tag, UStaticMesh *Mesh)
 Set the static mesh associated with Tag. More...
 

Detailed Description

Generates a random city using the meshes provided.

Note
At this point it only generates roads and sidewalks.

Definition at line 22 of file CityMapGenerator.h.

Constructor & Destructor Documentation

◆ ACityMapGenerator()

ACityMapGenerator::ACityMapGenerator ( const FObjectInitializer &  ObjectInitializer)

Definition at line 51 of file CityMapGenerator.cpp.

References RoadMap.

◆ ~ACityMapGenerator()

ACityMapGenerator::~ACityMapGenerator ( )

Definition at line 57 of file CityMapGenerator.cpp.

Member Function Documentation

◆ GenerateGraph()

void ACityMapGenerator::GenerateGraph ( )
private

Regenerate the DCEL.

Definition at line 109 of file CityMapGenerator.cpp.

References Dcel, DcelParser, MapGen::GraphGenerator::Generate(), MapSizeX, MapSizeY, and Seed.

Referenced by UpdateMap().

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

◆ GenerateRoadMap()

void ACityMapGenerator::GenerateRoadMap ( )
private

Generate the road map image and save to disk if requested.

Definition at line 262 of file CityMapGenerator.cpp.

References bDrawDebugPixelsToLevel, bLeftHandTraffic, bSaveRoadMapToDisk, bTagForSemanticSegmentation, ACityMapMeshHolder::GetMapScale(), CityMapMeshTag::GetRoadIntersectionSize(), ACityMapMeshHolder::GetTag(), LineTrace(), MapSizeX, MapSizeY, PixelsPerMapUnit, URoadMap::Reset(), RoadMap, URoadMap::SaveAsPNG(), URoadMap::SetPixelAt(), and ATagger::TagActorsInLevel().

Referenced by PreSave(), and UpdateMap().

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

◆ GenerateRoads()

void ACityMapGenerator::GenerateRoads ( )
private

Add the road meshes to the scene based on the current DCEL.

Definition at line 153 of file CityMapGenerator.cpp.

References ADD_INTERSECTION, ACityMapMeshHolder::AddInstance(), Dcel, CityMapMeshTag::GetRoadIntersectionSize(), FHalfEdgeCounter::Insert(), min(), MapGen::TIntersection, MapGen::Turn90Deg, and MapGen::XIntersection.

Referenced by UpdateMap().

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

◆ GetRoadMap()

URoadMap* ACityMapGenerator::GetRoadMap ( )
inline

Definition at line 62 of file CityMapGenerator.h.

◆ PreSave()

void ACityMapGenerator::PreSave ( const ITargetPlatform *  TargetPlatform)
overridevirtual

Definition at line 63 of file CityMapGenerator.cpp.

References bGenerateRoadMapOnSave, GenerateRoadMap(), and RoadMap.

+ Here is the call graph for this function:

◆ UpdateMap()

void ACityMapGenerator::UpdateMap ( )
overrideprivatevirtual

Here does nothing, implement in derived classes.

Reimplemented from ACityMapMeshHolder.

Definition at line 83 of file CityMapGenerator.cpp.

References bGenerateRoads, bTriggerRoadMapGeneration, GenerateGraph(), GenerateRoadMap(), GenerateRoads(), and UpdateSeeds().

+ Here is the call graph for this function:

◆ UpdateSeeds()

void ACityMapGenerator::UpdateSeeds ( )
private

Update the random seeds. Generate random if no fixed seed is used.

Definition at line 100 of file CityMapGenerator.cpp.

References bUseFixedSeed, and Seed.

Referenced by UpdateMap().

+ Here is the caller graph for this function:

Member Data Documentation

◆ bDrawDebugPixelsToLevel

bool ACityMapGenerator::bDrawDebugPixelsToLevel = false
private

If true, a debug point is drawn in the level for each pixel of the road map.

Definition at line 152 of file CityMapGenerator.h.

Referenced by GenerateRoadMap().

◆ bGenerateRoadMapOnSave

bool ACityMapGenerator::bGenerateRoadMapOnSave = true
private

The road map is re-computed on save so we always store an up-to-date version.

Uncheck this only for testing purposes as the road map might get out-of-sync with the current road layout.

Definition at line 159 of file CityMapGenerator.h.

Referenced by PreSave().

◆ bGenerateRoads

bool ACityMapGenerator::bGenerateRoads = true
private

If false, no mesh is added, only the internal representation of road is generated.

Definition at line 109 of file CityMapGenerator.h.

Referenced by UpdateMap().

◆ bLeftHandTraffic

bool ACityMapGenerator::bLeftHandTraffic = false
private

Whether the road map should be generated based on left-hand traffic.

Definition at line 140 of file CityMapGenerator.h.

Referenced by GenerateRoadMap().

◆ bSaveRoadMapToDisk

bool ACityMapGenerator::bSaveRoadMapToDisk = true
private

If true, the road map encoded as an image is saved to disk.

The image is saved to the "Saved" folder of the project.

Definition at line 146 of file CityMapGenerator.h.

Referenced by GenerateRoadMap().

◆ bTagForSemanticSegmentation

bool ACityMapGenerator::bTagForSemanticSegmentation = false
private

If true, activate the custom depth pass of each tagged actor in the level.

This pass is necessary for rendering the semantic segmentation. However, it may add a performance penalty since occlusion doesn't seem to be applied to objects having this value active.

Definition at line 167 of file CityMapGenerator.h.

Referenced by GenerateRoadMap().

◆ bTriggerRoadMapGeneration

bool ACityMapGenerator::bTriggerRoadMapGeneration = false
private

Trigger the generation a the road map image of the current layout (used for off-road and opposite lane invasion detection).

Definition at line 130 of file CityMapGenerator.h.

Referenced by UpdateMap().

◆ bUseFixedSeed

bool ACityMapGenerator::bUseFixedSeed = true
private

If false, a random seed is generated each time.

Definition at line 113 of file CityMapGenerator.h.

Referenced by UpdateSeeds().

◆ Dcel

TUniquePtr<MapGen::DoublyConnectedEdgeList> ACityMapGenerator::Dcel
private

Definition at line 179 of file CityMapGenerator.h.

Referenced by GenerateGraph(), and GenerateRoads().

◆ DcelParser

TUniquePtr<MapGen::GraphParser> ACityMapGenerator::DcelParser
private

Definition at line 181 of file CityMapGenerator.h.

Referenced by GenerateGraph().

◆ MapSizeX

uint32 ACityMapGenerator::MapSizeX = 20u
private

Size X of the map in map units.

The map unit is calculated based in the tile mesh of the road (see Map Scale).

Definition at line 97 of file CityMapGenerator.h.

Referenced by GenerateGraph(), and GenerateRoadMap().

◆ MapSizeY

uint32 ACityMapGenerator::MapSizeY = 20u
private

Size Y of the map in map units.

The map unit is calculated based in the tile mesh of the road (see Map Scale).

Definition at line 103 of file CityMapGenerator.h.

Referenced by GenerateGraph(), and GenerateRoadMap().

◆ PixelsPerMapUnit

uint32 ACityMapGenerator::PixelsPerMapUnit = 50u
private

The resolution in pixels per map unit of the road map.

The map unit is calculated based in the tile mesh of the road (see Map Scale).

Definition at line 136 of file CityMapGenerator.h.

Referenced by GenerateRoadMap().

◆ RoadMap

URoadMap* ACityMapGenerator::RoadMap
private

Definition at line 170 of file CityMapGenerator.h.

Referenced by ACityMapGenerator(), GenerateRoadMap(), and PreSave().

◆ Seed

int32 ACityMapGenerator::Seed = 123456789
private

Seed of the random map generated.

Definition at line 117 of file CityMapGenerator.h.

Referenced by GenerateGraph(), and UpdateSeeds().


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