Fix for Quality Settings apply function

This commit is contained in:
CVC\jbelon 2018-02-26 19:03:18 +01:00
parent 56652b769d
commit f9ae4b3c7c
4 changed files with 51 additions and 42 deletions

View File

@ -25,6 +25,9 @@ SynchronousMode=true
; performance. ; performance.
SendNonPlayerAgentsInfo=false SendNonPlayerAgentsInfo=false
[CARLA/QualitySettings]
DefaultLevel=Epic
[CARLA/LevelSettings] [CARLA/LevelSettings]
; Path of the vehicle class to be used for the player. Leave empty for default. ; Path of the vehicle class to be used for the player. Leave empty for default.
; Paths follow the pattern "/Game/Blueprints/Vehicles/Mustang/Mustang.Mustang_C" ; Paths follow the pattern "/Game/Blueprints/Vehicles/Mustang/Mustang.Mustang_C"
@ -85,6 +88,7 @@ RotationYaw=0
; depth map images instead. ; depth map images instead.
PostProcessing=Depth PostProcessing=Depth
[CARLA/Sensor/MyLidar] [CARLA/Sensor/MyLidar]
SensorType=LIDAR_RAY_TRACE SensorType=LIDAR_RAY_TRACE
; Number of lasers. ; Number of lasers.
@ -106,6 +110,3 @@ RotationPitch=0
RotationYaw=0 RotationYaw=0
RotationRoll=0 RotationRoll=0
[CARLA/QualitySettings]
DefaultLevel=Epic

View File

@ -131,7 +131,8 @@ void ACarlaGameModeBase::BeginPlay()
Super::BeginPlay(); Super::BeginPlay();
const auto &CarlaSettings = GameInstance->GetCarlaSettings(); const auto &CarlaSettings = GameInstance->GetCarlaSettings();
CarlaSettings.ApplyQualitySettingsLevelPostRestart();
// Setup semantic segmentation if necessary. // Setup semantic segmentation if necessary.
if (CarlaSettings.bSemanticSegmentationEnabled) { if (CarlaSettings.bSemanticSegmentationEnabled) {
TagActorsForSemanticSegmentation(); TagActorsForSemanticSegmentation();

View File

@ -118,9 +118,9 @@ static void LoadSettingsFromConfig(
ConfigFile.GetString(S_CARLA_QUALITYSETTINGS, TEXT("DefaultLevel"), sDefaultLevel); ConfigFile.GetString(S_CARLA_QUALITYSETTINGS, TEXT("DefaultLevel"), sDefaultLevel);
if(!Settings.SetQualitySettingsLevel(FQualitySettings::FromString(sDefaultLevel))) if(!Settings.SetQualitySettingsLevel(FQualitySettings::FromString(sDefaultLevel)))
{ {
//ERROR! @TODO : fix settings ///apply pre-restart.... @todo
} }
// Sensors. // Sensors.
FString Sensors; FString Sensors;
@ -179,14 +179,17 @@ bool UCarlaSettings::SetQualitySettingsLevel(EQualitySettingsLevel newDefaultLev
return false; return false;
} }
/*if(newDefaultLevel!=DefaultQualitySettingsLevel) DefaultQualitySettingsLevel = newDefaultLevel;
{
return true; return true;
}*/ }
void UCarlaSettings::ApplyQualitySettingsLevelPostRestart() const
{
UWorld *world = GetWorld(); UWorld *world = GetWorld();
if(!world) return ;
//set the quality settings now //set the quality settings now
switch(newDefaultLevel) switch(DefaultQualitySettingsLevel)
{ {
case EQualitySettingsLevel::Low: {//r.SSR.qualitylaunch commands to lower quality settings case EQualitySettingsLevel::Low: {//r.SSR.qualitylaunch commands to lower quality settings
world->Exec(world,TEXT("r.DefaultFeature.MotionBlur 0")); world->Exec(world,TEXT("r.DefaultFeature.MotionBlur 0"));
@ -248,34 +251,31 @@ bool UCarlaSettings::SetQualitySettingsLevel(EQualitySettingsLevel newDefaultLev
} }
}*/ }*/
//iterate all lights, deactivate shadows //iterate all directional lights, deactivate shadows
UGameplayStatics::GetAllActorsOfClass(world, ALight::StaticClass(), actors); UGameplayStatics::GetAllActorsOfClass(world, ALight::StaticClass(), actors);
for(i=0;i<actors.Num();i++) for(i=0;i<actors.Num();i++)
{ {
ALight *light = Cast<ALight>(actors[i]); //tweak directional lights
if(light) ADirectionalLight* directionallight = Cast<ADirectionalLight>(actors[i]);
if(directionallight)
{ {
//disable all lights shadows directionallight->SetCastShadows(false);
light->SetCastShadows(false); directionallight->SetLightFunctionFadeDistance(LowLightFadeDistance);
continue;
//tweak directional lights
ADirectionalLight* directionallight = Cast<ADirectionalLight>(light);
if(directionallight)
{
directionallight->SetLightFunctionFadeDistance(LowLightFadeDistance);
}
//disable point lights
APointLight* pointlight = Cast<APointLight>(light);
if(pointlight)
{
actors[i]->SetActorHiddenInGame(true);
}
} }
//disable point lights
/*
APointLight* pointlight = Cast<APointLight>(actors[i]);
if(pointlight)
{
actors[i]->SetActorHiddenInGame(true);
}
*/
//disable any other type of light
actors[i]->SetActorHiddenInGame(true);
} }
//Set all the roads the low quality material //Set all the roads the low quality material
/*UGameplayStatics::GetAllActorsWithTag(world, FName("CARLA_ROAD"),actors); /*UGameplayStatics::GetAllActorsWithTag(world, FName("CARLA_ROAD"),actors);
for(i=0; i<actors.Num(); i++) for(i=0; i<actors.Num(); i++)
@ -304,9 +304,6 @@ bool UCarlaSettings::SetQualitySettingsLevel(EQualitySettingsLevel newDefaultLev
default: ; default: ;
} }
DefaultQualitySettingsLevel = newDefaultLevel;
return true;
} }
void UCarlaSettings::LoadSettings() void UCarlaSettings::LoadSettings()

View File

@ -48,9 +48,19 @@ class CARLA_API UCarlaSettings : public UObject
GENERATED_BODY() GENERATED_BODY()
public: public:
/** Sets the new quality settings level and make changes in the game related to it. Returns the reuslt of the operation */
/**
* Sets the new quality settings level and make changes in the game related to it.
* Returns the result of the operation.
* @note This will not apply the quality settings. Use ApplyQualitySettings functions instead
* @param newDefaultLevel Store the new quality
*/
bool SetQualitySettingsLevel(EQualitySettingsLevel newDefaultLevel); bool SetQualitySettingsLevel(EQualitySettingsLevel newDefaultLevel);
/** @return current quality settings level (could not be applied yet) */
EQualitySettingsLevel GetQualitySettingsLevel() const { return DefaultQualitySettingsLevel; }
/** @todo move to class */
void ApplyQualitySettingsLevelPostRestart() const;
void ApplyQualitySettingsLevelPreRestart() const{}
/** Load the settings based on the command-line arguments and the INI file if provided. */ /** Load the settings based on the command-line arguments and the INI file if provided. */
void LoadSettings(); void LoadSettings();
@ -164,12 +174,12 @@ public:
/// @name Quality Settings /// @name Quality Settings
// =========================================================================== // ===========================================================================
/// @{ /// @{
public: private:
/** Quality Settings level. */ /** Quality Settings level. */
UPROPERTY(Category = "Quality Settings", VisibleAnywhere) UPROPERTY(Category = "Quality Settings", VisibleAnywhere, meta =(AllowPrivateAccess="true"))
EQualitySettingsLevel DefaultQualitySettingsLevel = EQualitySettingsLevel::None; EQualitySettingsLevel DefaultQualitySettingsLevel = EQualitySettingsLevel::None;
public:
//UPROPERTY(Category = "Quality Settings", EditAnywhere, config) //UPROPERTY(Category = "Quality Settings", EditAnywhere, config)
//TArray<UMaterial*> RoadMaterials; //TArray<UMaterial*> RoadMaterials;