CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
CityMapGenerator.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#pragma once
8
9
#include "
MapGen/CityMapMeshHolder.h
"
10
#include "
MapGen/DoublyConnectedEdgeList.h
"
11
#include "
MapGen/GraphParser.h
"
12
13
#include <util/ue-header-guard-begin.h>
14
#include "UObject/ObjectSaveContext.h"
15
#include <util/ue-header-guard-end.h>
16
17
#include "CityMapGenerator.generated.h"
18
19
class
URoadMap
;
20
21
/// Generates a random city using the meshes provided.
22
///
23
/// @note At this point it only generates roads and sidewalks.
24
UCLASS(HideCategories=(Input,Rendering,Actor))
25
class CARLA_API
ACityMapGenerator
: public
ACityMapMeshHolder
26
{
27
GENERATED_BODY()
28
29
// ===========================================================================
30
/// @name Constructor and destructor
31
// ===========================================================================
32
/// @{
33
public
:
34
35
ACityMapGenerator
(
const
FObjectInitializer& ObjectInitializer);
36
37
~ACityMapGenerator
();
38
39
/// @}
40
// ===========================================================================
41
/// @name Overriden from UObject
42
// ===========================================================================
43
/// @{
44
public
:
45
46
virtual
void
PreSave
(FObjectPreSaveContext ObjectSaveContext)
override
;
47
48
/// @}
49
// ===========================================================================
50
/// @name Overriden from ACityMapMeshHolder
51
// ===========================================================================
52
/// @{
53
private
:
54
55
virtual
void
UpdateMap
()
override
;
56
57
/// @}
58
// ===========================================================================
59
/// @name Road map
60
// ===========================================================================
61
/// @{
62
public
:
63
64
UFUNCTION(BlueprintCallable)
65
URoadMap
*
GetRoadMap
()
66
{
67
return
RoadMap
;
68
}
69
70
/// @}
71
// ===========================================================================
72
/// @name Map construction and update related methods
73
// ===========================================================================
74
/// @{
75
private
:
76
77
/// Update the random seeds. Generate random if no fixed seed is used.
78
void
UpdateSeeds();
79
80
/// Regenerate the DCEL.
81
void
GenerateGraph();
82
83
/// Add the road meshes to the scene based on the current DCEL.
84
void
GenerateRoads();
85
86
/// Generate the road map image and save to disk if requested.
87
void
GenerateRoadMap();
88
89
/// @}
90
// ===========================================================================
91
/// @name Map generation properties
92
// ===========================================================================
93
/// @{
94
private
:
95
96
/** Size X of the map in map units. The map unit is calculated based in the
97
* tile mesh of the road (see Map Scale).
98
*/
99
UPROPERTY(Category =
"Map Generation"
, EditAnywhere, meta = (ClampMin =
"10"
, ClampMax =
"200"
))
100
uint32
MapSizeX
= 20u;
101
102
/** Size Y of the map in map units. The map unit is calculated based in the
103
* tile mesh of the road (see Map Scale).
104
*/
105
UPROPERTY(Category =
"Map Generation"
, EditAnywhere, meta = (ClampMin =
"10"
, ClampMax =
"200"
))
106
uint32
MapSizeY
= 20u;
107
108
/** If false, no mesh is added, only the internal representation of road is
109
* generated.
110
*/
111
UPROPERTY(Category =
"Map Generation"
, EditAnywhere)
112
bool
bGenerateRoads
= true;
113
114
/** If false, a random seed is generated each time. */
115
UPROPERTY(Category =
"Map Generation"
, EditAnywhere)
116
bool
bUseFixedSeed
= true;
117
118
/** Seed of the random map generated. */
119
UPROPERTY(Category =
"Map Generation"
, EditAnywhere, meta = (EditCondition =
bUseFixedSeed
))
120
int32
Seed
= 123456789;
121
122
/// @}
123
// ===========================================================================
124
/// @name Road Map
125
// ===========================================================================
126
/// @{
127
private:
128
129
/** Trigger the generation a the road map image of the current layout (used
130
* for off-road and opposite lane invasion detection).
131
*/
132
UPROPERTY(Category =
"Road Map"
, EditAnywhere)
133
bool
bTriggerRoadMapGeneration
= false;
134
135
/** The resolution in pixels per map unit of the road map. The map unit is
136
* calculated based in the tile mesh of the road (see Map Scale).
137
*/
138
UPROPERTY(Category =
"Road Map"
, EditAnywhere, meta = (ClampMin =
"1"
, ClampMax =
"500"
))
139
uint32
PixelsPerMapUnit
= 50u;
140
141
/** Whether the road map should be generated based on left-hand traffic. */
142
UPROPERTY(Category =
"Road Map"
, EditAnywhere)
143
bool
bLeftHandTraffic
= false;
144
145
/** If true, the road map encoded as an image is saved to disk. The image is
146
* saved to the "Saved" folder of the project.
147
*/
148
UPROPERTY(Category =
"Road Map"
, EditAnywhere)
149
bool
bSaveRoadMapToDisk
= true;
150
151
/** If true, a debug point is drawn in the level for each pixel of the road
152
* map.
153
*/
154
UPROPERTY(Category =
"Road Map"
, EditAnywhere)
155
bool
bDrawDebugPixelsToLevel
= false;
156
157
/** The road map is re-computed on save so we always store an up-to-date
158
* version. Uncheck this only for testing purposes as the road map might get
159
* out-of-sync with the current road layout.
160
*/
161
UPROPERTY(Category =
"Road Map"
, EditAnywhere, AdvancedDisplay)
162
bool
bGenerateRoadMapOnSave
= true;
163
164
/** If true, activate the custom depth pass of each tagged actor in the level.
165
* This pass is necessary for rendering the semantic segmentation. However,
166
* it may add a performance penalty since occlusion doesn't seem to be
167
* applied to objects having this value active.
168
*/
169
UPROPERTY(Category =
"Road Map"
, EditAnywhere, AdvancedDisplay)
170
bool
bTagForSemanticSegmentation
= false;
171
172
UPROPERTY()
173
URoadMap
*
RoadMap
;
174
175
/// @}
176
// ===========================================================================
177
/// @name Other private members
178
// ===========================================================================
179
/// @{
180
private:
181
182
TUniquePtr<
MapGen
::DoublyConnectedEdgeList>
Dcel
;
183
184
TUniquePtr<
MapGen
::GraphParser>
DcelParser
;
185
/// @}
186
};
CityMapMeshHolder.h
DoublyConnectedEdgeList.h
GraphParser.h
ACityMapGenerator::bGenerateRoadMapOnSave
bool bGenerateRoadMapOnSave
The road map is re-computed on save so we always store an up-to-date version.
Definition
CityMapGenerator.h:162
ACityMapGenerator::RoadMap
URoadMap * RoadMap
Definition
CityMapGenerator.h:173
ACityMapGenerator::bGenerateRoads
bool bGenerateRoads
If false, no mesh is added, only the internal representation of road is generated.
Definition
CityMapGenerator.h:112
ACityMapGenerator::MapSizeY
uint32 MapSizeY
Size Y of the map in map units.
Definition
CityMapGenerator.h:106
ACityMapGenerator::Seed
int32 Seed
Seed of the random map generated.
Definition
CityMapGenerator.h:120
ACityMapGenerator::PixelsPerMapUnit
uint32 PixelsPerMapUnit
The resolution in pixels per map unit of the road map.
Definition
CityMapGenerator.h:139
ACityMapGenerator::UpdateMap
virtual void UpdateMap() override
Here does nothing, implement in derived classes.
Definition
CityMapGenerator.cpp:84
ACityMapGenerator::Dcel
TUniquePtr< MapGen::DoublyConnectedEdgeList > Dcel
Definition
CityMapGenerator.h:182
ACityMapGenerator::bDrawDebugPixelsToLevel
bool bDrawDebugPixelsToLevel
If true, a debug point is drawn in the level for each pixel of the road map.
Definition
CityMapGenerator.h:155
ACityMapGenerator::bLeftHandTraffic
bool bLeftHandTraffic
Whether the road map should be generated based on left-hand traffic.
Definition
CityMapGenerator.h:143
ACityMapGenerator::bUseFixedSeed
bool bUseFixedSeed
If false, a random seed is generated each time.
Definition
CityMapGenerator.h:116
ACityMapGenerator::bTriggerRoadMapGeneration
bool bTriggerRoadMapGeneration
Trigger the generation a the road map image of the current layout (used for off-road and opposite lan...
Definition
CityMapGenerator.h:133
ACityMapGenerator::ACityMapGenerator
ACityMapGenerator(const FObjectInitializer &ObjectInitializer)
Definition
CityMapGenerator.cpp:52
ACityMapGenerator::GetRoadMap
URoadMap * GetRoadMap()
Definition
CityMapGenerator.h:65
ACityMapGenerator::DcelParser
TUniquePtr< MapGen::GraphParser > DcelParser
Definition
CityMapGenerator.h:184
ACityMapGenerator::PreSave
virtual void PreSave(FObjectPreSaveContext ObjectSaveContext) override
Definition
CityMapGenerator.cpp:64
ACityMapGenerator::MapSizeX
uint32 MapSizeX
Size X of the map in map units.
Definition
CityMapGenerator.h:100
ACityMapGenerator::bSaveRoadMapToDisk
bool bSaveRoadMapToDisk
If true, the road map encoded as an image is saved to disk.
Definition
CityMapGenerator.h:149
ACityMapGenerator::bTagForSemanticSegmentation
bool bTagForSemanticSegmentation
If true, activate the custom depth pass of each tagged actor in the level.
Definition
CityMapGenerator.h:170
ACityMapMeshHolder::ACityMapMeshHolder
ACityMapMeshHolder(const FObjectInitializer &ObjectInitializer)
Initializes the mesh holders.
Definition
CityMapMeshHolder.cpp:31
URoadMap
Road map of the level.
Definition
RoadMap.h:95
MapGen
Definition
CityAreaDescription.h:13
Generated by
1.18.0