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
; performance.
SendNonPlayerAgentsInfo=false
; Flag to enable or disable the world and hud rendering.
; Disabled by default.
DisableRendering = false
; If set to true, all cameras and HUD will stop rendering. By default rendering
; is enabled.
DisableRendering=false
[CARLA/QualitySettings]
; 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, [
'SynchronousMode',
'SendNonPlayerAgentsInfo',
'DisableRendering'])
'DisableRendering'])
add_section(S_QUALITY, self, [
'QualityLevel'])
add_section(S_LEVEL, self, [

View File

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

View File

@ -211,10 +211,6 @@ void UCarlaSettings::LoadSettings()
{
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("Synchronous Mode = %s"), EnabledDisabled(bSynchronousMode));
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("Player Vehicle = %s"), (PlayerVehicle.IsEmpty() ? TEXT("Default") : *PlayerVehicle));
UE_LOG(LogCarla, Log, TEXT("Number Of Vehicles = %d"), NumberOfVehicles);