Agrarsense
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
UAgrarsenseSettings Class Reference

#include <AgrarsenseSettings.h>

Inheritance diagram for UAgrarsenseSettings:
Inheritance graph
[legend]
Collaboration diagram for UAgrarsenseSettings:
Collaboration graph
[legend]

Public Member Functions

void Setup (UWorld *World)
 
virtual void PostInitProperties () override
 
void LoadSettings (bool bForceReload=false) override
 
void ApplySettings (bool bCheckForCommandLineOverrides) override
 
void SetGraphicsSettings (FGlobalGraphicsSettings NewSettings)
 
void SetWindowMode (EWindowMode::Type WindowType)
 
void SetSimulationSettings (FGlobalSimulationSettings NewSettings)
 
void SetWorldRendering (bool enabled)
 
void SetQualityLevel (EQualityLevel newQualityLevel)
 
void SetQualityLevelFromString (const FString &QualityLevelString)
 
int GetGlobalTargetFrameRate () const
 
void SetGlobalTargetFrameRate (int NewTargetFrameRate)
 
float GetGlobalTimeDilation () const
 
void SetSpectatorMaxSpeed (float MaxSpeed)
 
void SetShowSpectatorRainAndSnowfall (bool Show)
 
float GetSpectatorMaxSpeed () const
 
bool GetShowSpectatorRainAndSnowfall () const
 
void SetGlobalTimeDilation (float TimeDilation)
 
void PauseSimulation ()
 
void UnPauseSimulation ()
 
void PauseSimulationEndOfThisFrame ()
 
void AdvanceFrameCount (int32 FramesToAdvance)
 
void AdvanceTime (float TimeToAdvance)
 
void ChangeMapByName (FString MapName)
 
void ChangeMapByMapPath (const FString &Path)
 
bool GetGrassVisibility () const
 
void SetGrassVisibility (bool Visible)
 
bool GetShadowCSMCache () const
 
void SetShadowCSMCache (bool CacheShadowCSM)
 
EAntiAliasing GetAntiAliasingMethod () const
 
void SetAntiAliasingMethod (EAntiAliasing AntiAliasingMethod)
 
void SetAntiAliasingMethodFromString (const FString &AntiAliasingMethodString)
 
void SetInstancedRenderingVisibility (bool Visible)
 
void SetWorldPositionOffsetRenderDistance (int32 WorldPositionOffsetDistance)
 
void SetNaniteMaxPixelsPerEdge (float MaxPixelsPerEdge=1.0f)
 
void SetShadowCacheInvalidationBehavior (EShadowCacheInvalidationBehavior Behaviour=EShadowCacheInvalidationBehavior::Rigid)
 
void SetShadowCacheInvalidationBehaviorFromString (const FString &BehaviourString)
 
int32 GetWorldPositionOffsetRenderDistance () const
 
float GetNaniteMaxPixelsPerEdge () const
 
EShadowCacheInvalidationBehavior GetShadowCacheInvalidationBehavior () const
 
bool GetStartWindowInitiallyMinimized () const
 
void SetStartWindowInitiallyMinimized (bool Minimized)
 
void SetRenderCustomDepthPass (bool RenderCustomDepthPass)
 
void SetUseVirtualShadowMaps (bool UseVirtualShadowMaps)
 
bool GetIsUsingVirtualShadowMaps () const
 
bool GetIsRenderingCustomDepthPass () const
 
int32 GetNumberOfWorkerThreads () const
 
FString GetConsoleVariableValueString (const FString &VariableName) const
 
EQualityLevel GetCurrentQualityLevel () const
 
TArray< FString > GetMapNames () const
 
TArray< FString > GetMapPaths () const
 

Static Public Member Functions

static UAgrarsenseSettingsGetAgrarsenseSettings ()
 
static bool ShouldStartWindowMinimized ()
 
static bool IsPlayingInMainMenu ()
 
static FGlobalSimulationSettings GetGlobalSimulationSettings ()
 
static bool IsSimulationPaused ()
 
static FGlobalGraphicsSettings GetGlobalGraphicsSettings ()
 

Public Attributes

FGraphicsSettingsDelegate OnGraphicsSettingsChanged
 

Private Member Functions

 UAgrarsenseSettings ()
 
bool ParseLaunchArguments ()
 
void OnSensorSpawned (ASensor *SensorPtr)
 
void OnSensorDestroyed (ASensor *SensorPtr)
 
void SetUltraWithRaytracingLevel ()
 
bool IsRaytracingSupported () const
 
void EnableRaytracing ()
 
void DisableRaytracing ()
 
void SetUltraQualityLevel ()
 
void SetBalancedQualityLevel ()
 
void SetLowQualityLevel ()
 

Private Attributes

int NumberOfPostProcessingSensors = 0
 
bool RenderCustomDepth = false
 
TWeakObjectPtr< UWorld > CurrentWorld = nullptr
 
FGlobalSimulationSettings SimulationSettings
 
FGlobalGraphicsSettings GraphicsSettings
 
FDelegateHandle AdvanceFramesHandle
 
int32 FrameCount = 0
 
FDelegateHandle EndOfFrameHandle
 
const TArray< FString > MapNames
 
const TArray< FString > MapPaths
 

Static Private Attributes

static bool IsMainMenu = false
 
static FString CurrentMapName
 

Friends

class AAgrarsenseGameModeBase
 

Detailed Description

Definition at line 28 of file AgrarsenseSettings.h.

Constructor & Destructor Documentation

◆ UAgrarsenseSettings()

UAgrarsenseSettings::UAgrarsenseSettings ( )
private

Definition at line 41 of file AgrarsenseSettings.cpp.

42{
43}

Member Function Documentation

◆ AdvanceFrameCount()

void UAgrarsenseSettings::AdvanceFrameCount ( int32  FramesToAdvance)

Amount of frames to advance before pausing simulation.

Parameters
Framesnumber of frames to advance before pausing simulation.

Definition at line 671 of file AgrarsenseSettings.cpp.

672{
673 if (FramesToAdvance == 0)
674 {
675 return;
676 }
677
678 if (AdvanceFramesHandle.IsValid())
679 {
680 // Already running this, return
681 return;
682 }
683
684 if (EndOfFrameHandle.IsValid())
685 {
686 // If PauseSimulationEndOfThisFrame was called, unsubribe
687 FCoreDelegates::OnEndFrame.Remove(EndOfFrameHandle);
688 EndOfFrameHandle.Reset();
689 }
690
691 // Unpause simulation now
693
694 FrameCount = 0;
695
696 // Subscribe to Unreal Engine end of frame callback
697 AdvanceFramesHandle = FCoreDelegates::OnEndFrame.AddLambda([this, FramesToAdvance]()
698 {
699 ++FrameCount;
700 if (FrameCount == FramesToAdvance)
701 {
702 // After given number of frames,
703 // unsubscribe from the event and pause simulation again at the end of that frame
704 if (IsValid(this))
705 {
706 FCoreDelegates::OnEndFrame.Remove(AdvanceFramesHandle);
707 AdvanceFramesHandle.Reset();
708 FrameCount = 0;
709
711 }
712 }
713 });
714}
FDelegateHandle AdvanceFramesHandle
FDelegateHandle EndOfFrameHandle

References AdvanceFramesHandle, EndOfFrameHandle, FrameCount, PauseSimulationEndOfThisFrame(), and UnPauseSimulation().

Referenced by UROSCommands::HandleAdvanceFrames(), and UROSCommands::HandleAdvanceOneFrame().

◆ AdvanceTime()

void UAgrarsenseSettings::AdvanceTime ( float  TimeToAdvance)

Amount of time to advance before pausing simulation. @TimeToAdvance time in seconds.

Definition at line 716 of file AgrarsenseSettings.cpp.

717{
718 UWorld* World = CurrentWorld.Get();
719 if (!World)
720 {
721 return;
722 }
723
724 // Unpause simulation now
726
727 // Pause simulation again after TimeToAdvance
728 FTimerHandle AdvanceTimeTimer;
729 World->GetTimerManager().SetTimer(AdvanceTimeTimer, FTimerDelegate::CreateLambda([this]
730 {
731 if (IsValid(this))
732 {
734 }
735
736 }), TimeToAdvance, false);
737}
TWeakObjectPtr< UWorld > CurrentWorld

References CurrentWorld, PauseSimulationEndOfThisFrame(), and UnPauseSimulation().

Referenced by UROSCommands::HandleAdvanceTime().

◆ ApplySettings()

void UAgrarsenseSettings::ApplySettings ( bool  bCheckForCommandLineOverrides)
override

Definition at line 140 of file AgrarsenseSettings.cpp.

141{
142 Super::ApplySettings(bCheckForCommandLineOverrides);
143
146}
void SetSimulationSettings(FGlobalSimulationSettings NewSettings)
FGlobalSimulationSettings SimulationSettings
void SetGraphicsSettings(FGlobalGraphicsSettings NewSettings)
FGlobalGraphicsSettings GraphicsSettings

References GraphicsSettings, SetGraphicsSettings(), SetSimulationSettings(), and SimulationSettings.

Referenced by SetGlobalTargetFrameRate(), and Setup().

◆ ChangeMapByMapPath()

void UAgrarsenseSettings::ChangeMapByMapPath ( const FString &  Path)

Change map by map relative path

Definition at line 766 of file AgrarsenseSettings.cpp.

767{
768 UWorld* World = CurrentWorld.Get();
769 if (World)
770 {
771 UGameplayStatics::OpenLevel(World, *Path, TRAVEL_Absolute);
772 }
773}

References CurrentWorld.

Referenced by ChangeMapByName().

◆ ChangeMapByName()

void UAgrarsenseSettings::ChangeMapByName ( FString  MapName)

Change map by name. This only works for maps defined in MapNames TArray.

Parameters
MapNamemap name as FString

Definition at line 739 of file AgrarsenseSettings.cpp.

740{
741 // Make the map name to lower
742 // This is because ROSCommands.cpp uses this and all the messages are in lower case.
743 MapName = MapName.ToLower();
744
745 bool FoundMap = false;
746 for (int32 i = 0; i < MapNames.Num(); i++)
747 {
748 if (MapName == MapNames[i])
749 {
750 FoundMap = true;
751 FString msg = FString::Printf(TEXT("Changing map to: %s"), *MapName);
753
755 break;
756 }
757 }
758
759 if (!FoundMap)
760 {
761 FString msg = FString::Printf(TEXT("Couldn't find map: %s"), *MapName);
763 }
764}
static void Log(const FString &Message, bool LogToTextFile=true, bool LogToROS=true)
const TArray< FString > MapPaths
void ChangeMapByMapPath(const FString &Path)
const TArray< FString > MapNames

References ChangeMapByMapPath(), SimulatorLog::Log(), MapNames, and MapPaths.

Referenced by UROSCommands::HandleChangeMap().

◆ DisableRaytracing()

void UAgrarsenseSettings::DisableRaytracing ( )
private

Definition at line 868 of file AgrarsenseSettings.cpp.

869{
870 UWorld* World = CurrentWorld.Get();
871 if (!World || !GEngine)
872 {
873 return;
874 }
875
876 GEngine->Exec(World, TEXT("r.Lumen.HardwareRayTracing 0"));
877 GEngine->Exec(World, TEXT("r.RayTracing.Geometry 0"));
878 GEngine->Exec(World, TEXT("r.RayTracing.Shadows 0"));
879 GEngine->Exec(World, TEXT("r.RayTracing.Reflections 0"));
880 GEngine->Exec(World, TEXT("r.RayTracing.AmbientOcclusion 0"));
881 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination 0"));
882 GEngine->Exec(World, TEXT("r.RayTracing.Translucency 0"));
883 GEngine->Exec(World, TEXT("r.RayTracing.SkyLight 0"));
884}

References CurrentWorld.

Referenced by SetBalancedQualityLevel(), SetLowQualityLevel(), and SetUltraQualityLevel().

◆ EnableRaytracing()

void UAgrarsenseSettings::EnableRaytracing ( )
private

Definition at line 850 of file AgrarsenseSettings.cpp.

851{
852 UWorld* World = CurrentWorld.Get();
853 if (!World || !GEngine)
854 {
855 return;
856 }
857
858 GEngine->Exec(World, TEXT("r.Lumen.HardwareRayTracing 1")); // Enable lumen raytracing
859 GEngine->Exec(World, TEXT("r.RayTracing.Geometry 1")); // Enable ray tracing geometry
860 GEngine->Exec(World, TEXT("r.RayTracing.Shadows 1")); // Enable ray tracing shadows
861 GEngine->Exec(World, TEXT("r.RayTracing.Reflections 1")); // Enable ray tracing reflections
862 GEngine->Exec(World, TEXT("r.RayTracing.AmbientOcclusion 1")); // Enable ray tracing ambient occlusion
863 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination 1")); // Enable ray tracing global illumination
864 GEngine->Exec(World, TEXT("r.RayTracing.Translucency 1")); // Enable ray tracing translucency
865 GEngine->Exec(World, TEXT("r.RayTracing.SkyLight 1")); // Enable ray tracing sky light
866}

References CurrentWorld.

Referenced by SetUltraWithRaytracingLevel().

◆ GetAgrarsenseSettings()

UAgrarsenseSettings * UAgrarsenseSettings::GetAgrarsenseSettings ( )
static

Definition at line 130 of file AgrarsenseSettings.cpp.

131{
132 return Cast<UAgrarsenseSettings>(UGameUserSettings::GetGameUserSettings());
133}

Referenced by UAgrarsenseStatics::GetAgrarsenseSettings(), and AAgrarsenseGameModeBase::SpawnNeededActorsInitGame().

◆ GetAntiAliasingMethod()

EAntiAliasing UAgrarsenseSettings::GetAntiAliasingMethod ( ) const

Get current anti aliasing method

Returns

Definition at line 448 of file AgrarsenseSettings.cpp.

449{
451}

References FGlobalGraphicsSettings::AntiAliasingMethod, and GraphicsSettings.

◆ GetConsoleVariableValueString()

FString UAgrarsenseSettings::GetConsoleVariableValueString ( const FString &  VariableName) const

Get Console variable value as FString.

Returns
console variable value as FString or empty string if not found.

Definition at line 197 of file AgrarsenseSettings.cpp.

198{
199 IConsoleVariable* ConsoleVariable = IConsoleManager::Get().FindConsoleVariable(*VariableName);
200 if (ConsoleVariable)
201 {
202 FString VariableValue = ConsoleVariable->GetString();
203 return VariableValue;
204 }
205 else
206 {
207 return FString();
208 }
209}

◆ GetCurrentQualityLevel()

EQualityLevel UAgrarsenseSettings::GetCurrentQualityLevel ( ) const
inline

Get current graphics quality level

Returns
EQualityLevel enum

Definition at line 360 of file AgrarsenseSettings.h.

361 {
363 }

◆ GetGlobalGraphicsSettings()

static FGlobalGraphicsSettings UAgrarsenseSettings::GetGlobalGraphicsSettings ( )
inlinestatic

Get Global Graphics settings.

Definition at line 432 of file AgrarsenseSettings.h.

433 {
435 }
static UAgrarsenseSettings * GetAgrarsenseSettings()

◆ GetGlobalSimulationSettings()

static FGlobalSimulationSettings UAgrarsenseSettings::GetGlobalSimulationSettings ( )
inlinestatic

Get Global simulation settings.

Definition at line 414 of file AgrarsenseSettings.h.

415 {
417 }

◆ GetGlobalTargetFrameRate()

int UAgrarsenseSettings::GetGlobalTargetFrameRate ( ) const

Get the global target frame rate for the Simulator

Returns
int TargetFrameRate

Definition at line 550 of file AgrarsenseSettings.cpp.

551{
552 return GetFrameRateLimit();
553}

◆ GetGlobalTimeDilation()

float UAgrarsenseSettings::GetGlobalTimeDilation ( ) const

Get global time dilation factor, affecting the entire simulation tick time flow.

Returns
float TimeDilation

Definition at line 561 of file AgrarsenseSettings.cpp.

562{
563 UWorld* World = CurrentWorld.Get();
564
565 if (!World)
566 {
568 }
569
570 return UGameplayStatics::GetGlobalTimeDilation(World);
571}

References CurrentWorld, SimulationSettings, and FGlobalSimulationSettings::TimeDilation.

◆ GetGrassVisibility()

bool UAgrarsenseSettings::GetGrassVisibility ( ) const

Get if grass visible or not

Returns
Grass visibility

Definition at line 246 of file AgrarsenseSettings.cpp.

References GraphicsSettings, and FGlobalGraphicsSettings::RenderGrass.

◆ GetIsRenderingCustomDepthPass()

bool UAgrarsenseSettings::GetIsRenderingCustomDepthPass ( ) const

Get is rendering custom depth pass on.

Definition at line 443 of file AgrarsenseSettings.cpp.

444{
445 return RenderCustomDepth;
446}

References RenderCustomDepth.

◆ GetIsUsingVirtualShadowMaps()

bool UAgrarsenseSettings::GetIsUsingVirtualShadowMaps ( ) const

Get is rendering virtual shadow maps on.

Definition at line 438 of file AgrarsenseSettings.cpp.

References GraphicsSettings, and FGlobalGraphicsSettings::UseVirtualShadowMaps.

◆ GetMapNames()

TArray< FString > UAgrarsenseSettings::GetMapNames ( ) const
inline

Get map names as TArray. This TArray is hardcoded.

Returns
TArray<FString> MapNames

Definition at line 370 of file AgrarsenseSettings.h.

371 {
372 return MapNames;
373 }

Referenced by UROSCommands::HandlePrintMaps().

◆ GetMapPaths()

TArray< FString > UAgrarsenseSettings::GetMapPaths ( ) const
inline

Get map paths as TArray. This TArray is hardcoded.

Returns
TArray<FString> MapPaths

Definition at line 380 of file AgrarsenseSettings.h.

381 {
382 return MapPaths;
383 }

◆ GetNaniteMaxPixelsPerEdge()

float UAgrarsenseSettings::GetNaniteMaxPixelsPerEdge ( ) const

◆ GetNumberOfWorkerThreads()

int32 UAgrarsenseSettings::GetNumberOfWorkerThreads ( ) const

Returns the number of worker threads used by the Simulator.

Definition at line 192 of file AgrarsenseSettings.cpp.

193{
194 return FPlatformMisc::NumberOfWorkerThreadsToSpawn();
195}

◆ GetShadowCacheInvalidationBehavior()

EShadowCacheInvalidationBehavior UAgrarsenseSettings::GetShadowCacheInvalidationBehavior ( ) const

◆ GetShadowCSMCache()

bool UAgrarsenseSettings::GetShadowCSMCache ( ) const

Get Shadow CSM cache

Returns
Shadow CSM cache on/off

Definition at line 280 of file AgrarsenseSettings.cpp.

References GraphicsSettings, and FGlobalGraphicsSettings::ShadowCSMCaching.

◆ GetShowSpectatorRainAndSnowfall()

bool UAgrarsenseSettings::GetShowSpectatorRainAndSnowfall ( ) const
inline

Get if spectator rain and snowfall niagara system should be visible

Returns
Show or not

Definition at line 141 of file AgrarsenseSettings.h.

◆ GetSpectatorMaxSpeed()

float UAgrarsenseSettings::GetSpectatorMaxSpeed ( ) const
inline

Get the max of the spectator pawn

Returns
Current max speed

Definition at line 131 of file AgrarsenseSettings.h.

◆ GetStartWindowInitiallyMinimized()

bool UAgrarsenseSettings::GetStartWindowInitiallyMinimized ( ) const

Get if new UnrealWindow's start minimized instead of popping in front of everything.

Definition at line 391 of file AgrarsenseSettings.cpp.

References SimulationSettings, and FGlobalSimulationSettings::StartCameraWindowsMinimized.

◆ GetWorldPositionOffsetRenderDistance()

int32 UAgrarsenseSettings::GetWorldPositionOffsetRenderDistance ( ) const

◆ IsPlayingInMainMenu()

static bool UAgrarsenseSettings::IsPlayingInMainMenu ( )
inlinestatic

Check if currently playing in the main menu map.

Returns
true if the game is playing in the main menu, false otherwise.

Definition at line 405 of file AgrarsenseSettings.h.

406 {
407 return IsMainMenu;
408 }

Referenced by ATagger::BeginPlay(), and USimulatorJsonParser::ParseAndOperateJSONFile().

◆ IsRaytracingSupported()

bool UAgrarsenseSettings::IsRaytracingSupported ( ) const
private

Definition at line 824 of file AgrarsenseSettings.cpp.

825{
826 bool RayTracingSupported = false;
827
828 // Check if the hardware supports ray tracing
829 IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing"));
830 if (CVar && CVar->GetInt() > 0 && GRHISupportsRayTracing)
831 {
832 RayTracingSupported = true;
833 }
834
835#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION <= 3 // Check Engine version. In UE 5.4 Vulkan also supports raytracing.
836 #if PLATFORM_WINDOWS
837 {
838 // DirectX Raytracing support check
839 if (!GDynamicRHI && GDynamicRHI->GetName() == FString(TEXT("D3D12")))
840 {
841 RayTracingSupported = false;
842 }
843 }
844 #endif
845#endif
846
847 return RayTracingSupported;
848}

Referenced by SetUltraWithRaytracingLevel().

◆ IsSimulationPaused()

static bool UAgrarsenseSettings::IsSimulationPaused ( )
inlinestatic

◆ LoadSettings()

void UAgrarsenseSettings::LoadSettings ( bool  bForceReload = false)
override

Load and apply saved settings

Definition at line 135 of file AgrarsenseSettings.cpp.

136{
137 Super::LoadSettings(bForceReload);
138}

◆ OnSensorDestroyed()

void UAgrarsenseSettings::OnSensorDestroyed ( ASensor SensorPtr)
private

Definition at line 791 of file AgrarsenseSettings.cpp.

792{
793 if (!SensorPtr)
794 {
795 return;
796 }
797
798 ESensorTypes type = SensorPtr->GetSensorType();
800 {
803 {
804 // If there's no more sensors that need CustomDepthPass to work,
805 // disable it to save rendering performance
807 }
808 }
809}
ESensorTypes
Definition: SensorTypes.h:15
@ SemanticSegmentationCamera
virtual ESensorTypes GetSensorType() const
Definition: Sensor.h:64
void SetRenderCustomDepthPass(bool RenderCustomDepthPass)

References ASensor::GetSensorType(), NumberOfPostProcessingSensors, SemanticSegmentationCamera, SetRenderCustomDepthPass(), and ThermalCamera.

Referenced by Setup().

◆ OnSensorSpawned()

void UAgrarsenseSettings::OnSensorSpawned ( ASensor SensorPtr)
private

Definition at line 775 of file AgrarsenseSettings.cpp.

776{
777 if (!SensorPtr)
778 {
779 return;
780 }
781
782 ESensorTypes type = SensorPtr->GetSensorType();
784 {
785 // If the the sensor uses CustomDepthPass to color objects, enable custom depth pass
788 }
789}

References ASensor::GetSensorType(), NumberOfPostProcessingSensors, SemanticSegmentationCamera, SetRenderCustomDepthPass(), and ThermalCamera.

Referenced by Setup().

◆ ParseLaunchArguments()

bool UAgrarsenseSettings::ParseLaunchArguments ( )
private

Definition at line 148 of file AgrarsenseSettings.cpp.

149{
150 bool SettingsWereChanged = false;
151
152 // Check -map= launch argument
153 FString AntiAliasingString;
154 if (FParse::Value(FCommandLine::Get(), TEXT("-antialiasing="), AntiAliasingString))
155 {
156 // Convert incoming string to int and then EAntiAliasing enum
157 int32 AntiAliasingInt;
158 if (AntiAliasingString.IsNumeric())
159 {
160 AntiAliasingInt = FCString::Atoi(*AntiAliasingString);
161 EAntiAliasing NewAntiAliasingMethod = static_cast<EAntiAliasing>(AntiAliasingInt);
162 GraphicsSettings.AntiAliasingMethod = NewAntiAliasingMethod;
163 SettingsWereChanged = true;
164 }
165 }
166
167 // Check -no-world-rendering launch argument
168 if (FParse::Param(FCommandLine::Get(), TEXT("-no-spectator-rendering")))
169 {
171 SettingsWereChanged = true;
172 }
173
174 // Check -start-camerawindows-minimized launch argument
175 if (FParse::Param(FCommandLine::Get(), TEXT("-start-camerawindows-minimized")))
176 {
178 SettingsWereChanged = true;
179 }
180
181 // Check -quality-level= launch argument
182 FString QualityLevelString;
183 if (FParse::Value(FCommandLine::Get(), TEXT("-quality-level="), QualityLevelString))
184 {
186 SettingsWereChanged = true;
187 }
188
189 return SettingsWereChanged;
190}
EAntiAliasing
Definition: AntiAliasing.h:15
static EQualityLevel ConvertStringToQualityLevel(const FString &String)

References FGlobalGraphicsSettings::AntiAliasingMethod, UEnumUtilities::ConvertStringToQualityLevel(), FGlobalGraphicsSettings::DisableSpectatorRendering, GraphicsSettings, FGlobalGraphicsSettings::QualityLevel, SimulationSettings, and FGlobalSimulationSettings::StartCameraWindowsMinimized.

Referenced by PostInitProperties().

◆ PauseSimulation()

void UAgrarsenseSettings::PauseSimulation ( )

Pause the Simulator immediately.

Definition at line 621 of file AgrarsenseSettings.cpp.

622{
623 UWorld* World = CurrentWorld.Get();
625 {
626 UGameplayStatics::SetGlobalTimeDilation(World, 0.0f);
627 UGameplayStatics::SetGamePaused(World, true);
629
630 SimulatorLog::Log("Simulator paused");
631 }
632}

References CurrentWorld, FGlobalSimulationSettings::IsSimulationPaused, SimulatorLog::Log(), and SimulationSettings.

Referenced by PauseSimulationEndOfThisFrame().

◆ PauseSimulationEndOfThisFrame()

void UAgrarsenseSettings::PauseSimulationEndOfThisFrame ( )

Pauses the Simulator after the end of this frame.

Definition at line 647 of file AgrarsenseSettings.cpp.

648{
650 {
651 return;
652 }
653
654 // Subscribe to Unreal Engine end of frame callback
655 EndOfFrameHandle = FCoreDelegates::OnEndFrame.AddLambda([this]()
656 {
657 // After receiving the event, unsubcribe from the event and pause the simulation.
658 if (IsValid(this))
659 {
660 if (EndOfFrameHandle.IsValid())
661 {
662 FCoreDelegates::OnEndFrame.Remove(EndOfFrameHandle);
663 EndOfFrameHandle.Reset();
664 }
665
667 }
668 });
669}

References EndOfFrameHandle, FGlobalSimulationSettings::IsSimulationPaused, PauseSimulation(), and SimulationSettings.

Referenced by AdvanceFrameCount(), AdvanceTime(), and UROSCommands::HandlePauseSimulator().

◆ PostInitProperties()

void UAgrarsenseSettings::PostInitProperties ( )
overridevirtual

Definition at line 118 of file AgrarsenseSettings.cpp.

119{
120 Super::PostInitProperties();
121
122#if UE_BUILD_SHIPPING || UE_BUILD_DEVELOPMENT
124 {
125 SaveConfig();
126 }
127#endif
128}

References ParseLaunchArguments().

◆ SetAntiAliasingMethod()

void UAgrarsenseSettings::SetAntiAliasingMethod ( EAntiAliasing  AntiAliasingMethod)

Override anti aliasing method. Default TAA.

Parameters
AntiAliasingMethod

Definition at line 453 of file AgrarsenseSettings.cpp.

454{
455
456 UWorld* World = CurrentWorld.Get();
457
458 if (!GEngine || !World)
459 {
460 return;
461 }
462
463 GraphicsSettings.AntiAliasingMethod = AntiAliasingMethod;
464
465 FString ExecCommand;
466 switch (AntiAliasingMethod)
467 {
469 ExecCommand = TEXT("r.AntiAliasingMethod 0");
470 break;
471
473 ExecCommand = TEXT("r.AntiAliasingMethod 1");
474 break;
475
477 ExecCommand = TEXT("r.AntiAliasingMethod 2");
478 break;
479
480 // MSAA ("r.AntiAliasingMethod 3) is not supported on Deferred rendering
481
483 ExecCommand = TEXT("r.AntiAliasingMethod 4");
484 break;
485
486 default:
487 return;
488 }
489
490 GEngine->Exec(World, *ExecCommand);
491
493}
FGraphicsSettingsDelegate OnGraphicsSettingsChanged

References FGlobalGraphicsSettings::AntiAliasingMethod, CurrentWorld, FXAA, GraphicsSettings, NONE, OnGraphicsSettingsChanged, TAA, and TSR.

Referenced by SetAntiAliasingMethodFromString(), and SetGraphicsSettings().

◆ SetAntiAliasingMethodFromString()

void UAgrarsenseSettings::SetAntiAliasingMethodFromString ( const FString &  AntiAliasingMethodString)

@Override anti aliasing method using a string.

Parameters
AntiAliasingMethodString

Definition at line 495 of file AgrarsenseSettings.cpp.

496{
497 EAntiAliasing NewMethod = UEnumUtilities::ConvertStringToAntiAliasingMethod(AntiAliasingMethodString);
498 SetAntiAliasingMethod(NewMethod);
499}
void SetAntiAliasingMethod(EAntiAliasing AntiAliasingMethod)
static EAntiAliasing ConvertStringToAntiAliasingMethod(const FString &String)

References UEnumUtilities::ConvertStringToAntiAliasingMethod(), and SetAntiAliasingMethod().

◆ SetBalancedQualityLevel()

void UAgrarsenseSettings::SetBalancedQualityLevel ( )
private

Definition at line 925 of file AgrarsenseSettings.cpp.

926{
927 UWorld* World = CurrentWorld.Get();
928 if (!World || !GEngine)
929 {
930 return;
931 }
932
934
935 GEngine->Exec(World, TEXT("sg.PostProcessQuality 3"));
936 GEngine->Exec(World, TEXT("sg.TextureQuality 3"));
937 GEngine->Exec(World, TEXT("sg.EffectsQuality 3"));
938 GEngine->Exec(World, TEXT("sg.FoliageQuality 3"));
939
940 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.03"));
941 GEngine->Exec(World, TEXT("r.SeparateTranslucency 1"));
942 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 2"));
943 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 1"));
944 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 64"));
945 GEngine->Exec(World, TEXT("r.MaxAnisotropy 8"));
946 GEngine->Exec(World, TEXT("r.LensFlareQuality 2"));
947 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 1"));
948 GEngine->Exec(World, TEXT("r.FastBlurThreshold 7"));
949 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
950 GEngine->Exec(World, TEXT("r.ShadowQuality 3"));
951 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 1"));
952 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 2"));
953 GEngine->Exec(World, TEXT("r.DetailMode 2"));
954 GEngine->Exec(World, TEXT("r.BloomQuality 4"));
955 GEngine->Exec(World, TEXT("foliage.DensityScale 1"));
956 GEngine->Exec(World, TEXT("grass.DensityScale 1"));
957 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
958 GEngine->Exec(World, TEXT("r.Shadow.RadiusThreshold 0.01"));
959
960 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
961}
void SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior Behaviour=EShadowCacheInvalidationBehavior::Rigid)

References CurrentWorld, DisableRaytracing(), and SetShadowCacheInvalidationBehavior().

Referenced by SetQualityLevel().

◆ SetGlobalTargetFrameRate()

void UAgrarsenseSettings::SetGlobalTargetFrameRate ( int  NewTargetFrameRate)

Sets the global target frame rate for the Simulator. This function allows you to specify a target frame rate in frames per second (FPS) that Unreal Engine will attempt to maintain.

Parameters
NewTargetFrameRateThe desired target frame rate to set (in FPS).

Definition at line 555 of file AgrarsenseSettings.cpp.

556{
557 SetFrameRateLimit(NewTargetFrameRate);
558 ApplySettings(false);
559}
void ApplySettings(bool bCheckForCommandLineOverrides) override

References ApplySettings().

Referenced by UROSCommands::HandleSetGlobalTargetFrameRate().

◆ SetGlobalTimeDilation()

void UAgrarsenseSettings::SetGlobalTimeDilation ( float  TimeDilation)

Set the global time dilation factor, affecting the entire simulation tick time flow. This function allows you to control the time dilation factor for the entire game world. Time dilation affects the speed of all game actors, animations, and other time-dependent processes.

Parameters
TimeDilationThe desired time dilation factor. A value of 1.0 represents real-time, while values less than 1.0 slow down time, and values greater than 1.0 speed it up.

Definition at line 573 of file AgrarsenseSettings.cpp.

574{
575 UWorld* World = CurrentWorld.Get();
576 if (!World)
577 {
578 return;
579 }
580
581 SimulationSettings.TimeDilation = TimeDilation;
582 UGameplayStatics::SetGlobalTimeDilation(World, TimeDilation);
583
584 FString msg = FString::Printf(TEXT("Global time dilation: %f"), TimeDilation);
586}

References CurrentWorld, SimulatorLog::Log(), SimulationSettings, and FGlobalSimulationSettings::TimeDilation.

Referenced by UROSCommands::HandleSetGlobalTimeDilation(), and SetSimulationSettings().

◆ SetGraphicsSettings()

void UAgrarsenseSettings::SetGraphicsSettings ( FGlobalGraphicsSettings  NewSettings)

Change global graphics settings.

Parameters
NewSettingsThe new graphics settings to apply.

Definition at line 211 of file AgrarsenseSettings.cpp.

References FGlobalGraphicsSettings::AntiAliasingMethod, FGlobalGraphicsSettings::DisableSpectatorRendering, GraphicsSettings, FGlobalGraphicsSettings::QualityLevel, FGlobalGraphicsSettings::RenderGrass, SetAntiAliasingMethod(), SetGrassVisibility(), SetQualityLevel(), SetShadowCSMCache(), SetUseVirtualShadowMaps(), SetWorldRendering(), FGlobalGraphicsSettings::ShadowCSMCaching, and FGlobalGraphicsSettings::UseVirtualShadowMaps.

Referenced by ApplySettings().

◆ SetGrassVisibility()

void UAgrarsenseSettings::SetGrassVisibility ( bool  Visible)

Set grass rendering visibility.

Definition at line 251 of file AgrarsenseSettings.cpp.

252{
253 if (GraphicsSettings.RenderGrass == Visible)
254 {
255 return;
256 }
257
258 UWorld* World = CurrentWorld.Get();
259
260 if (!GEngine || !World)
261 {
262 return;
263 }
264
266
268 {
269 GEngine->Exec(World, TEXT("grass.enable 0"));
270 GEngine->Exec(World, TEXT("grass.FlushCache"));
271 }
272 else
273 {
274 GEngine->Exec(World, TEXT("grass.enable 1"));
275 }
276
278}

References CurrentWorld, GraphicsSettings, OnGraphicsSettingsChanged, and FGlobalGraphicsSettings::RenderGrass.

Referenced by SetGraphicsSettings().

◆ SetInstancedRenderingVisibility()

void UAgrarsenseSettings::SetInstancedRenderingVisibility ( bool  Visible)

Set instanced rendering visibility which is most static objects. Mainly for debugging purposes.

Definition at line 310 of file AgrarsenseSettings.cpp.

311{
312 UWorld* World = CurrentWorld.Get();
313
314 if (World)
315 {
317 if (InstanceRenderer)
318 {
319 InstanceRenderer->SetInstancedRendering(Visible);
320 }
321 }
322}
void SetInstancedRendering(bool ShouldRender)
static AInstancedRenderer * GetInstancedRenderer(const UObject *WorldContextObject)

References CurrentWorld, UAgrarsenseStatics::GetInstancedRenderer(), and AInstancedRenderer::SetInstancedRendering().

◆ SetLowQualityLevel()

void UAgrarsenseSettings::SetLowQualityLevel ( )
private

Definition at line 963 of file AgrarsenseSettings.cpp.

964{
965 UWorld* World = CurrentWorld.Get();
966 if (!World || !GEngine)
967 {
968 return;
969 }
970
972
973 GEngine->Exec(World, TEXT("sg.PostProcessQuality 0"));
974 GEngine->Exec(World, TEXT("sg.ShadowQuality 0"));
975 GEngine->Exec(World, TEXT("sg.TextureQuality 0"));
976 GEngine->Exec(World, TEXT("sg.EffectsQuality 0"));
977 GEngine->Exec(World, TEXT("sg.FoliageQuality 0"));
978
979 GEngine->Exec(World, TEXT("r.DefaultFeature.MotionBlur 0"));
980 GEngine->Exec(World, TEXT("r.DefaultFeature.Bloom 0"));
981 GEngine->Exec(World, TEXT("r.DefaultFeature.AmbientOcclusion 0"));
982 GEngine->Exec(World, TEXT("r.DefaultFeature.AmbientOcclusionStaticFraction 0"));
983 GEngine->Exec(World, TEXT("r.HZBOcclusion 0"));
984 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.01"));
985 GEngine->Exec(World, TEXT("r.SeparateTranslucency 0"));
986 GEngine->Exec(World, TEXT("r.FinishCurrentFrame 0"));
987 GEngine->Exec(World, TEXT("r.MotionBlurQuality 0"));
988 GEngine->Exec(World, TEXT("r.BloomQuality 1"));
989 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 0"));
990 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 0"));
991 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 4"));
992 GEngine->Exec(World, TEXT("r.MaxAnisotropy 4"));
993 GEngine->Exec(World, TEXT("r.LensFlareQuality 0"));
994 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 0"));
995 GEngine->Exec(World, TEXT("r.FastBlurThreshold 0"));
996 GEngine->Exec(World, TEXT("r.SSR 0"));
997 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
998 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 0"));
999 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 4"));
1000 GEngine->Exec(World, TEXT("r.OcclusionQueryLocation 1"));
1001 GEngine->Exec(World, TEXT("foliage.DensityScale 0"));
1002 GEngine->Exec(World, TEXT("grass.DensityScale 0"));
1003 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
1004
1005 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
1006}

References CurrentWorld, DisableRaytracing(), and SetShadowCacheInvalidationBehavior().

Referenced by SetQualityLevel().

◆ SetNaniteMaxPixelsPerEdge()

void UAgrarsenseSettings::SetNaniteMaxPixelsPerEdge ( float  MaxPixelsPerEdge = 1.0f)

Definition at line 330 of file AgrarsenseSettings.cpp.

331{
332 UWorld* World = CurrentWorld.Get();
333 if (GEngine && World)
334 {
335 MaxPixelsPerEdge = FMath::Clamp(MaxPixelsPerEdge, 0.1f, 10.0f);
336
337 FString Command = FString::Printf(TEXT("r.Nanite.MaxPixelsPerEdge %f"), MaxPixelsPerEdge);
338 GEngine->Exec(World, *Command);
339
340 GraphicsSettings.NaniteMaxPixelsPerEdge = MaxPixelsPerEdge;
342 }
343}

References CurrentWorld, GraphicsSettings, FGlobalGraphicsSettings::NaniteMaxPixelsPerEdge, and OnGraphicsSettingsChanged.

Referenced by UROSCommands::HandleSetNaniteMaxPixelsPerEdge().

◆ SetQualityLevel()

void UAgrarsenseSettings::SetQualityLevel ( EQualityLevel  newQualityLevel)

Set new Graphics quality level.

Parameters
qualityLevelEQualityLevel enum

Definition at line 515 of file AgrarsenseSettings.cpp.

516{
517 GraphicsSettings.QualityLevel = newQualityLevel;
518
520 {
523 break;
524
527 break;
528
531 break;
532
535 break;
536 }
537
539 FString Msg = FString::Printf(TEXT("Graphics settings: %s"), *QualityLevelString);
541
543}
static FString ConvertQualityLevelToString(EQualityLevel QualityLevel)

References Balanced, UEnumUtilities::ConvertQualityLevelToString(), GraphicsSettings, SimulatorLog::Log(), Low, OnGraphicsSettingsChanged, FGlobalGraphicsSettings::QualityLevel, SetBalancedQualityLevel(), SetLowQualityLevel(), SetUltraQualityLevel(), SetUltraWithRaytracingLevel(), Ultra, and UltraRaytracing.

Referenced by SetGraphicsSettings(), and SetQualityLevelFromString().

◆ SetQualityLevelFromString()

void UAgrarsenseSettings::SetQualityLevelFromString ( const FString &  QualityLevelString)

Set new graphics quality level from string parsed to quality level enum.

Parameters
FString&QualityLevelString

Definition at line 545 of file AgrarsenseSettings.cpp.

546{
548}

References UEnumUtilities::ConvertStringToQualityLevel(), and SetQualityLevel().

Referenced by UROSCommands::HandleSetQualityLevel().

◆ SetRenderCustomDepthPass()

void UAgrarsenseSettings::SetRenderCustomDepthPass ( bool  RenderCustomDepthPass)

Set should custom depth pass be rendered at all.

Definition at line 401 of file AgrarsenseSettings.cpp.

402{
403 UWorld* World = CurrentWorld.Get();
404 if (GEngine || World)
405 {
406 RenderCustomDepth = RenderCustomDepthPass;
407 if (RenderCustomDepthPass)
408 {
409 GEngine->Exec(World, TEXT("r.CustomDepth 3"));
410 }
411 else
412 {
413 GEngine->Exec(World, TEXT("r.CustomDepth 0"));
414 }
415 }
416}

References CurrentWorld, and RenderCustomDepth.

Referenced by OnSensorDestroyed(), and OnSensorSpawned().

◆ SetShadowCacheInvalidationBehavior()

void UAgrarsenseSettings::SetShadowCacheInvalidationBehavior ( EShadowCacheInvalidationBehavior  Behaviour = EShadowCacheInvalidationBehavior::Rigid)

◆ SetShadowCacheInvalidationBehaviorFromString()

void UAgrarsenseSettings::SetShadowCacheInvalidationBehaviorFromString ( const FString &  BehaviourString)

Set Shadow cache invalidation behavior option from string.

See also
SetShadowCacheInvalidationBehaviour(EShadowCacheInvalidationBehavior Behaviour) for what setting does
Parameters
BehaviourStringString to convert to enum

Definition at line 354 of file AgrarsenseSettings.cpp.

355{
356 FString BehaviourStringToLower = BehaviourString.ToLower();
357
358 if (BehaviourStringToLower == "auto")
359 {
360 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Auto);
361 }
362 else if (BehaviourStringToLower == "rigid")
363 {
364 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
365 }
366 else if (BehaviourStringToLower == "always")
367 {
368 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Always);
369 }
370 else if (BehaviourStringToLower == "static")
371 {
372 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Static);
373 }
374}

References SetShadowCacheInvalidationBehavior().

◆ SetShadowCSMCache()

void UAgrarsenseSettings::SetShadowCSMCache ( bool  CacheShadowCSM)

Definition at line 285 of file AgrarsenseSettings.cpp.

286{
287 if (GraphicsSettings.ShadowCSMCaching == CacheShadowCSM)
288 {
289 return;
290 }
291
292 UWorld* World = CurrentWorld.Get();
293 if (GEngine && World)
294 {
295 GraphicsSettings.ShadowCSMCaching = CacheShadowCSM;
296
298 {
299 GEngine->Exec(World, TEXT("r.Shadow.CSMCaching 1"));
300 }
301 else
302 {
303 GEngine->Exec(World, TEXT("r.Shadow.CSMCaching 0"));
304 }
305
307 }
308}

References CurrentWorld, GraphicsSettings, OnGraphicsSettingsChanged, and FGlobalGraphicsSettings::ShadowCSMCaching.

Referenced by SetGraphicsSettings().

◆ SetShowSpectatorRainAndSnowfall()

void UAgrarsenseSettings::SetShowSpectatorRainAndSnowfall ( bool  Show)

Set if specator rain and snowfall niagara system is enabled

Definition at line 604 of file AgrarsenseSettings.cpp.

605{
606 UWorld* World = CurrentWorld.Get();
607 if (!World)
608 {
609 return;
610 }
611
613
614 if (IsValid(Spectator))
615 {
616 Spectator->SetNiagaraComponentVisibility(Show);
618 }
619}
bool IsNiagaraComponentVisible()
Definition: Spectator.h:100
void SetNiagaraComponentVisibility(bool Visible)
Definition: Spectator.cpp:187
static ASpectator * GetSpectator(const UObject *WorldContextObject)

References CurrentWorld, UAgrarsenseStatics::GetSpectator(), ASpectator::IsNiagaraComponentVisible(), ASpectator::SetNiagaraComponentVisibility(), FGlobalSimulationSettings::ShowSpectatorRainAndSnowfall, and SimulationSettings.

Referenced by SetSimulationSettings().

◆ SetSimulationSettings()

void UAgrarsenseSettings::SetSimulationSettings ( FGlobalSimulationSettings  NewSettings)

◆ SetSpectatorMaxSpeed()

void UAgrarsenseSettings::SetSpectatorMaxSpeed ( float  MaxSpeed)

Set the max speed of the spectator pawn

Definition at line 588 of file AgrarsenseSettings.cpp.

589{
590 UWorld* World = CurrentWorld.Get();
591 if (!World)
592 {
593 return;
594 }
595
597 if (IsValid(Spectator))
598 {
599 Spectator->SetMaxSpeed(MaxSpeed);
601 }
602}
void SetMaxSpeed(float MaxSpeed=1500.0f)
Definition: Spectator.cpp:195
float GetMaxSpeed()
Definition: Spectator.cpp:204

References CurrentWorld, ASpectator::GetMaxSpeed(), UAgrarsenseStatics::GetSpectator(), ASpectator::SetMaxSpeed(), SimulationSettings, and FGlobalSimulationSettings::SpectatorMaxSpeed.

Referenced by SetSimulationSettings().

◆ SetStartWindowInitiallyMinimized()

void UAgrarsenseSettings::SetStartWindowInitiallyMinimized ( bool  Minimized)

Set should new UnrealWindow's start minimized instead of popping in front of everything.

Definition at line 396 of file AgrarsenseSettings.cpp.

397{
399}

References SimulationSettings, and FGlobalSimulationSettings::StartCameraWindowsMinimized.

Referenced by SetSimulationSettings().

◆ SetUltraQualityLevel()

void UAgrarsenseSettings::SetUltraQualityLevel ( )
private

Definition at line 886 of file AgrarsenseSettings.cpp.

887{
888 UWorld* World = CurrentWorld.Get();
889 if (!World || !GEngine)
890 {
891 return;
892 }
893
895
896 // https://dev.epicgames.com/documentation/en-us/unreal-engine/scalability-reference-for-unreal-engine?application_version=5.3
897 GEngine->Exec(World, TEXT("sg.PostProcessQuality 3"));
898 GEngine->Exec(World, TEXT("sg.ShadowQuality 3"));
899 GEngine->Exec(World, TEXT("sg.TextureQuality 4"));
900 GEngine->Exec(World, TEXT("sg.EffectsQuality 4"));
901 GEngine->Exec(World, TEXT("sg.FoliageQuality 4"));
902
903 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.03"));
904 GEngine->Exec(World, TEXT("r.SeparateTranslucency 1"));
905 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 2"));
906 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 1"));
907 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 64"));
908 GEngine->Exec(World, TEXT("r.MaxAnisotropy 8"));
909 GEngine->Exec(World, TEXT("r.LensFlareQuality 2"));
910 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 1"));
911 GEngine->Exec(World, TEXT("r.FastBlurThreshold 7"));
912 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
913 GEngine->Exec(World, TEXT("r.ShadowQuality 5"));
914 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 1"));
915 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 2"));
916 GEngine->Exec(World, TEXT("r.DetailMode 2"));
917 GEngine->Exec(World, TEXT("foliage.DensityScale 1"));
918 GEngine->Exec(World, TEXT("grass.DensityScale 1"));
919 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
920 GEngine->Exec(World, TEXT("r.Shadow.RadiusThreshold 0.00"));
921
922 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Auto);
923}

References CurrentWorld, DisableRaytracing(), and SetShadowCacheInvalidationBehavior().

Referenced by SetQualityLevel(), and SetUltraWithRaytracingLevel().

◆ SetUltraWithRaytracingLevel()

void UAgrarsenseSettings::SetUltraWithRaytracingLevel ( )
private

Definition at line 811 of file AgrarsenseSettings.cpp.

812{
814 {
817 }
818 else
819 {
820 SimulatorLog::Log("Graphics settings: Ray tracing not supported on this hardware.");
821 }
822}
bool IsRaytracingSupported() const

References EnableRaytracing(), IsRaytracingSupported(), SimulatorLog::Log(), and SetUltraQualityLevel().

Referenced by SetQualityLevel().

◆ Setup()

void UAgrarsenseSettings::Setup ( UWorld *  World)

Setup the settings with the new world, and apply settings.

Parameters
World

Definition at line 45 of file AgrarsenseSettings.cpp.

46{
47#if WITH_EDITOR
48 // In case the simulator was shutdown when it was paused,
49 // reset this static variable
51#endif
52
53 CurrentWorld = World;
54
55 UWorld* GameWorld = CurrentWorld.Get();
56
57 CurrentMapName = GameWorld->GetMapName().ToLower();
58 IsMainMenu = CurrentMapName.Contains("mainmenu");
59
60 if (GameWorld)
61 {
62 // Prioritize grass creation
63 // This allows turning grass on faster if it was turned off.
64 ULandscapeSubsystem* LandscapeSubsystem = CurrentWorld->GetSubsystem<ULandscapeSubsystem>();
65 if (LandscapeSubsystem)
66 {
67 LandscapeSubsystem->PrioritizeGrassCreation(true);
68 }
69 }
70
71 // Apply Graphics and Simulation settings when Simulator is started
72 ApplySettings(true);
73
74 // Apply few console commands. One time setup.
75 if (GEngine && World)
76 {
77 // Set OptimizedWPO to 1 to allow disabling WPO runtime for foliage (see InstancedRenderer.cpp)
78 GEngine->Exec(World, TEXT("r.OptimizedWPO 1"));
79
80 GEngine->Exec(World, TEXT("g.TimeoutForBlockOnRenderFence 600000"));
81 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0"));
82 GEngine->Exec(World, TEXT("r.CustomDepth 0"));
83
84 // Disable application starting to throttle performance if Window loses focus
85 GEngine->Exec(World, TEXT("t.IdleWhenNotForeground 0"));
86 }
87
89 if (Manager)
90 {
91 Manager->OnSensorSpawned.AddUniqueDynamic(this, &UAgrarsenseSettings::OnSensorSpawned);
92 Manager->OnSensorDestroyed.AddUniqueDynamic(this, &UAgrarsenseSettings::OnSensorDestroyed);
93 }
94 else
95 {
96 // Else failed to get SensorManager and listen Sensor spawning, always render custom depth
97 RenderCustomDepth = true;
98 }
99
100#if UE_BUILD_SHIPPING
101 // In Shipping mode check for Fullscreen and WindowedFullscreen launch args,
102 // Otherwise set window to windowed by default.
103 if (FParse::Param(FCommandLine::Get(), TEXT("Fullscreen")))
104 {
105 SetWindowMode(EWindowMode::Type::Fullscreen);
106 }
107 else if (FParse::Param(FCommandLine::Get(), TEXT("WindowedFullscreen")))
108 {
109 SetWindowMode(EWindowMode::Type::WindowedFullscreen);
110 }
111 else
112 {
113 SetWindowMode(EWindowMode::Type::Windowed);
114 }
115#endif
116}
void OnSensorSpawned(ASensor *SensorPtr)
static FString CurrentMapName
void SetWindowMode(EWindowMode::Type WindowType)
void OnSensorDestroyed(ASensor *SensorPtr)
static USensorManager * Get()
FSensorDestroyedDelegate OnSensorDestroyed
Definition: SensorManager.h:68
FSensorSpawnedDelegate OnSensorSpawned
Definition: SensorManager.h:61

References ApplySettings(), CurrentMapName, CurrentWorld, USensorManager::Get(), IsMainMenu, FGlobalSimulationSettings::IsSimulationPaused, USensorManager::OnSensorDestroyed, OnSensorDestroyed(), USensorManager::OnSensorSpawned, OnSensorSpawned(), RenderCustomDepth, SetWindowMode(), and SimulationSettings.

Referenced by AAgrarsenseGameModeBase::SpawnNeededActorsInitGame().

◆ SetUseVirtualShadowMaps()

void UAgrarsenseSettings::SetUseVirtualShadowMaps ( bool  UseVirtualShadowMaps)

Set should virtual shadow maps be used, otherwise regular shadow maps are used.

Definition at line 418 of file AgrarsenseSettings.cpp.

419{
420 UWorld* World = CurrentWorld.Get();
421 if (GEngine || World)
422 {
423 GraphicsSettings.UseVirtualShadowMaps = UseVirtualShadowMaps;
424
426 {
427 GEngine->Exec(World, TEXT("r.Shadow.Virtual.Enable 1"));
428 }
429 else
430 {
431 GEngine->Exec(World, TEXT("r.Shadow.Virtual.Enable 0"));
432 }
433
435 }
436}

References CurrentWorld, GraphicsSettings, OnGraphicsSettingsChanged, and FGlobalGraphicsSettings::UseVirtualShadowMaps.

Referenced by SetGraphicsSettings().

◆ SetWindowMode()

void UAgrarsenseSettings::SetWindowMode ( EWindowMode::Type  WindowType)

Set Main unreal window type

Definition at line 223 of file AgrarsenseSettings.cpp.

224{
225 if (GEngine)
226 {
227 UGameUserSettings* UserSettings = GEngine->GetGameUserSettings();
228 if (UserSettings)
229 {
230 UserSettings->SetFullscreenMode(WindowType);
231 UserSettings->ApplySettings(false);
232 }
233 }
234}

Referenced by Setup().

◆ SetWorldPositionOffsetRenderDistance()

void UAgrarsenseSettings::SetWorldPositionOffsetRenderDistance ( int32  WorldPositionOffsetDistance)

◆ SetWorldRendering()

void UAgrarsenseSettings::SetWorldRendering ( bool  enabled)

Set main Unreal window world rendering on or off. Doesn't stop rendering UI elements.

Parameters
enabledboolean to set rendering on or off

Definition at line 501 of file AgrarsenseSettings.cpp.

502{
503 if (GEngine && GEngine->GameViewport)
504 {
505 GEngine->GameViewport->bDisableWorldRendering = !enabled;
507
508 FString msg = FString::Printf(TEXT("World rendering: %s"), enabled ? TEXT("On") : TEXT("Off"));
510
512 }
513}

References FGlobalGraphicsSettings::DisableSpectatorRendering, GraphicsSettings, SimulatorLog::Log(), and OnGraphicsSettingsChanged.

Referenced by UROSCommands::HandleSetWorldRendering(), and SetGraphicsSettings().

◆ ShouldStartWindowMinimized()

static bool UAgrarsenseSettings::ShouldStartWindowMinimized ( )
inlinestatic

Static method to determine whether the Unreal window should start in a minimized state. Called by UnrealWindow.cpp.

Returns
true if the Unreal window should start minimized, false otherwise.

Definition at line 396 of file AgrarsenseSettings.h.

Referenced by FUnrealWindow::FUnrealWindow().

◆ UnPauseSimulation()

void UAgrarsenseSettings::UnPauseSimulation ( )

Unpause the simulator immediately.

Definition at line 634 of file AgrarsenseSettings.cpp.

635{
636 UWorld* World = CurrentWorld.Get();
638 {
639 UGameplayStatics::SetGlobalTimeDilation(World, SimulationSettings.TimeDilation);
640 UGameplayStatics::SetGamePaused(World, false);
642
643 SimulatorLog::Log("Simulator unpaused");
644 }
645}

References CurrentWorld, FGlobalSimulationSettings::IsSimulationPaused, SimulatorLog::Log(), SimulationSettings, and FGlobalSimulationSettings::TimeDilation.

Referenced by AdvanceFrameCount(), AdvanceTime(), and UROSCommands::HandleUnPauseSimulator().

Friends And Related Function Documentation

◆ AAgrarsenseGameModeBase

friend class AAgrarsenseGameModeBase
friend

Definition at line 440 of file AgrarsenseSettings.h.

Member Data Documentation

◆ AdvanceFramesHandle

FDelegateHandle UAgrarsenseSettings::AdvanceFramesHandle
private

Definition at line 480 of file AgrarsenseSettings.h.

Referenced by AdvanceFrameCount().

◆ CurrentMapName

FString UAgrarsenseSettings::CurrentMapName
staticprivate

Definition at line 512 of file AgrarsenseSettings.h.

Referenced by Setup().

◆ CurrentWorld

TWeakObjectPtr<UWorld> UAgrarsenseSettings::CurrentWorld = nullptr
private

◆ EndOfFrameHandle

FDelegateHandle UAgrarsenseSettings::EndOfFrameHandle
private

Definition at line 484 of file AgrarsenseSettings.h.

Referenced by AdvanceFrameCount(), and PauseSimulationEndOfThisFrame().

◆ FrameCount

int32 UAgrarsenseSettings::FrameCount = 0
private

Definition at line 481 of file AgrarsenseSettings.h.

Referenced by AdvanceFrameCount().

◆ GraphicsSettings

FGlobalGraphicsSettings UAgrarsenseSettings::GraphicsSettings
private

◆ IsMainMenu

bool UAgrarsenseSettings::IsMainMenu = false
staticprivate

Definition at line 511 of file AgrarsenseSettings.h.

Referenced by Setup().

◆ MapNames

const TArray<FString> UAgrarsenseSettings::MapNames
private
Initial value:
=
{
"mainmenu",
"rovaniemiforest",
"vindeln",
"sensorshowcase",
"playground"
}

Definition at line 492 of file AgrarsenseSettings.h.

Referenced by ChangeMapByName().

◆ MapPaths

const TArray<FString> UAgrarsenseSettings::MapPaths
private
Initial value:
=
{
"/Game/Agrarsense/Maps/MainMenu",
"/Game/Agrarsense/Maps/RovaniemiForest/RovaniemiForest",
"/Game/Agrarsense/Maps/Vindeln/Vindeln",
"/Game/Agrarsense/Maps/SensorShowCase/SensorShowCase",
"/Game/Agrarsense/Maps/Playground"
}

Definition at line 502 of file AgrarsenseSettings.h.

Referenced by ChangeMapByName().

◆ NumberOfPostProcessingSensors

int UAgrarsenseSettings::NumberOfPostProcessingSensors = 0
private

Definition at line 466 of file AgrarsenseSettings.h.

Referenced by OnSensorDestroyed(), and OnSensorSpawned().

◆ OnGraphicsSettingsChanged

FGraphicsSettingsDelegate UAgrarsenseSettings::OnGraphicsSettingsChanged

◆ RenderCustomDepth

bool UAgrarsenseSettings::RenderCustomDepth = false
private

◆ SimulationSettings

FGlobalSimulationSettings UAgrarsenseSettings::SimulationSettings
private

The documentation for this class was generated from the following files: