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 668 of file AgrarsenseSettings.cpp.

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

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

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

Referenced by UROSCommands::HandleAdvanceTime().

◆ ApplySettings()

void UAgrarsenseSettings::ApplySettings ( bool  bCheckForCommandLineOverrides)
override

Definition at line 137 of file AgrarsenseSettings.cpp.

138{
139 Super::ApplySettings(bCheckForCommandLineOverrides);
140
143}
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 763 of file AgrarsenseSettings.cpp.

764{
765 UWorld* World = CurrentWorld.Get();
766 if (World)
767 {
768 UGameplayStatics::OpenLevel(World, *Path, TRAVEL_Absolute);
769 }
770}

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 736 of file AgrarsenseSettings.cpp.

737{
738 // Make the map name to lower
739 // This is because ROSCommands.cpp uses this and all the messages are in lower case.
740 MapName = MapName.ToLower();
741
742 bool FoundMap = false;
743 for (int32 i = 0; i < MapNames.Num(); i++)
744 {
745 if (MapName == MapNames[i])
746 {
747 FoundMap = true;
748 FString msg = FString::Printf(TEXT("Changing map to: %s"), *MapName);
750
752 break;
753 }
754 }
755
756 if (!FoundMap)
757 {
758 FString msg = FString::Printf(TEXT("Couldn't find map: %s"), *MapName);
760 }
761}
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 865 of file AgrarsenseSettings.cpp.

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

References CurrentWorld.

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

◆ EnableRaytracing()

void UAgrarsenseSettings::EnableRaytracing ( )
private

Definition at line 847 of file AgrarsenseSettings.cpp.

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

References CurrentWorld.

Referenced by SetUltraWithRaytracingLevel().

◆ GetAgrarsenseSettings()

UAgrarsenseSettings * UAgrarsenseSettings::GetAgrarsenseSettings ( )
static

Definition at line 127 of file AgrarsenseSettings.cpp.

128{
129 return Cast<UAgrarsenseSettings>(UGameUserSettings::GetGameUserSettings());
130}

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

◆ GetAntiAliasingMethod()

EAntiAliasing UAgrarsenseSettings::GetAntiAliasingMethod ( ) const

Get current anti aliasing method

Returns

Definition at line 445 of file AgrarsenseSettings.cpp.

446{
448}

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 194 of file AgrarsenseSettings.cpp.

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

◆ 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 547 of file AgrarsenseSettings.cpp.

548{
549 return GetFrameRateLimit();
550}

◆ GetGlobalTimeDilation()

float UAgrarsenseSettings::GetGlobalTimeDilation ( ) const

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

Returns
float TimeDilation

Definition at line 558 of file AgrarsenseSettings.cpp.

559{
560 UWorld* World = CurrentWorld.Get();
561
562 if (!World)
563 {
565 }
566
567 return UGameplayStatics::GetGlobalTimeDilation(World);
568}

References CurrentWorld, SimulationSettings, and FGlobalSimulationSettings::TimeDilation.

◆ GetGrassVisibility()

bool UAgrarsenseSettings::GetGrassVisibility ( ) const

Get if grass visible or not

Returns
Grass visibility

Definition at line 243 of file AgrarsenseSettings.cpp.

References GraphicsSettings, and FGlobalGraphicsSettings::RenderGrass.

◆ GetIsRenderingCustomDepthPass()

bool UAgrarsenseSettings::GetIsRenderingCustomDepthPass ( ) const

Get is rendering custom depth pass on.

Definition at line 440 of file AgrarsenseSettings.cpp.

441{
442 return RenderCustomDepth;
443}

References RenderCustomDepth.

◆ GetIsUsingVirtualShadowMaps()

bool UAgrarsenseSettings::GetIsUsingVirtualShadowMaps ( ) const

Get is rendering virtual shadow maps on.

Definition at line 435 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 189 of file AgrarsenseSettings.cpp.

190{
191 return FPlatformMisc::NumberOfWorkerThreadsToSpawn();
192}

◆ GetShadowCacheInvalidationBehavior()

EShadowCacheInvalidationBehavior UAgrarsenseSettings::GetShadowCacheInvalidationBehavior ( ) const

◆ GetShadowCSMCache()

bool UAgrarsenseSettings::GetShadowCSMCache ( ) const

Get Shadow CSM cache

Returns
Shadow CSM cache on/off

Definition at line 277 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 388 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 821 of file AgrarsenseSettings.cpp.

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

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 132 of file AgrarsenseSettings.cpp.

133{
134 Super::LoadSettings(bForceReload);
135}

◆ OnSensorDestroyed()

void UAgrarsenseSettings::OnSensorDestroyed ( ASensor SensorPtr)
private

Definition at line 788 of file AgrarsenseSettings.cpp.

789{
790 if (!SensorPtr)
791 {
792 return;
793 }
794
795 ESensorTypes type = SensorPtr->GetSensorType();
797 {
800 {
801 // If there's no more sensors that need CustomDepthPass to work,
802 // disable it to save rendering performance
804 }
805 }
806}
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 772 of file AgrarsenseSettings.cpp.

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

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

Referenced by Setup().

◆ ParseLaunchArguments()

bool UAgrarsenseSettings::ParseLaunchArguments ( )
private

Definition at line 145 of file AgrarsenseSettings.cpp.

146{
147 bool SettingsWereChanged = false;
148
149 // Check -map= launch argument
150 FString AntiAliasingString;
151 if (FParse::Value(FCommandLine::Get(), TEXT("-antialiasing="), AntiAliasingString))
152 {
153 // Convert incoming string to int and then EAntiAliasing enum
154 int32 AntiAliasingInt;
155 if (AntiAliasingString.IsNumeric())
156 {
157 AntiAliasingInt = FCString::Atoi(*AntiAliasingString);
158 EAntiAliasing NewAntiAliasingMethod = static_cast<EAntiAliasing>(AntiAliasingInt);
159 GraphicsSettings.AntiAliasingMethod = NewAntiAliasingMethod;
160 SettingsWereChanged = true;
161 }
162 }
163
164 // Check -no-world-rendering launch argument
165 if (FParse::Param(FCommandLine::Get(), TEXT("-no-spectator-rendering")))
166 {
168 SettingsWereChanged = true;
169 }
170
171 // Check -start-camerawindows-minimized launch argument
172 if (FParse::Param(FCommandLine::Get(), TEXT("-start-camerawindows-minimized")))
173 {
175 SettingsWereChanged = true;
176 }
177
178 // Check -quality-level= launch argument
179 FString QualityLevelString;
180 if (FParse::Value(FCommandLine::Get(), TEXT("-quality-level="), QualityLevelString))
181 {
183 SettingsWereChanged = true;
184 }
185
186 return SettingsWereChanged;
187}
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 618 of file AgrarsenseSettings.cpp.

619{
620 UWorld* World = CurrentWorld.Get();
622 {
623 UGameplayStatics::SetGlobalTimeDilation(World, 0.0f);
624 UGameplayStatics::SetGamePaused(World, true);
626
627 SimulatorLog::Log("Simulator paused");
628 }
629}

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 644 of file AgrarsenseSettings.cpp.

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

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

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

◆ PostInitProperties()

void UAgrarsenseSettings::PostInitProperties ( )
overridevirtual

Definition at line 115 of file AgrarsenseSettings.cpp.

116{
117 Super::PostInitProperties();
118
119#if UE_BUILD_SHIPPING || UE_BUILD_DEVELOPMENT
121 {
122 SaveConfig();
123 }
124#endif
125}

References ParseLaunchArguments().

◆ SetAntiAliasingMethod()

void UAgrarsenseSettings::SetAntiAliasingMethod ( EAntiAliasing  AntiAliasingMethod)

Override anti aliasing method. Default TAA.

Parameters
AntiAliasingMethod

Definition at line 450 of file AgrarsenseSettings.cpp.

451{
452
453 UWorld* World = CurrentWorld.Get();
454
455 if (!GEngine || !World)
456 {
457 return;
458 }
459
460 GraphicsSettings.AntiAliasingMethod = AntiAliasingMethod;
461
462 FString ExecCommand;
463 switch (AntiAliasingMethod)
464 {
466 ExecCommand = TEXT("r.AntiAliasingMethod 0");
467 break;
468
470 ExecCommand = TEXT("r.AntiAliasingMethod 1");
471 break;
472
474 ExecCommand = TEXT("r.AntiAliasingMethod 2");
475 break;
476
477 // MSAA ("r.AntiAliasingMethod 3) is not supported on Deferred rendering
478
480 ExecCommand = TEXT("r.AntiAliasingMethod 4");
481 break;
482
483 default:
484 return;
485 }
486
487 GEngine->Exec(World, *ExecCommand);
488
490}
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 492 of file AgrarsenseSettings.cpp.

493{
494 EAntiAliasing NewMethod = UEnumUtilities::ConvertStringToAntiAliasingMethod(AntiAliasingMethodString);
495 SetAntiAliasingMethod(NewMethod);
496}
void SetAntiAliasingMethod(EAntiAliasing AntiAliasingMethod)
static EAntiAliasing ConvertStringToAntiAliasingMethod(const FString &String)

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

◆ SetBalancedQualityLevel()

void UAgrarsenseSettings::SetBalancedQualityLevel ( )
private

Definition at line 922 of file AgrarsenseSettings.cpp.

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

553{
554 SetFrameRateLimit(NewTargetFrameRate);
555 ApplySettings(false);
556}
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 570 of file AgrarsenseSettings.cpp.

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

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 208 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 248 of file AgrarsenseSettings.cpp.

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

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 307 of file AgrarsenseSettings.cpp.

308{
309 UWorld* World = CurrentWorld.Get();
310
311 if (World)
312 {
314 if (InstanceRenderer)
315 {
316 InstanceRenderer->SetInstancedRendering(Visible);
317 }
318 }
319}
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 960 of file AgrarsenseSettings.cpp.

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

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

Referenced by SetQualityLevel().

◆ SetNaniteMaxPixelsPerEdge()

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

Definition at line 327 of file AgrarsenseSettings.cpp.

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

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 512 of file AgrarsenseSettings.cpp.

513{
514 GraphicsSettings.QualityLevel = newQualityLevel;
515
517 {
520 break;
521
524 break;
525
528 break;
529
532 break;
533 }
534
536 FString Msg = FString::Printf(TEXT("Graphics settings: %s"), *QualityLevelString);
538
540}
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 542 of file AgrarsenseSettings.cpp.

543{
545}

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 398 of file AgrarsenseSettings.cpp.

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

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 351 of file AgrarsenseSettings.cpp.

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

References SetShadowCacheInvalidationBehavior().

◆ SetShadowCSMCache()

void UAgrarsenseSettings::SetShadowCSMCache ( bool  CacheShadowCSM)

Definition at line 282 of file AgrarsenseSettings.cpp.

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

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 601 of file AgrarsenseSettings.cpp.

602{
603 UWorld* World = CurrentWorld.Get();
604 if (!World)
605 {
606 return;
607 }
608
610
611 if (IsValid(Spectator))
612 {
613 Spectator->SetNiagaraComponentVisibility(Show);
615 }
616}
bool IsNiagaraComponentVisible()
Definition: Spectator.h:93
void SetNiagaraComponentVisibility(bool Visible)
Definition: Spectator.cpp:183
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 585 of file AgrarsenseSettings.cpp.

586{
587 UWorld* World = CurrentWorld.Get();
588 if (!World)
589 {
590 return;
591 }
592
594 if (IsValid(Spectator))
595 {
596 Spectator->SetMaxSpeed(MaxSpeed);
598 }
599}
void SetMaxSpeed(float MaxSpeed=1500.0f)
Definition: Spectator.cpp:191
float GetMaxSpeed()
Definition: Spectator.cpp:200

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 393 of file AgrarsenseSettings.cpp.

394{
396}

References SimulationSettings, and FGlobalSimulationSettings::StartCameraWindowsMinimized.

Referenced by SetSimulationSettings().

◆ SetUltraQualityLevel()

void UAgrarsenseSettings::SetUltraQualityLevel ( )
private

Definition at line 883 of file AgrarsenseSettings.cpp.

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

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

Referenced by SetQualityLevel(), and SetUltraWithRaytracingLevel().

◆ SetUltraWithRaytracingLevel()

void UAgrarsenseSettings::SetUltraWithRaytracingLevel ( )
private

Definition at line 808 of file AgrarsenseSettings.cpp.

809{
811 {
814 }
815 else
816 {
817 SimulatorLog::Log("Graphics settings: Ray tracing not supported on this hardware.");
818 }
819}
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
86 if (Manager)
87 {
88 Manager->OnSensorSpawned.AddUniqueDynamic(this, &UAgrarsenseSettings::OnSensorSpawned);
89 Manager->OnSensorDestroyed.AddUniqueDynamic(this, &UAgrarsenseSettings::OnSensorDestroyed);
90 }
91 else
92 {
93 // Else failed to get SensorManager and listen Sensor spawning, always render custom depth
94 RenderCustomDepth = true;
95 }
96
97#if UE_BUILD_SHIPPING
98 // In Shipping mode check for Fullscreen and WindowedFullscreen launch args,
99 // Otherwise set window to windowed by default.
100 if (FParse::Param(FCommandLine::Get(), TEXT("Fullscreen")))
101 {
102 SetWindowMode(EWindowMode::Type::Fullscreen);
103 }
104 else if (FParse::Param(FCommandLine::Get(), TEXT("WindowedFullscreen")))
105 {
106 SetWindowMode(EWindowMode::Type::WindowedFullscreen);
107 }
108 else
109 {
110 SetWindowMode(EWindowMode::Type::Windowed);
111 }
112#endif
113}
void OnSensorSpawned(ASensor *SensorPtr)
static FString CurrentMapName
void SetWindowMode(EWindowMode::Type WindowType)
void OnSensorDestroyed(ASensor *SensorPtr)
static USensorManager * Get()
FSensorDestroyedDelegate OnSensorDestroyed
Definition: SensorManager.h:58
FSensorSpawnedDelegate OnSensorSpawned
Definition: SensorManager.h:51

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 415 of file AgrarsenseSettings.cpp.

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

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 220 of file AgrarsenseSettings.cpp.

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

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 498 of file AgrarsenseSettings.cpp.

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

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 631 of file AgrarsenseSettings.cpp.

632{
633 UWorld* World = CurrentWorld.Get();
635 {
636 UGameplayStatics::SetGlobalTimeDilation(World, SimulationSettings.TimeDilation);
637 UGameplayStatics::SetGamePaused(World, false);
639
640 SimulatorLog::Log("Simulator unpaused");
641 }
642}

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: