18#include "Engine/Classes/Interfaces/Interface_CollisionDataProvider.h"
19#include "PhysicsCore/Public/BodySetupEnums.h"
23 PrimaryActorTick.bCanEverTick =
false;
24 MeshComponent = CreateDefaultSubobject<UProceduralMeshComponent>(TEXT(
"RootComponent"));
29 : Super(ObjectInitializer)
31 PrimaryActorTick.bCanEverTick =
false;
32 RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT(
"SceneComponent"));
33 SetRootComponent(RootComponent);
34 RootComponent->Mobility = EComponentMobility::Static;
41 if (OpenDrive.IsEmpty())
43 UE_LOG(LogCarla, Error, TEXT(
"The OpenDrive is empty"));
65 UE_LOG(LogCarla, Error, TEXT(
"The OpenDrive has not been loaded"));
81 const auto Meshes = CarlaMap->GenerateChunkedMesh(Parameters);
82 for (
const auto &Mesh : Meshes) {
83 if (!Mesh->GetVertices().size())
89 TempPMC->bUseAsyncCooking =
true;
90 TempPMC->bUseComplexAsSimpleCollision =
true;
91 TempPMC->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
94 TempPMC->CreateMeshSection_LinearColor(
100 TArray<FLinearColor>(),
101 TArray<FProcMeshTangent>(),
111 actor->SetActorHiddenInGame(
true);
136 UE_LOG(LogCarla, Error, TEXT(
"The OpenDrive has not been loaded"));
146 UE_LOG(LogCarla, Error, TEXT(
"The OpenDrive has not been loaded"));
150 const auto Waypoints = CarlaMap->GenerateWaypointsOnRoadEntries();
151 for (
const auto &Wp : Waypoints)
153 const FTransform Trans = CarlaMap->ComputeTransform(Wp);
155 Spawner->SetActorRotation(Trans.GetRotation());
156 Spawner->SetActorLocation(Trans.GetTranslation() + FVector(0.f, 0.f,
SpawnersHeight));
177 auto World = GetWorld();
178 check(World !=
nullptr);
181 AActor* TrafficLightManagerActor = UGameplayStatics::GetActorOfClass(World, ATrafficLightManager::StaticClass());
182 if(TrafficLightManagerActor ==
nullptr) {
const boost::optional< carla::road::Map > & GetMap() const
bool LoadOpenDrive(const FString &OpenDrive)
Set the OpenDRIVE information as string and generates the queryable map structure.
TArray< AVehicleSpawnPoint * > VehicleSpawners
const FString & GetOpenDrive() const
Get the OpenDRIVE information as string.
AOpenDriveGenerator(const FObjectInitializer &ObjectInitializer)
void GeneratePoles()
Generates pole meshes based on the OpenDRIVE information.
void GenerateRoadMesh()
Generates the road and sidewalk mesh based on the OpenDRIVE information.
virtual void BeginPlay() override
TArray< AActor * > ActorMeshList
float SpawnersHeight
Determine the height where the spawners will be placed, relative to each RoutePlanner
void GenerateSpawnPoints()
Generates spawn points along the road.
bool IsOpenDriveValid() const
Checks if the OpenDrive has been loaded and it's valid.
UProceduralMeshComponent * MeshComponent
Class In charge of creating and assigning traffic light groups, controllers and components.
Base class for spawner locations for walkers.
The game instance contains elements that must be kept alive in between levels.
const carla::rpc::OpendriveGenerationParameters & GetOpendriveGenerationParameters() const
static UCarlaGameInstance * GetGameInstance(const UObject *WorldContextObject)
static ACarlaGameModeBase * GetGameMode(const UObject *WorldContextObject)
static FString GetXODR(const UWorld *World)
Return the OpenDrive XML associated to MapName, or empty if the file is not found.
static void log_warning(Args &&... args)
A definition of a Carla Mesh.
TArray< int32 > Triangles
TArray< FVector > Vertices
TArray< FVector > Normals
Seting for map generation from opendrive without additional geometry
bool enable_mesh_visibility