Add options to game mode for overriding CARLA settings in editor

This commit is contained in:
nsubiron 2017-05-18 17:01:35 +01:00
parent 97885dfdb4
commit 310b31a0f4
2 changed files with 33 additions and 1 deletions

View File

@ -8,6 +8,14 @@ MockGameController::MockGameController(const FMockGameControllerSettings &Settin
void MockGameController::Initialize(UCarlaSettings & CarlaSettings)
{
#ifdef WITH_EDITOR
if (Settings.bOverrideCarlaSettings) {
CarlaSettings.NumberOfVehicles = Settings.NumberOfVehicles;
CarlaSettings.NumberOfPedestrians = Settings.NumberOfPedestrians;
CarlaSettings.WeatherId = Settings.WeatherId;
}
#endif // WITH_EDITOR
if (Settings.bChangeWeatherOnBeginPlay && (CarlaSettings.WeatherDescriptions.Num() > 0)) {
static uint32 StaticIndex = 0u;
CarlaSettings.WeatherId = StaticIndex % CarlaSettings.WeatherDescriptions.Num();
@ -33,6 +41,7 @@ APlayerStart *MockGameController::ChoosePlayerStart(
Index = StaticIndex % AvailableStartSpots.Num();
++StaticIndex;
}
UE_LOG(LogCarla, Log, TEXT("Spawning player at player start %d/%d"), Index, AvailableStartSpots.Num());
return AvailableStartSpots[Index];
}

View File

@ -9,7 +9,10 @@ struct FMockGameControllerSettings
{
GENERATED_USTRUCT_BODY()
/** If true, weather will be changed every time we start the level. */
/** If true, weather will be changed every time we start the level.
*
* Has precedence over options in "Override CARLA Settings".
*/
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller")
bool bChangeWeatherOnBeginPlay = true;
@ -20,4 +23,24 @@ struct FMockGameControllerSettings
/** If true, semantic segmentation will be always enabled even if no camera needs it. */
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller")
bool bForceEnableSemanticSegmentation = false;
#if WITH_EDITORONLY_DATA
/** Override available settings in CARLA Settings (Editor only). */
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller", meta = (DisplayName = "Override CARLA Settings"))
bool bOverrideCarlaSettings = false;
/** Number of NPC vehicles to be spawned into the level. */
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller", meta = (EditCondition = "bOverrideCarlaSettings", ClampMin = 0))
int32 NumberOfVehicles = 5;
/** Number of NPC pedestrians to be spawned into the level. */
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller", meta = (EditCondition = "bOverrideCarlaSettings", ClampMin = 0))
int32 NumberOfPedestrians = 15;
/** Index of the weather setting to use. If negative, weather won't be changed. */
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller", meta = (EditCondition = "bOverrideCarlaSettings"))
int32 WeatherId = -1;
#endif // WITH_EDITORONLY_DATA
};