CARLA
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ACityMapMeshHolder Class Reference

Holds the static meshes and instances necessary for building a city map. More...

#include <CityMapMeshHolder.h>

+ Inheritance diagram for ACityMapMeshHolder:

Public Member Functions

 ACityMapMeshHolder (const FObjectInitializer &ObjectInitializer)
 Initializes the mesh holders.
 

Protected Member Functions

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.
 

Private Member Functions

void DeletePieces ()
 Clear all instances of the static mesh actors.
 
virtual void UpdateMap ()
 Here does nothing, implement in derived classes.
 
void UpdateMapScale ()
 Set the scale to the dimensions of the base mesh.
 

Private Attributes

float MapScale = 1.0f
 
TObjectPtr< USceneComponent > SceneRootComponent
 
TMap< ECityMapMeshTag, TObjectPtr< UStaticMesh > > StaticMeshes
 
TMap< TObjectPtr< UStaticMesh >, ECityMapMeshTag > TagMap
 

Detailed Description

Holds the static meshes and instances necessary for building a city map.

Definition at line 24 of file CityMapMeshHolder.h.

Constructor & Destructor Documentation

◆ ACityMapMeshHolder()

ACityMapMeshHolder::ACityMapMeshHolder ( const FObjectInitializer &  ObjectInitializer)

Initializes the mesh holders.

It is safe to call SetStaticMesh after this. However, instances cannot be added until OnConstruction is called.

Definition at line 31 of file CityMapMeshHolder.cpp.

References CityMapMeshTag::FromUInt(), NUMBER_OF_TAGS, SceneRootComponent, and StaticMeshes.

Member Function Documentation

◆ AddInstance() [1/3]

void ACityMapMeshHolder::AddInstance ( ECityMapMeshTag  Tag,
FTransform  Transform 
)
protected

Add an instance of a mesh with a given transform.

Parameters
TagThe mesh' tag
TransformTransform that will be applied to the mesh

Definition at line 137 of file CityMapMeshHolder.cpp.

References UCarlaSettings::CARLA_ROAD_TAG, and GetStaticMesh().

◆ AddInstance() [2/3]

void ACityMapMeshHolder::AddInstance ( ECityMapMeshTag  Tag,
uint32  X,
uint32  Y 
)
protected

Add an instance of a mesh with a given tile location.

Parameters
TagThe mesh' tag
XTile coordinate X
YTile coordinate Y

Definition at line 125 of file CityMapMeshHolder.cpp.

References AddInstance(), and GetTileLocation().

Referenced by AddInstance(), AddInstance(), and ACityMapGenerator::GenerateRoads().

◆ AddInstance() [3/3]

void ACityMapMeshHolder::AddInstance ( ECityMapMeshTag  Tag,
uint32  X,
uint32  Y,
float  Angle 
)
protected

Add an instance of a mesh with a given tile location and rotation.

Parameters
TagThe mesh' tag
XTile coordinate X
YTile coordinate Y
AngleRotation around Z axis

Definition at line 130 of file CityMapMeshHolder.cpp.

References AddInstance(), and GetTileLocation().

◆ DeletePieces()

void ACityMapMeshHolder::DeletePieces ( )
private

Clear all instances of the static mesh actors.

Definition at line 159 of file CityMapMeshHolder.cpp.

References UCarlaSettings::CARLA_ROAD_TAG.

◆ GetMapScale()

float ACityMapMeshHolder::GetMapScale ( ) const
inlineprotected

Definition at line 53 of file CityMapMeshHolder.h.

Referenced by ACityMapGenerator::GenerateRoadMap().

◆ GetStaticMesh() [1/2]

UStaticMesh * ACityMapMeshHolder::GetStaticMesh ( ECityMapMeshTag  Tag)
protected

Return the static mesh corresponding to Tag.

Definition at line 109 of file CityMapMeshHolder.cpp.

References StaticMeshes.

Referenced by AddInstance(), and UpdateMapScale().

◆ GetStaticMesh() [2/2]

const UStaticMesh * ACityMapMeshHolder::GetStaticMesh ( ECityMapMeshTag  Tag) const
protected

Return the static mesh corresponding to Tag.

Definition at line 114 of file CityMapMeshHolder.cpp.

References StaticMeshes.

◆ GetTag()

ECityMapMeshTag ACityMapMeshHolder::GetTag ( const UStaticMesh &  StaticMesh) const
protected

Return the tag corresponding to StaticMesh.

Definition at line 119 of file CityMapMeshHolder.cpp.

References TagMap.

Referenced by ACityMapGenerator::GenerateRoadMap().

◆ GetTileLocation()

FVector ACityMapMeshHolder::GetTileLocation ( uint32  X,
uint32  Y 
) const
protected

Return the 3D world location (relative to this actor) of the given 2D tile.

Definition at line 96 of file CityMapMeshHolder.cpp.

References MapScale.

Referenced by AddInstance(), and AddInstance().

◆ OnConstruction()

void ACityMapMeshHolder::OnConstruction ( const FTransform &  Transform)
overrideprotectedvirtual

Initializes the instantiators.

Definition at line 55 of file CityMapMeshHolder.cpp.

◆ PostInitializeComponents()

void ACityMapMeshHolder::PostInitializeComponents ( )
overrideprotectedvirtual

Definition at line 61 of file CityMapMeshHolder.cpp.

References IsValid(), UpdateMap(), and UpdateMapScale().

◆ SetStaticMesh()

void ACityMapMeshHolder::SetStaticMesh ( ECityMapMeshTag  Tag,
UStaticMesh *  Mesh 
)
protected

Set the static mesh associated with Tag.

Definition at line 101 of file CityMapMeshHolder.cpp.

References StaticMeshes, and TagMap.

◆ UpdateMap()

void ACityMapMeshHolder::UpdateMap ( )
privatevirtual

Here does nothing, implement in derived classes.

Reimplemented in ACityMapGenerator.

Definition at line 157 of file CityMapMeshHolder.cpp.

Referenced by PostInitializeComponents().

◆ UpdateMapScale()

void ACityMapMeshHolder::UpdateMapScale ( )
private

Set the scale to the dimensions of the base mesh.

Definition at line 182 of file CityMapMeshHolder.cpp.

References CityMapMeshTag::GetBaseMeshTag(), GetStaticMesh(), MapScale, and CityMapMeshTag::ToString().

Referenced by PostInitializeComponents().

Member Data Documentation

◆ MapScale

float ACityMapMeshHolder::MapScale = 1.0f
private

Definition at line 114 of file CityMapMeshHolder.h.

Referenced by GetTileLocation(), and UpdateMapScale().

◆ SceneRootComponent

TObjectPtr<USceneComponent> ACityMapMeshHolder::SceneRootComponent
private

Definition at line 111 of file CityMapMeshHolder.h.

Referenced by ACityMapMeshHolder().

◆ StaticMeshes

TMap<ECityMapMeshTag, TObjectPtr<UStaticMesh> > ACityMapMeshHolder::StaticMeshes
private

◆ TagMap

TMap<TObjectPtr<UStaticMesh>, ECityMapMeshTag> ACityMapMeshHolder::TagMap
private

Definition at line 120 of file CityMapMeshHolder.h.

Referenced by GetTag(), and SetStaticMesh().


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