Add options to game mode for overriding CARLA settings in editor
This commit is contained in:
parent
97885dfdb4
commit
310b31a0f4
|
@ -8,6 +8,14 @@ MockGameController::MockGameController(const FMockGameControllerSettings &Settin
|
||||||
|
|
||||||
void MockGameController::Initialize(UCarlaSettings & CarlaSettings)
|
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)) {
|
if (Settings.bChangeWeatherOnBeginPlay && (CarlaSettings.WeatherDescriptions.Num() > 0)) {
|
||||||
static uint32 StaticIndex = 0u;
|
static uint32 StaticIndex = 0u;
|
||||||
CarlaSettings.WeatherId = StaticIndex % CarlaSettings.WeatherDescriptions.Num();
|
CarlaSettings.WeatherId = StaticIndex % CarlaSettings.WeatherDescriptions.Num();
|
||||||
|
@ -33,6 +41,7 @@ APlayerStart *MockGameController::ChoosePlayerStart(
|
||||||
Index = StaticIndex % AvailableStartSpots.Num();
|
Index = StaticIndex % AvailableStartSpots.Num();
|
||||||
++StaticIndex;
|
++StaticIndex;
|
||||||
}
|
}
|
||||||
|
UE_LOG(LogCarla, Log, TEXT("Spawning player at player start %d/%d"), Index, AvailableStartSpots.Num());
|
||||||
return AvailableStartSpots[Index];
|
return AvailableStartSpots[Index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,10 @@ struct FMockGameControllerSettings
|
||||||
{
|
{
|
||||||
GENERATED_USTRUCT_BODY()
|
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")
|
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller")
|
||||||
bool bChangeWeatherOnBeginPlay = true;
|
bool bChangeWeatherOnBeginPlay = true;
|
||||||
|
|
||||||
|
@ -20,4 +23,24 @@ struct FMockGameControllerSettings
|
||||||
/** If true, semantic segmentation will be always enabled even if no camera needs it. */
|
/** If true, semantic segmentation will be always enabled even if no camera needs it. */
|
||||||
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller")
|
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller")
|
||||||
bool bForceEnableSemanticSegmentation = false;
|
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
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue