CARLA
Loading...
Searching...
No Matches
List of all members
ACityMapGenerator Class Reference

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

#include <CityMapGenerator.h>

+ Inheritance diagram for ACityMapGenerator:

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

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).
 
uint32 PixelsPerMapUnit = 50u
 The resolution in pixels per map unit of the road map.
 
bool bLeftHandTraffic = false
 Whether the road map should be generated based on left-hand traffic.
 
bool bSaveRoadMapToDisk = true
 If true, the road map encoded as an image is saved to disk.
 
bool bDrawDebugPixelsToLevel = false
 If true, a debug point is drawn in the level for each pixel of the road map.
 
bool bGenerateRoadMapOnSave = true
 The road map is re-computed on save so we always store an up-to-date version.
 
bool bTagForSemanticSegmentation = false
 If true, activate the custom depth pass of each tagged actor in the level.
 
URoadMap * RoadMap
 
URoadMap * GetRoadMap ()
 

Additional Inherited Members

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

Detailed Description

Generates a random city using the meshes provided.

Note
At this point it only generates roads and sidewalks.

Definition at line 25 of file CityMapGenerator.h.

Constructor & Destructor Documentation

◆ ACityMapGenerator()

ACityMapGenerator::ACityMapGenerator ( const FObjectInitializer &  ObjectInitializer)

Definition at line 52 of file CityMapGenerator.cpp.

References RoadMap.

◆ ~ACityMapGenerator()

ACityMapGenerator::~ACityMapGenerator ( )

Definition at line 58 of file CityMapGenerator.cpp.

Member Function Documentation

◆ GenerateGraph()

void ACityMapGenerator::GenerateGraph ( )
private

Regenerate the DCEL.

Definition at line 110 of file CityMapGenerator.cpp.

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

Referenced by UpdateMap().

◆ GenerateRoadMap()

void ACityMapGenerator::GenerateRoadMap ( )
private

◆ GenerateRoads()

void ACityMapGenerator::GenerateRoads ( )
private

◆ GetRoadMap()

URoadMap * ACityMapGenerator::GetRoadMap ( )
inline

Definition at line 65 of file CityMapGenerator.h.

◆ PreSave()

void ACityMapGenerator::PreSave ( FObjectPreSaveContext  ObjectSaveContext)
overridevirtual

Definition at line 64 of file CityMapGenerator.cpp.

References bGenerateRoadMapOnSave, GenerateRoadMap(), and RoadMap.

◆ UpdateMap()

void ACityMapGenerator::UpdateMap ( )
overrideprivatevirtual

Here does nothing, implement in derived classes.

Reimplemented from ACityMapMeshHolder.

Definition at line 84 of file CityMapGenerator.cpp.

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

◆ UpdateSeeds()

void ACityMapGenerator::UpdateSeeds ( )
private

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

Definition at line 101 of file CityMapGenerator.cpp.

References bUseFixedSeed, and Seed.

Referenced by UpdateMap().

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 155 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 162 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 112 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 143 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 149 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 170 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 133 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 116 of file CityMapGenerator.h.

Referenced by UpdateSeeds().

◆ Dcel

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

Definition at line 182 of file CityMapGenerator.h.

Referenced by GenerateGraph(), and GenerateRoads().

◆ DcelParser

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

Definition at line 184 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 100 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 106 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 139 of file CityMapGenerator.h.

Referenced by GenerateRoadMap().

◆ RoadMap

URoadMap* ACityMapGenerator::RoadMap
private

Definition at line 173 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 120 of file CityMapGenerator.h.

Referenced by GenerateGraph(), and UpdateSeeds().


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