CARLA
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:
+ Collaboration diagram for ACityMapMeshHolder:

Public Member Functions

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

Protected Member Functions

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...
 

Private Member Functions

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

Private Attributes

float MapScale = 1.0f
 
USceneComponent * SceneRootComponent
 
TMap< ECityMapMeshTag, UStaticMesh * > StaticMeshes
 
TMap< UStaticMesh *, ECityMapMeshTagTagMap
 

Detailed Description

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

Definition at line 20 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 26 of file CityMapMeshHolder.cpp.

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

+ Here is the call graph for this function:

Member Function Documentation

◆ AddInstance() [1/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 120 of file CityMapMeshHolder.cpp.

References GetTileLocation().

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

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

◆ AddInstance() [2/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 125 of file CityMapMeshHolder.cpp.

References AddInstance(), and GetTileLocation().

+ Here is the call graph for this function:

◆ AddInstance() [3/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 132 of file CityMapMeshHolder.cpp.

References UCarlaSettings::CARLA_ROAD_TAG, and GetStaticMesh().

+ Here is the call graph for this function:

◆ DeletePieces()

void ACityMapMeshHolder::DeletePieces ( )
private

Clear all instances of the static mesh actors.

Definition at line 154 of file CityMapMeshHolder.cpp.

References UCarlaSettings::CARLA_ROAD_TAG.

Referenced by PostInitializeComponents().

+ Here is the caller graph for this function:

◆ GetMapScale()

float ACityMapMeshHolder::GetMapScale ( ) const
inlineprotected

Definition at line 49 of file CityMapMeshHolder.h.

Referenced by ACityMapGenerator::GenerateRoadMap().

+ Here is the caller graph for this function:

◆ GetStaticMesh() [1/2]

UStaticMesh * ACityMapMeshHolder::GetStaticMesh ( ECityMapMeshTag  Tag)
protected

Return the static mesh corresponding to Tag.

Definition at line 104 of file CityMapMeshHolder.cpp.

References StaticMeshes.

Referenced by AddInstance(), and UpdateMapScale().

+ Here is the caller graph for this function:

◆ GetStaticMesh() [2/2]

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

Return the static mesh corresponding to Tag.

Definition at line 109 of file CityMapMeshHolder.cpp.

References StaticMeshes.

◆ GetTag()

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

Return the tag corresponding to StaticMesh.

Definition at line 114 of file CityMapMeshHolder.cpp.

References TagMap.

Referenced by ACityMapGenerator::GenerateRoadMap().

+ Here is the caller graph for this function:

◆ 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 91 of file CityMapMeshHolder.cpp.

References MapScale.

Referenced by AddInstance().

+ Here is the caller graph for this function:

◆ OnConstruction()

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

Initializes the instantiators.

Definition at line 50 of file CityMapMeshHolder.cpp.

◆ PostInitializeComponents()

void ACityMapMeshHolder::PostInitializeComponents ( )
overrideprotectedvirtual

Definition at line 56 of file CityMapMeshHolder.cpp.

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

+ Here is the call graph for this function:

◆ SetStaticMesh()

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

Set the static mesh associated with Tag.

Definition at line 96 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 152 of file CityMapMeshHolder.cpp.

Referenced by PostInitializeComponents().

+ Here is the caller graph for this function:

◆ UpdateMapScale()

void ACityMapMeshHolder::UpdateMapScale ( )
private

Set the scale to the dimensions of the base mesh.

Definition at line 177 of file CityMapMeshHolder.cpp.

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

Referenced by PostInitializeComponents().

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

Member Data Documentation

◆ MapScale

float ACityMapMeshHolder::MapScale = 1.0f
private

Definition at line 110 of file CityMapMeshHolder.h.

Referenced by GetTileLocation(), and UpdateMapScale().

◆ SceneRootComponent

USceneComponent* ACityMapMeshHolder::SceneRootComponent
private

Definition at line 107 of file CityMapMeshHolder.h.

Referenced by ACityMapMeshHolder().

◆ StaticMeshes

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

Definition at line 113 of file CityMapMeshHolder.h.

Referenced by ACityMapMeshHolder(), GetStaticMesh(), and SetStaticMesh().

◆ TagMap

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

Definition at line 116 of file CityMapMeshHolder.h.

Referenced by GetTag(), and SetStaticMesh().


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