Improved OpenDriveActor

- Now it keeps track of signs and lights
- Now it despawns signs and lights on "Remove Route"
This commit is contained in:
Daniel 2019-02-25 11:00:46 +01:00
parent e7a5f870f3
commit c004432c39
3 changed files with 2922 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -308,6 +308,7 @@ void AOpenDriveActor::BuildRoutes(FString MapName)
FString AddTrafficLightCommand = FString::Printf(TEXT("AddTrafficLightPole %s"),
*SpawnedTrafficLight->GetName());
SpawnedTrafficGroup->CallFunctionByNameWithArguments(*AddTrafficLightCommand, ar, NULL, true);
PersistentTrafficLights.Push(SpawnedTrafficGroup);
SpawnedTrafficLight->CallFunctionByNameWithArguments(TEXT("InitData"), ar, NULL, true);
for (TrafficBoxComponent TfBoxComponent : CurrentTrafficLight.box_areas)
{
@ -326,6 +327,7 @@ void AOpenDriveActor::BuildRoutes(FString MapName)
TLBoxRot.Roll,
TLBoxRot.Yaw);
SpawnedTrafficLight->CallFunctionByNameWithArguments(*BoxCommand, ar, NULL, true);
PersistentTrafficLights.Push(SpawnedTrafficLight);
}
}
}
@ -371,6 +373,7 @@ void AOpenDriveActor::BuildRoutes(FString MapName)
SpawnParams);
break;
}
PersistentTrafficSigns.Push(SignActor);
for (TrafficBoxComponent TfBoxComponent : CurrentTrafficSign.box_areas)
{
FVector TLBoxPos = FVector(TfBoxComponent.x_pos,
@ -403,6 +406,22 @@ void AOpenDriveActor::RemoveRoutes()
}
}
RoutePlanners.Empty();
const int tl_num = PersistentTrafficLights.Num();
for (int i = 0; i < tl_num; i++)
{
if(PersistentTrafficLights[i] != nullptr) {
PersistentTrafficLights[i]->Destroy();
}
}
PersistentTrafficLights.Empty();
const int ts_num = PersistentTrafficSigns.Num();
for (int i = 0; i < ts_num; i++)
{
if(PersistentTrafficSigns[i] != nullptr) {
PersistentTrafficSigns[i]->Destroy();
}
}
PersistentTrafficSigns.Empty();
}
void AOpenDriveActor::DebugRoutes() const

View File

@ -45,6 +45,12 @@ private:
UPROPERTY()
TArray<AVehicleSpawnPoint *> VehicleSpawners;
UPROPERTY()
TArray<AActor *> PersistentTrafficLights;
UPROPERTY()
TArray<AActor *> PersistentTrafficSigns;
UPROPERTY()
TSubclassOf<class AActor> TrafficLightBlueprintClass;