CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
MapGen
CityMapMeshHolder.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 "
CityMapMeshTag.h
"
10
11
#include <util/ue-header-guard-begin.h>
12
#include "GameFramework/Actor.h"
13
#include <util/ue-header-guard-end.h>
14
15
#include "CityMapMeshHolder.generated.h"
16
17
class
IDetailLayoutBuilder;
18
class
UInstancedStaticMeshComponent;
19
class
AStaticMeshActor;
20
21
22
/// Holds the static meshes and instances necessary for building a city map.
23
UCLASS(Abstract)
24
class CARLA_API
ACityMapMeshHolder
: public
AActor
25
{
26
GENERATED_BODY()
27
28
// ===========================================================================
29
// -- Construction and update related methods --------------------------------
30
// ===========================================================================
31
public
:
32
33
/// Initializes the mesh holders. It is safe to call SetStaticMesh after this.
34
/// However, instances cannot be added until OnConstruction is called.
35
ACityMapMeshHolder
(
const
FObjectInitializer& ObjectInitializer);
36
//void LayoutDetails( IDetailLayoutBuilder& DetailLayout );
37
protected
:
38
39
/// Initializes the instantiators.
40
virtual
void
OnConstruction
(
const
FTransform &
Transform
)
override
;
41
virtual
void
PostInitializeComponents
()
override
;
42
43
#if WITH_EDITOR
44
/// Clears and updates the instantiators.
45
virtual
void
PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
override
;
46
#endif
// WITH_EDITOR
47
48
// ===========================================================================
49
// -- Other protected methods ------------------------------------------------
50
// ===========================================================================
51
protected
:
52
53
float
GetMapScale
()
const
54
{
55
56
return
MapScale
;
57
}
58
59
/// Return the 3D world location (relative to this actor) of the given 2D
60
/// tile.
61
FVector GetTileLocation(uint32 X, uint32 Y)
const
;
62
63
/// Set the static mesh associated with @a Tag.
64
void
SetStaticMesh(
ECityMapMeshTag
Tag, UStaticMesh *Mesh);
65
66
/// Return the static mesh corresponding to @a Tag.
67
UStaticMesh *GetStaticMesh(
ECityMapMeshTag
Tag);
68
69
/// Return the static mesh corresponding to @a Tag.
70
const
UStaticMesh *GetStaticMesh(
ECityMapMeshTag
Tag)
const
;
71
72
/// Return the tag corresponding to @a StaticMesh.
73
ECityMapMeshTag
GetTag(
const
UStaticMesh &StaticMesh)
const
;
74
75
/// Add an instance of a mesh with a given tile location.
76
/// @param Tag The mesh' tag
77
/// @param X Tile coordinate X
78
/// @param Y Tile coordinate Y
79
void
AddInstance(
ECityMapMeshTag
Tag, uint32 X, uint32 Y);
80
81
/// Add an instance of a mesh with a given tile location and rotation.
82
/// @param Tag The mesh' tag
83
/// @param X Tile coordinate X
84
/// @param Y Tile coordinate Y
85
/// @param Angle Rotation around Z axis
86
void
AddInstance(
ECityMapMeshTag
Tag, uint32 X, uint32 Y,
float
Angle);
87
88
/// Add an instance of a mesh with a given transform.
89
/// @param Tag The mesh' tag
90
/// @param Transform Transform that will be applied to the mesh
91
void
AddInstance(
ECityMapMeshTag
Tag, FTransform
Transform
);
92
93
// ===========================================================================
94
// -- Private methods and members --------------------------------------------
95
// ===========================================================================
96
private
:
97
98
/// Here does nothing, implement in derived classes.
99
virtual
void
UpdateMap();
100
101
/// Clear all instances of the static mesh actors.
102
void
DeletePieces();
103
104
/// Set the scale to the dimensions of the base mesh.
105
void
UpdateMapScale();
106
107
private
:
108
109
110
UPROPERTY()
111
TObjectPtr<USceneComponent>
SceneRootComponent
;
112
113
UPROPERTY(Category =
"Map Generation"
, VisibleAnywhere)
114
float
MapScale
= 1.0f;
115
116
UPROPERTY(Category =
"Meshes"
, EditAnywhere)
117
TMap<
ECityMapMeshTag
, TObjectPtr<UStaticMesh>>
StaticMeshes
;
118
119
UPROPERTY()
120
TMap<TObjectPtr<UStaticMesh>,
ECityMapMeshTag
>
TagMap
;
121
122
123
};
CityMapMeshTag.h
ECityMapMeshTag
ECityMapMeshTag
Tag to identify the meshes used by the ProceduralMapGenerator.
Definition
CityMapMeshTag.h:19
AActor
ACityMapMeshHolder::PostInitializeComponents
virtual void PostInitializeComponents() override
Definition
CityMapMeshHolder.cpp:61
ACityMapMeshHolder::TagMap
TMap< TObjectPtr< UStaticMesh >, ECityMapMeshTag > TagMap
Definition
CityMapMeshHolder.h:120
ACityMapMeshHolder::SceneRootComponent
TObjectPtr< USceneComponent > SceneRootComponent
Definition
CityMapMeshHolder.h:111
ACityMapMeshHolder::GetMapScale
float GetMapScale() const
Definition
CityMapMeshHolder.h:53
ACityMapMeshHolder::StaticMeshes
TMap< ECityMapMeshTag, TObjectPtr< UStaticMesh > > StaticMeshes
Definition
CityMapMeshHolder.h:117
ACityMapMeshHolder::ACityMapMeshHolder
ACityMapMeshHolder(const FObjectInitializer &ObjectInitializer)
Initializes the mesh holders.
Definition
CityMapMeshHolder.cpp:31
ACityMapMeshHolder::OnConstruction
virtual void OnConstruction(const FTransform &Transform) override
Initializes the instantiators.
Definition
CityMapMeshHolder.cpp:55
ACityMapMeshHolder::MapScale
float MapScale
Definition
CityMapMeshHolder.h:114
Transform
A rigid transform in CARLA's / Unreal's left-handed frame: x forward, y right, z up,...
Definition
geom/Transform.h:32
Generated by
1.18.0