Minor fixes to non-rendering mode

This commit is contained in:
nsubiron 2018-08-24 16:14:55 +02:00
parent 662fc32c8b
commit a1684ad0ae
4 changed files with 79 additions and 46 deletions

View File

@ -24,9 +24,9 @@ SynchronousMode=true
; vehicles, pedestrians and traffic signs. Disabled by default to improve ; vehicles, pedestrians and traffic signs. Disabled by default to improve
; performance. ; performance.
SendNonPlayerAgentsInfo=false SendNonPlayerAgentsInfo=false
; Flag to enable or disable the world and hud rendering. ; If set to true, all cameras and HUD will stop rendering. By default rendering
; Disabled by default. ; is enabled.
DisableRendering = false DisableRendering=false
[CARLA/QualitySettings] [CARLA/QualitySettings]
; Quality level of the graphics, a lower level makes the simulation run ; Quality level of the graphics, a lower level makes the simulation run

View File

@ -96,7 +96,7 @@ class CarlaSettings(object):
add_section(S_SERVER, self, [ add_section(S_SERVER, self, [
'SynchronousMode', 'SynchronousMode',
'SendNonPlayerAgentsInfo', 'SendNonPlayerAgentsInfo',
'DisableRendering']) 'DisableRendering'])
add_section(S_QUALITY, self, [ add_section(S_QUALITY, self, [
'QualityLevel']) 'QualityLevel'])
add_section(S_LEVEL, self, [ add_section(S_LEVEL, self, [

View File

@ -81,45 +81,55 @@ void ACarlaGameModeBase::InitGame(
} }
// Set default pawn class. // Set default pawn class.
if (!CarlaSettings.PlayerVehicle.IsEmpty()) { if (!CarlaSettings.PlayerVehicle.IsEmpty())
{
auto Class = FindObject<UClass>(ANY_PACKAGE, *CarlaSettings.PlayerVehicle); auto Class = FindObject<UClass>(ANY_PACKAGE, *CarlaSettings.PlayerVehicle);
if (Class) { if (Class)
{
DefaultPawnClass = Class; DefaultPawnClass = Class;
} else { }
else
{
UE_LOG(LogCarla, Error, TEXT("Failed to load player pawn class \"%s\""), *CarlaSettings.PlayerVehicle) UE_LOG(LogCarla, Error, TEXT("Failed to load player pawn class \"%s\""), *CarlaSettings.PlayerVehicle)
} }
} }
if (TaggerDelegate != nullptr) { if (TaggerDelegate != nullptr)
{
TaggerDelegate->RegisterSpawnHandler(world); TaggerDelegate->RegisterSpawnHandler(world);
} else { }
else
{
UE_LOG(LogCarla, Error, TEXT("Missing TaggerDelegate!")); UE_LOG(LogCarla, Error, TEXT("Missing TaggerDelegate!"));
} }
if(CarlaSettingsDelegate!=nullptr) { if(CarlaSettingsDelegate!=nullptr)
{
//apply quality settings //apply quality settings
CarlaSettingsDelegate->ApplyQualitySettingsLevelPostRestart(); CarlaSettingsDelegate->ApplyQualitySettingsLevelPostRestart();
//assign settings delegate for every new actor from now on //assign settings delegate for every new actor from now on
CarlaSettingsDelegate->RegisterSpawnHandler(world); CarlaSettingsDelegate->RegisterSpawnHandler(world);
} else { }
else
{
UE_LOG(LogCarla, Error, TEXT("Missing CarlaSettingsDelegate!")); UE_LOG(LogCarla, Error, TEXT("Missing CarlaSettingsDelegate!"));
} }
if (DynamicWeatherClass != nullptr) { if (DynamicWeatherClass != nullptr)
{
DynamicWeather = world->SpawnActor<ADynamicWeather>(DynamicWeatherClass); DynamicWeather = world->SpawnActor<ADynamicWeather>(DynamicWeatherClass);
} }
if (VehicleSpawnerClass != nullptr) { if (VehicleSpawnerClass != nullptr)
{
VehicleSpawner = world->SpawnActor<AVehicleSpawnerBase>(VehicleSpawnerClass); VehicleSpawner = world->SpawnActor<AVehicleSpawnerBase>(VehicleSpawnerClass);
} }
if (WalkerSpawnerClass != nullptr) { if (WalkerSpawnerClass != nullptr)
{
WalkerSpawner = world->SpawnActor<AWalkerSpawnerBase>(WalkerSpawnerClass); WalkerSpawner = world->SpawnActor<AWalkerSpawnerBase>(WalkerSpawnerClass);
} }
} }
void ACarlaGameModeBase::RestartPlayer(AController* NewPlayer) void ACarlaGameModeBase::RestartPlayer(AController* NewPlayer)
@ -128,16 +138,20 @@ void ACarlaGameModeBase::RestartPlayer(AController* NewPlayer)
TArray<APlayerStart *> UnOccupiedStartPoints; TArray<APlayerStart *> UnOccupiedStartPoints;
APlayerStart *PlayFromHere = FindUnOccupiedStartPoints(NewPlayer, UnOccupiedStartPoints); APlayerStart *PlayFromHere = FindUnOccupiedStartPoints(NewPlayer, UnOccupiedStartPoints);
bool bStartSpotFound = false; bool bStartSpotFound = false;
if (PlayFromHere != nullptr) { if (PlayFromHere != nullptr)
{
RestartPlayerAtPlayerStart(NewPlayer, PlayFromHere); RestartPlayerAtPlayerStart(NewPlayer, PlayFromHere);
RegisterPlayer(*NewPlayer); RegisterPlayer(*NewPlayer);
bStartSpotFound = true; bStartSpotFound = true;
} else if (UnOccupiedStartPoints.Num() > 0u) { }
else if (UnOccupiedStartPoints.Num() > 0u)
{
check(GameController != nullptr); check(GameController != nullptr);
APlayerStart *StartSpot = GameController->ChoosePlayerStart(UnOccupiedStartPoints); APlayerStart *StartSpot = GameController->ChoosePlayerStart(UnOccupiedStartPoints);
if (StartSpot != nullptr) { if (StartSpot != nullptr)
{
RestartPlayerAtPlayerStart(NewPlayer, StartSpot); RestartPlayerAtPlayerStart(NewPlayer, StartSpot);
RegisterPlayer(*NewPlayer); RegisterPlayer(*NewPlayer);
bStartSpotFound = true; bStartSpotFound = true;
} }
} }
@ -145,9 +159,8 @@ void ACarlaGameModeBase::RestartPlayer(AController* NewPlayer)
{ {
UE_LOG(LogCarla, Error, TEXT("No start spot found!")); UE_LOG(LogCarla, Error, TEXT("No start spot found!"));
} }
if(CarlaSettingsDelegate!=nullptr) if(CarlaSettingsDelegate != nullptr)
{ {
//apply quality settings
CarlaSettingsDelegate->ApplyQualitySettingsLevelPreRestart(); CarlaSettingsDelegate->ApplyQualitySettingsLevelPreRestart();
} }
} }
@ -159,20 +172,25 @@ void ACarlaGameModeBase::BeginPlay()
const auto &CarlaSettings = GameInstance->GetCarlaSettings(); const auto &CarlaSettings = GameInstance->GetCarlaSettings();
// Setup semantic segmentation if necessary. // Setup semantic segmentation if necessary.
if (CarlaSettings.bSemanticSegmentationEnabled) { if (CarlaSettings.bSemanticSegmentationEnabled)
{
TagActorsForSemanticSegmentation(); TagActorsForSemanticSegmentation();
TaggerDelegate->SetSemanticSegmentationEnabled(); TaggerDelegate->SetSemanticSegmentationEnabled();
} }
// Change weather. // Change weather.
if (DynamicWeather != nullptr) { if (DynamicWeather != nullptr)
{
const auto *Weather = CarlaSettings.GetActiveWeatherDescription(); const auto *Weather = CarlaSettings.GetActiveWeatherDescription();
if (Weather != nullptr) { if (Weather != nullptr)
{
UE_LOG(LogCarla, Log, TEXT("Changing weather settings to \"%s\""), *Weather->Name); UE_LOG(LogCarla, Log, TEXT("Changing weather settings to \"%s\""), *Weather->Name);
DynamicWeather->SetWeatherDescription(*Weather); DynamicWeather->SetWeatherDescription(*Weather);
DynamicWeather->RefreshWeather(); DynamicWeather->RefreshWeather();
} }
} else { }
else
{
UE_LOG(LogCarla, Error, TEXT("Missing dynamic weather actor!")); UE_LOG(LogCarla, Error, TEXT("Missing dynamic weather actor!"));
} }
@ -180,30 +198,40 @@ void ACarlaGameModeBase::BeginPlay()
TActorIterator<ACityMapGenerator> It(GetWorld()); TActorIterator<ACityMapGenerator> It(GetWorld());
URoadMap *RoadMap = (It ? It->GetRoadMap() : nullptr); URoadMap *RoadMap = (It ? It->GetRoadMap() : nullptr);
if (PlayerController != nullptr) { if (PlayerController != nullptr)
{
PlayerController->SetRoadMap(RoadMap); PlayerController->SetRoadMap(RoadMap);
} else { }
else
{
UE_LOG(LogCarla, Error, TEXT("Player controller is not a AWheeledVehicleAIController!")); UE_LOG(LogCarla, Error, TEXT("Player controller is not a AWheeledVehicleAIController!"));
} }
// Setup other vehicles. // Setup other vehicles.
if (VehicleSpawner != nullptr) { if (VehicleSpawner != nullptr)
{
VehicleSpawner->SetNumberOfVehicles(CarlaSettings.NumberOfVehicles); VehicleSpawner->SetNumberOfVehicles(CarlaSettings.NumberOfVehicles);
VehicleSpawner->SetSeed(CarlaSettings.SeedVehicles); VehicleSpawner->SetSeed(CarlaSettings.SeedVehicles);
VehicleSpawner->SetRoadMap(RoadMap); VehicleSpawner->SetRoadMap(RoadMap);
if (PlayerController != nullptr) { if (PlayerController != nullptr)
{
PlayerController->GetRandomEngine()->Seed( PlayerController->GetRandomEngine()->Seed(
VehicleSpawner->GetRandomEngine()->GenerateSeed()); VehicleSpawner->GetRandomEngine()->GenerateSeed());
} }
} else { }
else
{
UE_LOG(LogCarla, Error, TEXT("Missing vehicle spawner actor!")); UE_LOG(LogCarla, Error, TEXT("Missing vehicle spawner actor!"));
} }
// Setup walkers. // Setup walkers.
if (WalkerSpawner != nullptr) { if (WalkerSpawner != nullptr)
{
WalkerSpawner->SetNumberOfWalkers(CarlaSettings.NumberOfPedestrians); WalkerSpawner->SetNumberOfWalkers(CarlaSettings.NumberOfPedestrians);
WalkerSpawner->SetSeed(CarlaSettings.SeedPedestrians); WalkerSpawner->SetSeed(CarlaSettings.SeedPedestrians);
} else { }
else
{
UE_LOG(LogCarla, Error, TEXT("Missing walker spawner actor!")); UE_LOG(LogCarla, Error, TEXT("Missing walker spawner actor!"));
} }
@ -230,11 +258,14 @@ void ACarlaGameModeBase::RegisterPlayer(AController &NewPlayer)
check(GameController != nullptr); check(GameController != nullptr);
AddTickPrerequisiteActor(&NewPlayer); AddTickPrerequisiteActor(&NewPlayer);
PlayerController = Cast<ACarlaVehicleController>(&NewPlayer); PlayerController = Cast<ACarlaVehicleController>(&NewPlayer);
if (PlayerController != nullptr) { if (PlayerController != nullptr)
{
GetDataRouter().RegisterPlayer(*PlayerController); GetDataRouter().RegisterPlayer(*PlayerController);
GameController->RegisterPlayer(*PlayerController); GameController->RegisterPlayer(*PlayerController);
AttachSensorsToPlayer(); AttachSensorsToPlayer();
} else { }
else
{
UE_LOG(LogCarla, Error, TEXT("ACarlaGameModeBase: Player is not a ACarlaVehicleController")); UE_LOG(LogCarla, Error, TEXT("ACarlaGameModeBase: Player is not a ACarlaVehicleController"));
} }
} }
@ -273,20 +304,26 @@ APlayerStart *ACarlaGameModeBase::FindUnOccupiedStartPoints(
APlayerStart* FoundPlayerStart = nullptr; APlayerStart* FoundPlayerStart = nullptr;
UClass* PawnClass = GetDefaultPawnClassForController(Player); UClass* PawnClass = GetDefaultPawnClassForController(Player);
APawn* PawnToFit = PawnClass ? PawnClass->GetDefaultObject<APawn>() : nullptr; APawn* PawnToFit = PawnClass ? PawnClass->GetDefaultObject<APawn>() : nullptr;
for (TActorIterator<APlayerStart> It(GetWorld()); It; ++It) { for (TActorIterator<APlayerStart> It(GetWorld()); It; ++It)
{
APlayerStart* PlayerStart = *It; APlayerStart* PlayerStart = *It;
if (PlayerStart->IsA<APlayerStartPIE>()) { if (PlayerStart->IsA<APlayerStartPIE>())
{
FoundPlayerStart = PlayerStart; FoundPlayerStart = PlayerStart;
break; break;
} else { }
else
{
FVector ActorLocation = PlayerStart->GetActorLocation(); FVector ActorLocation = PlayerStart->GetActorLocation();
const FRotator ActorRotation = PlayerStart->GetActorRotation(); const FRotator ActorRotation = PlayerStart->GetActorRotation();
if (!GetWorld()->EncroachingBlockingGeometry(PawnToFit, ActorLocation, ActorRotation)) { if (!GetWorld()->EncroachingBlockingGeometry(PawnToFit, ActorLocation, ActorRotation))
{
UnOccupiedStartPoints.Add(PlayerStart); UnOccupiedStartPoints.Add(PlayerStart);
} }
#if WITH_EDITOR #if WITH_EDITOR
else if (GetWorld()->FindTeleportSpot(PawnToFit, ActorLocation, ActorRotation)) { else if (GetWorld()->FindTeleportSpot(PawnToFit, ActorLocation, ActorRotation))
{
UE_LOG( UE_LOG(
LogCarla, LogCarla,
Warning, Warning,

View File

@ -211,10 +211,6 @@ void UCarlaSettings::LoadSettings()
{ {
bUseNetworking = false; bUseNetworking = false;
} }
if(FParse::Param(FCommandLine::Get(), TEXT("disable-rendering")))
{
bDisableRendering = true;
}
} }
} }
@ -255,7 +251,7 @@ void UCarlaSettings::LogSettings() const
UE_LOG(LogCarla, Log, TEXT("Server Time-out = %d ms"), ServerTimeOut); UE_LOG(LogCarla, Log, TEXT("Server Time-out = %d ms"), ServerTimeOut);
UE_LOG(LogCarla, Log, TEXT("Synchronous Mode = %s"), EnabledDisabled(bSynchronousMode)); UE_LOG(LogCarla, Log, TEXT("Synchronous Mode = %s"), EnabledDisabled(bSynchronousMode));
UE_LOG(LogCarla, Log, TEXT("Send Non-Player Agents Info = %s"), EnabledDisabled(bSendNonPlayerAgentsInfo)); UE_LOG(LogCarla, Log, TEXT("Send Non-Player Agents Info = %s"), EnabledDisabled(bSendNonPlayerAgentsInfo));
UE_LOG(LogCarla, Log, TEXT("Disable Render World = %s"), bDisableRendering?TEXT("YES"):TEXT("NO")); UE_LOG(LogCarla, Log, TEXT("Rendering = %s"), EnabledDisabled(!bDisableRendering));
UE_LOG(LogCarla, Log, TEXT("[%s]"), S_CARLA_LEVELSETTINGS); UE_LOG(LogCarla, Log, TEXT("[%s]"), S_CARLA_LEVELSETTINGS);
UE_LOG(LogCarla, Log, TEXT("Player Vehicle = %s"), (PlayerVehicle.IsEmpty() ? TEXT("Default") : *PlayerVehicle)); UE_LOG(LogCarla, Log, TEXT("Player Vehicle = %s"), (PlayerVehicle.IsEmpty() ? TEXT("Default") : *PlayerVehicle));
UE_LOG(LogCarla, Log, TEXT("Number Of Vehicles = %d"), NumberOfVehicles); UE_LOG(LogCarla, Log, TEXT("Number Of Vehicles = %d"), NumberOfVehicles);