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 SetWindowMode (EWindowMode::Type WindowType)
 
void SetSimulationSettings (FGlobalSimulationSettings NewSettings)
 
void SetWorldRendering (bool enabled)
 
void SetQualityLevel (EQualityLevel newQualityLevel)
 
void SetQualityLevelFromString (const FString &QualityLevelString)
 
int32 GetGlobalTargetFrameRate () const
 
void SetGlobalTargetFrameRate (int32 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
 
bool IsRaytracingSupported () 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 ()
 
void SetGraphicsSettings (FGlobalGraphicsSettings NewSettings)
 
bool ParseLaunchArguments ()
 
void SetUltraWithRaytracingLevel ()
 
void EnableRaytracing ()
 
void DisableRaytracing ()
 
void SetUltraQualityLevel ()
 
void SetBalancedQualityLevel ()
 
void SetLowQualityLevel ()
 

Private Attributes

bool RenderCustomDepth = true
 
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 37 of file AgrarsenseSettings.cpp.

38{
39}

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

653{
654 if (FramesToAdvance == 0)
655 {
656 return;
657 }
658
659 if (AdvanceFramesHandle.IsValid())
660 {
661 // Already running this, return
662 return;
663 }
664
665 if (EndOfFrameHandle.IsValid())
666 {
667 // If PauseSimulationEndOfThisFrame was called, unsubribe
668 FCoreDelegates::OnEndFrame.Remove(EndOfFrameHandle);
669 EndOfFrameHandle.Reset();
670 }
671
672 // Unpause simulation now
674
675 FrameCount = 0;
676
677 // Subscribe to Unreal Engine end of frame callback
678 AdvanceFramesHandle = FCoreDelegates::OnEndFrame.AddLambda([this, FramesToAdvance]()
679 {
680 ++FrameCount;
681 if (FrameCount == FramesToAdvance)
682 {
683 // After given number of frames,
684 // unsubscribe from the event and pause simulation again at the end of that frame
685 if (IsValid(this))
686 {
687 FCoreDelegates::OnEndFrame.Remove(AdvanceFramesHandle);
688 AdvanceFramesHandle.Reset();
689 FrameCount = 0;
690
692 }
693 }
694 });
695}
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 697 of file AgrarsenseSettings.cpp.

698{
699 UWorld* World = CurrentWorld.Get();
700 if (!World)
701 {
702 return;
703 }
704
705 // Unpause simulation now
707
708 // Pause simulation again after TimeToAdvance
709 FTimerHandle AdvanceTimeTimer;
710 World->GetTimerManager().SetTimer(AdvanceTimeTimer, FTimerDelegate::CreateLambda([this]
711 {
712 if (IsValid(this))
713 {
715 }
716
717 }), TimeToAdvance, false);
718}
TWeakObjectPtr< UWorld > CurrentWorld

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

Referenced by UROSCommands::HandleAdvanceTime().

◆ ApplySettings()

void UAgrarsenseSettings::ApplySettings ( bool  bCheckForCommandLineOverrides)
override

Definition at line 120 of file AgrarsenseSettings.cpp.

121{
122 Super::ApplySettings(bCheckForCommandLineOverrides);
123
126}
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 747 of file AgrarsenseSettings.cpp.

748{
749 UWorld* World = CurrentWorld.Get();
750 if (World)
751 {
752 UGameplayStatics::OpenLevel(World, *Path, TRAVEL_Absolute);
753 }
754}

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

721{
722 // Make the map name to lower
723 // This is because ROSCommands.cpp uses this and all the messages are in lower case.
724 MapName = MapName.ToLower();
725
726 bool FoundMap = false;
727 for (int32 i = 0; i < MapNames.Num(); i++)
728 {
729 if (MapName == MapNames[i])
730 {
731 FoundMap = true;
732 FString msg = FString::Printf(TEXT("Changing map to: %s"), *MapName);
734
736 break;
737 }
738 }
739
740 if (!FoundMap)
741 {
742 FString msg = FString::Printf(TEXT("Couldn't find map: %s"), *MapName);
744 }
745}
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 825 of file AgrarsenseSettings.cpp.

826{
827 UWorld* World = CurrentWorld.Get();
828 if (!World || !GEngine)
829 {
830 return;
831 }
832
833#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION == 6)
834 GEngine->Exec(World, TEXT("r.RayTracing.Geometry.NaniteProxies.WPO 1"));
835#endif
836
837 GEngine->Exec(World, TEXT("r.RayTracing 0"));
838 GEngine->Exec(World, TEXT("r.RayTracing.Denoiser 0"));
839 GEngine->Exec(World, TEXT("r.Lumen.HardwareRayTracing 0"));
840 GEngine->Exec(World, TEXT("r.RayTracing.Geometry 0"));
841 GEngine->Exec(World, TEXT("r.RayTracing.Reflections 0"));
842 GEngine->Exec(World, TEXT("r.RayTracing.AmbientOcclusion 0"));
843 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination 0"));
844 GEngine->Exec(World, TEXT("r.RayTracing.Translucency 0"));
845 GEngine->Exec(World, TEXT("r.RayTracing.SkyLight 0"));
846 GEngine->Exec(World, TEXT("r.RayTracing.Shadows 0"));
847}

References CurrentWorld.

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

◆ EnableRaytracing()

void UAgrarsenseSettings::EnableRaytracing ( )
private

Definition at line 783 of file AgrarsenseSettings.cpp.

784{
785 UWorld* World = CurrentWorld.Get();
786 if (!World || !GEngine)
787 {
788 return;
789 }
790
791
792#if (ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION == 6)
793 // Due to UE 5.6 bug where ISM nanite proxies with WPO enabled cause shadows not working properly
794 GEngine->Exec(World, TEXT("r.RayTracing.Geometry.NaniteProxies.WPO 0"));
795#endif
796
797 GEngine->Exec(World, TEXT("r.RayTracing 1"));
798 GEngine->Exec(World, TEXT("r.Lumen.HardwareRayTracing 1")); // Enable lumen raytracing
799 GEngine->Exec(World, TEXT("r.RayTracing.Geometry 1")); // Enable ray tracing geometry
800 GEngine->Exec(World, TEXT("r.RayTracing.Reflections 1")); // Enable ray tracing reflections
801 GEngine->Exec(World, TEXT("r.RayTracing.AmbientOcclusion 1")); // Enable ray tracing ambient occlusion
802 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination 1")); // Enable ray tracing global illumination
803 GEngine->Exec(World, TEXT("r.RayTracing.Translucency 1")); // Enable ray tracing translucency
804 GEngine->Exec(World, TEXT("r.RayTracing.SkyLight 1")); // Enable ray tracing sky light
805
806 // Couldn't get Nanite trees with WPO to work with Raytracing
807 //GEngine->Exec(World, TEXT("r.RayTracing.Shadows 1")); // Enable ray tracing shadows
808 //GEngine->Exec(World, TEXT("r.RayTracing.Shadows.SoftShadows 1"));
809 //GEngine->Exec(World, TEXT("r.RayTracing.Shadows.SamplesPerPixel 4"));
810
811 GEngine->Exec(World, TEXT("r.RayTracing.Reflections.MaxRoughness 1.0")); // Enable reflections on all surfaces
812 GEngine->Exec(World, TEXT("r.RayTracing.Reflections.Shadows 1")); // Enable ray-traced shadows in reflections
813 GEngine->Exec(World, TEXT("r.RayTracing.Reflections.SortTiles 1")); // Optimized tile sorting for performance
814 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination.Quality 4")); // Increase RT GI quality (0-4)
815 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination.SamplesPerPixel 4")); // Improve GI smoothness
816
817 GEngine->Exec(World, TEXT("r.Lumen.Reflections 1")); // Enable Lumen reflections
818 GEngine->Exec(World, TEXT("r.Lumen.ScreenProbeGather.ScreenTraces 1")); // Improve Lumen probe accuracy
819
820 GEngine->Exec(World, TEXT("r.RayTracing.Denoiser 1")); // Enable denoiser
821 GEngine->Exec(World, TEXT("r.RayTracing.Denoiser.TemporalAccumulation 1")); // Temporal stability
822 GEngine->Exec(World, TEXT("r.RayTracing.Denoiser.ReuseRadiance 1")); // Improves light reuse
823}

References CurrentWorld.

Referenced by SetUltraWithRaytracingLevel().

◆ GetAgrarsenseSettings()

UAgrarsenseSettings * UAgrarsenseSettings::GetAgrarsenseSettings ( )
static

Definition at line 110 of file AgrarsenseSettings.cpp.

111{
112 return Cast<UAgrarsenseSettings>(UGameUserSettings::GetGameUserSettings());
113}

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

◆ GetAntiAliasingMethod()

EAntiAliasing UAgrarsenseSettings::GetAntiAliasingMethod ( ) const

Get current anti aliasing method

Returns

Definition at line 429 of file AgrarsenseSettings.cpp.

430{
432}

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

178{
179 IConsoleVariable* ConsoleVariable = IConsoleManager::Get().FindConsoleVariable(*VariableName);
180 if (ConsoleVariable)
181 {
182 FString VariableValue = ConsoleVariable->GetString();
183 return VariableValue;
184 }
185 else
186 {
187 return FString();
188 }
189}

◆ GetCurrentQualityLevel()

EQualityLevel UAgrarsenseSettings::GetCurrentQualityLevel ( ) const
inline

Get current graphics quality level

Returns
EQualityLevel enum

Definition at line 354 of file AgrarsenseSettings.h.

355 {
357 }

◆ GetGlobalGraphicsSettings()

static FGlobalGraphicsSettings UAgrarsenseSettings::GetGlobalGraphicsSettings ( )
inlinestatic

Get Global Graphics settings.

Definition at line 426 of file AgrarsenseSettings.h.

427 {
429 }
static UAgrarsenseSettings * GetAgrarsenseSettings()

◆ GetGlobalSimulationSettings()

static FGlobalSimulationSettings UAgrarsenseSettings::GetGlobalSimulationSettings ( )
inlinestatic

Get Global simulation settings.

Definition at line 408 of file AgrarsenseSettings.h.

409 {
411 }

◆ GetGlobalTargetFrameRate()

int32 UAgrarsenseSettings::GetGlobalTargetFrameRate ( ) const

Get the global target frame rate for the Simulator

Returns
int32 TargetFrameRate

Definition at line 531 of file AgrarsenseSettings.cpp.

532{
533 return GetFrameRateLimit();
534}

◆ GetGlobalTimeDilation()

float UAgrarsenseSettings::GetGlobalTimeDilation ( ) const

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

Returns
float TimeDilation

Definition at line 542 of file AgrarsenseSettings.cpp.

543{
544 UWorld* World = CurrentWorld.Get();
545
546 if (!World)
547 {
549 }
550
551 return UGameplayStatics::GetGlobalTimeDilation(World);
552}

References CurrentWorld, SimulationSettings, and FGlobalSimulationSettings::TimeDilation.

◆ GetGrassVisibility()

bool UAgrarsenseSettings::GetGrassVisibility ( ) const

Get if grass visible or not

Returns
Grass visibility

Definition at line 226 of file AgrarsenseSettings.cpp.

References GraphicsSettings, and FGlobalGraphicsSettings::RenderGrass.

◆ GetIsRenderingCustomDepthPass()

bool UAgrarsenseSettings::GetIsRenderingCustomDepthPass ( ) const

Get is rendering custom depth pass on.

Definition at line 424 of file AgrarsenseSettings.cpp.

425{
426 return RenderCustomDepth;
427}

References RenderCustomDepth.

◆ GetIsUsingVirtualShadowMaps()

bool UAgrarsenseSettings::GetIsUsingVirtualShadowMaps ( ) const

Get is rendering virtual shadow maps on.

Definition at line 419 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 364 of file AgrarsenseSettings.h.

365 {
366 return MapNames;
367 }

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 374 of file AgrarsenseSettings.h.

375 {
376 return MapPaths;
377 }

◆ GetNaniteMaxPixelsPerEdge()

float UAgrarsenseSettings::GetNaniteMaxPixelsPerEdge ( ) const

◆ GetNumberOfWorkerThreads()

int32 UAgrarsenseSettings::GetNumberOfWorkerThreads ( ) const

Returns the number of worker threads used by the Simulator.

Definition at line 172 of file AgrarsenseSettings.cpp.

173{
174 return FPlatformMisc::NumberOfWorkerThreadsToSpawn();
175}

◆ GetShadowCacheInvalidationBehavior()

EShadowCacheInvalidationBehavior UAgrarsenseSettings::GetShadowCacheInvalidationBehavior ( ) const

◆ GetShadowCSMCache()

bool UAgrarsenseSettings::GetShadowCSMCache ( ) const

Get Shadow CSM cache

Returns
Shadow CSM cache on/off

Definition at line 260 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 135 of file AgrarsenseSettings.h.

◆ GetSpectatorMaxSpeed()

float UAgrarsenseSettings::GetSpectatorMaxSpeed ( ) const
inline

Get the max of the spectator pawn

Returns
Current max speed

Definition at line 125 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 371 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 399 of file AgrarsenseSettings.h.

400 {
401 return IsMainMenu;
402 }

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

◆ IsRaytracingSupported()

bool UAgrarsenseSettings::IsRaytracingSupported ( ) const

Definition at line 769 of file AgrarsenseSettings.cpp.

770{
771 bool RayTracingSupported = false;
772
773 // Check if the hardware supports ray tracing
774 IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing"));
775 if (CVar && CVar->GetInt() > 0 && GRHISupportsRayTracing)
776 {
777 RayTracingSupported = true;
778 }
779
780 return RayTracingSupported;
781}

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

116{
117 Super::LoadSettings(bForceReload);
118}

◆ ParseLaunchArguments()

bool UAgrarsenseSettings::ParseLaunchArguments ( )
private

Definition at line 128 of file AgrarsenseSettings.cpp.

129{
130 bool SettingsWereChanged = false;
131
132 // Check -map= launch argument
133 FString AntiAliasingString;
134 if (FParse::Value(FCommandLine::Get(), TEXT("-antialiasing="), AntiAliasingString))
135 {
136 // Convert incoming string to int and then EAntiAliasing enum
137 int32 AntiAliasingInt;
138 if (AntiAliasingString.IsNumeric())
139 {
140 AntiAliasingInt = FCString::Atoi(*AntiAliasingString);
141 EAntiAliasing NewAntiAliasingMethod = static_cast<EAntiAliasing>(AntiAliasingInt);
142 GraphicsSettings.AntiAliasingMethod = NewAntiAliasingMethod;
143 SettingsWereChanged = true;
144 }
145 }
146
147 // Check -no-world-rendering launch argument
148 if (FParse::Param(FCommandLine::Get(), TEXT("-no-spectator-rendering")))
149 {
151 SettingsWereChanged = true;
152 }
153
154 // Check -start-camerawindows-minimized launch argument
155 if (FParse::Param(FCommandLine::Get(), TEXT("-start-camerawindows-minimized")))
156 {
158 SettingsWereChanged = true;
159 }
160
161 // Check -quality-level= launch argument
162 FString QualityLevelString;
163 if (FParse::Value(FCommandLine::Get(), TEXT("-quality-level="), QualityLevelString))
164 {
166 SettingsWereChanged = true;
167 }
168
169 return SettingsWereChanged;
170}
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 602 of file AgrarsenseSettings.cpp.

603{
604 UWorld* World = CurrentWorld.Get();
606 {
607 UGameplayStatics::SetGlobalTimeDilation(World, 0.0f);
608 UGameplayStatics::SetGamePaused(World, true);
610
611 SimulatorLog::Log("Simulator paused");
612 }
613}

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

629{
631 {
632 return;
633 }
634
635 // Subscribe to Unreal Engine end of frame callback
636 EndOfFrameHandle = FCoreDelegates::OnEndFrame.AddLambda([this]()
637 {
638 // After receiving the event, unsubcribe from the event and pause the simulation.
639 if (IsValid(this))
640 {
641 if (EndOfFrameHandle.IsValid())
642 {
643 FCoreDelegates::OnEndFrame.Remove(EndOfFrameHandle);
644 EndOfFrameHandle.Reset();
645 }
646
648 }
649 });
650}

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

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

◆ PostInitProperties()

void UAgrarsenseSettings::PostInitProperties ( )
overridevirtual

Definition at line 98 of file AgrarsenseSettings.cpp.

99{
100 Super::PostInitProperties();
101
102#if UE_BUILD_SHIPPING || UE_BUILD_DEVELOPMENT
104 {
105 SaveConfig();
106 }
107#endif
108}

References ParseLaunchArguments().

◆ SetAntiAliasingMethod()

void UAgrarsenseSettings::SetAntiAliasingMethod ( EAntiAliasing  AntiAliasingMethod)

Override anti aliasing method. Default TAA.

Parameters
AntiAliasingMethod

Definition at line 434 of file AgrarsenseSettings.cpp.

435{
436
437 UWorld* World = CurrentWorld.Get();
438
439 if (!GEngine || !World)
440 {
441 return;
442 }
443
444 GraphicsSettings.AntiAliasingMethod = AntiAliasingMethod;
445
446 FString ExecCommand;
447 switch (AntiAliasingMethod)
448 {
450 ExecCommand = TEXT("r.AntiAliasingMethod 0");
451 break;
452
454 ExecCommand = TEXT("r.AntiAliasingMethod 1");
455 break;
456
458 ExecCommand = TEXT("r.AntiAliasingMethod 2");
459 break;
460
461 // MSAA ("r.AntiAliasingMethod 3) is not supported on Deferred rendering
462
464 ExecCommand = TEXT("r.AntiAliasingMethod 4");
465 break;
466
467 default:
468 return;
469 }
470
471 GEngine->Exec(World, *ExecCommand);
472
474}
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 476 of file AgrarsenseSettings.cpp.

477{
478 EAntiAliasing NewMethod = UEnumUtilities::ConvertStringToAntiAliasingMethod(AntiAliasingMethodString);
479 SetAntiAliasingMethod(NewMethod);
480}
void SetAntiAliasingMethod(EAntiAliasing AntiAliasingMethod)
static EAntiAliasing ConvertStringToAntiAliasingMethod(const FString &String)

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

◆ SetBalancedQualityLevel()

void UAgrarsenseSettings::SetBalancedQualityLevel ( )
private

Definition at line 888 of file AgrarsenseSettings.cpp.

889{
890 UWorld* World = CurrentWorld.Get();
891 if (!World || !GEngine)
892 {
893 return;
894 }
895
897
898 GEngine->Exec(World, TEXT("sg.PostProcessQuality 3"));
899 GEngine->Exec(World, TEXT("sg.TextureQuality 3"));
900 GEngine->Exec(World, TEXT("sg.EffectsQuality 3"));
901 GEngine->Exec(World, TEXT("sg.FoliageQuality 3"));
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 3"));
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("r.BloomQuality 4"));
918 GEngine->Exec(World, TEXT("foliage.DensityScale 1"));
919 GEngine->Exec(World, TEXT("grass.DensityScale 1"));
920 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
921 GEngine->Exec(World, TEXT("r.Shadow.RadiusThreshold 0.01"));
922
923 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
924}
void SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior Behaviour=EShadowCacheInvalidationBehavior::Rigid)

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

Referenced by SetQualityLevel().

◆ SetGlobalTargetFrameRate()

void UAgrarsenseSettings::SetGlobalTargetFrameRate ( int32  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 536 of file AgrarsenseSettings.cpp.

537{
538 SetFrameRateLimit(NewTargetFrameRate);
539 ApplySettings(false);
540}
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 554 of file AgrarsenseSettings.cpp.

555{
556 UWorld* World = CurrentWorld.Get();
557 if (!World)
558 {
559 return;
560 }
561
562 SimulationSettings.TimeDilation = TimeDilation;
563 UGameplayStatics::SetGlobalTimeDilation(World, TimeDilation);
564
565 FString msg = FString::Printf(TEXT("Global time dilation: %f"), TimeDilation);
567}

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

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

◆ SetGraphicsSettings()

void UAgrarsenseSettings::SetGraphicsSettings ( FGlobalGraphicsSettings  NewSettings)
private

Change global graphics settings.

Parameters
NewSettingsThe new graphics settings to apply.

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

232{
233 if (GraphicsSettings.RenderGrass == Visible)
234 {
235 return;
236 }
237
238 UWorld* World = CurrentWorld.Get();
239
240 if (!GEngine || !World)
241 {
242 return;
243 }
244
246
248 {
249 GEngine->Exec(World, TEXT("grass.enable 0"));
250 GEngine->Exec(World, TEXT("grass.FlushCache"));
251 }
252 else
253 {
254 GEngine->Exec(World, TEXT("grass.enable 1"));
255 }
256
258}

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

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

◆ SetInstancedRenderingVisibility()

void UAgrarsenseSettings::SetInstancedRenderingVisibility ( bool  Visible)

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

Definition at line 290 of file AgrarsenseSettings.cpp.

291{
292 UWorld* World = CurrentWorld.Get();
293
294 if (World)
295 {
297 if (InstanceRenderer)
298 {
299 InstanceRenderer->SetInstancedRendering(Visible);
300 }
301 }
302}
static AInstancedRendererManager * GetInstancedRenderer(const UObject *WorldContextObject)

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

◆ SetLowQualityLevel()

void UAgrarsenseSettings::SetLowQualityLevel ( )
private

Definition at line 926 of file AgrarsenseSettings.cpp.

927{
928 UWorld* World = CurrentWorld.Get();
929 if (!World || !GEngine)
930 {
931 return;
932 }
933
935
936 GEngine->Exec(World, TEXT("sg.PostProcessQuality 0"));
937 GEngine->Exec(World, TEXT("sg.ShadowQuality 0"));
938 GEngine->Exec(World, TEXT("sg.TextureQuality 0"));
939 GEngine->Exec(World, TEXT("sg.EffectsQuality 0"));
940 GEngine->Exec(World, TEXT("sg.FoliageQuality 0"));
941
942 GEngine->Exec(World, TEXT("r.DefaultFeature.MotionBlur 0"));
943 GEngine->Exec(World, TEXT("r.DefaultFeature.Bloom 0"));
944 GEngine->Exec(World, TEXT("r.DefaultFeature.AmbientOcclusion 0"));
945 GEngine->Exec(World, TEXT("r.DefaultFeature.AmbientOcclusionStaticFraction 0"));
946 GEngine->Exec(World, TEXT("r.HZBOcclusion 0"));
947 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.01"));
948 GEngine->Exec(World, TEXT("r.SeparateTranslucency 0"));
949 GEngine->Exec(World, TEXT("r.FinishCurrentFrame 0"));
950 GEngine->Exec(World, TEXT("r.MotionBlurQuality 0"));
951 GEngine->Exec(World, TEXT("r.BloomQuality 1"));
952 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 0"));
953 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 0"));
954 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 4"));
955 GEngine->Exec(World, TEXT("r.MaxAnisotropy 4"));
956 GEngine->Exec(World, TEXT("r.LensFlareQuality 0"));
957 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 0"));
958 GEngine->Exec(World, TEXT("r.FastBlurThreshold 0"));
959 GEngine->Exec(World, TEXT("r.SSR 0"));
960 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
961 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 0"));
962 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 4"));
963 GEngine->Exec(World, TEXT("r.OcclusionQueryLocation 1"));
964 GEngine->Exec(World, TEXT("foliage.DensityScale 0"));
965 GEngine->Exec(World, TEXT("grass.DensityScale 0"));
966 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
967
968 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
969}

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

Referenced by SetQualityLevel().

◆ SetNaniteMaxPixelsPerEdge()

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

Definition at line 310 of file AgrarsenseSettings.cpp.

311{
312 UWorld* World = CurrentWorld.Get();
313 if (GEngine && World)
314 {
315 MaxPixelsPerEdge = FMath::Clamp(MaxPixelsPerEdge, 0.1f, 10.0f);
316
317 FString Command = FString::Printf(TEXT("r.Nanite.MaxPixelsPerEdge %f"), MaxPixelsPerEdge);
318 GEngine->Exec(World, *Command);
319
320 GraphicsSettings.NaniteMaxPixelsPerEdge = MaxPixelsPerEdge;
322 }
323}

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

497{
498 GraphicsSettings.QualityLevel = newQualityLevel;
499
501 {
504 break;
505
508 break;
509
512 break;
513
516 break;
517 }
518
520 FString Msg = FString::Printf(TEXT("Graphics settings: %s"), *QualityLevelString);
522
524}
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 526 of file AgrarsenseSettings.cpp.

527{
529}

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

382{
383 UWorld* World = CurrentWorld.Get();
384 if (GEngine || World)
385 {
386 RenderCustomDepth = RenderCustomDepthPass;
387 if (RenderCustomDepthPass)
388 {
389 // Note. calling this runtime will cause niagara particles to stop working correctly.
390 GEngine->Exec(World, TEXT("r.CustomDepth 3"));
391 }
392 else
393 {
394 GEngine->Exec(World, TEXT("r.CustomDepth 0"));
395 }
396 }
397}

References CurrentWorld, and RenderCustomDepth.

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

335{
336 FString BehaviourStringToLower = BehaviourString.ToLower();
337
338 if (BehaviourStringToLower == "auto")
339 {
340 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Auto);
341 }
342 else if (BehaviourStringToLower == "rigid")
343 {
344 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Rigid);
345 }
346 else if (BehaviourStringToLower == "always")
347 {
348 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Always);
349 }
350 else if (BehaviourStringToLower == "static")
351 {
352 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Static);
353 }
354}

References SetShadowCacheInvalidationBehavior().

◆ SetShadowCSMCache()

void UAgrarsenseSettings::SetShadowCSMCache ( bool  CacheShadowCSM)

Definition at line 265 of file AgrarsenseSettings.cpp.

266{
267 if (GraphicsSettings.ShadowCSMCaching == CacheShadowCSM)
268 {
269 return;
270 }
271
272 UWorld* World = CurrentWorld.Get();
273 if (GEngine && World)
274 {
275 GraphicsSettings.ShadowCSMCaching = CacheShadowCSM;
276
278 {
279 GEngine->Exec(World, TEXT("r.Shadow.CSMCaching 1"));
280 }
281 else
282 {
283 GEngine->Exec(World, TEXT("r.Shadow.CSMCaching 0"));
284 }
285
287 }
288}

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

586{
587 UWorld* World = CurrentWorld.Get();
588 if (!World)
589 {
590 return;
591 }
592
594
595 if (IsValid(Spectator))
596 {
597 Spectator->SetNiagaraComponentVisibility(Show);
599 }
600}
bool IsNiagaraComponentVisible()
Definition: Spectator.h:102
void SetNiagaraComponentVisibility(bool Visible)
Definition: Spectator.cpp:214
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 569 of file AgrarsenseSettings.cpp.

570{
571 UWorld* World = CurrentWorld.Get();
572 if (!World)
573 {
574 return;
575 }
576
578 if (IsValid(Spectator))
579 {
580 Spectator->SetMaxSpeed(MaxSpeed);
582 }
583}
void SetMaxSpeed(float MaxSpeed=1500.0f)
Definition: Spectator.cpp:222
float GetMaxSpeed()
Definition: Spectator.cpp:231

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

377{
379}

References SimulationSettings, and FGlobalSimulationSettings::StartCameraWindowsMinimized.

Referenced by SetSimulationSettings().

◆ SetUltraQualityLevel()

void UAgrarsenseSettings::SetUltraQualityLevel ( )
private

Definition at line 849 of file AgrarsenseSettings.cpp.

850{
851 UWorld* World = CurrentWorld.Get();
852 if (!World || !GEngine)
853 {
854 return;
855 }
856
858
859 // https://dev.epicgames.com/documentation/en-us/unreal-engine/scalability-reference-for-unreal-engine?application_version=5.3
860 GEngine->Exec(World, TEXT("sg.PostProcessQuality 3"));
861 GEngine->Exec(World, TEXT("sg.ShadowQuality 3"));
862 GEngine->Exec(World, TEXT("sg.TextureQuality 4"));
863 GEngine->Exec(World, TEXT("sg.EffectsQuality 4"));
864 GEngine->Exec(World, TEXT("sg.FoliageQuality 4"));
865
866 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.03"));
867 GEngine->Exec(World, TEXT("r.SeparateTranslucency 1"));
868 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 2"));
869 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 1"));
870 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 64"));
871 GEngine->Exec(World, TEXT("r.MaxAnisotropy 8"));
872 GEngine->Exec(World, TEXT("r.LensFlareQuality 2"));
873 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 1"));
874 GEngine->Exec(World, TEXT("r.FastBlurThreshold 7"));
875 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
876 GEngine->Exec(World, TEXT("r.ShadowQuality 5"));
877 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 1"));
878 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 2"));
879 GEngine->Exec(World, TEXT("r.DetailMode 2"));
880 GEngine->Exec(World, TEXT("foliage.DensityScale 1"));
881 GEngine->Exec(World, TEXT("grass.DensityScale 1"));
882 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
883 GEngine->Exec(World, TEXT("r.Shadow.RadiusThreshold 0.00"));
884
885 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Auto);
886}

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

Referenced by SetQualityLevel(), and SetUltraWithRaytracingLevel().

◆ SetUltraWithRaytracingLevel()

void UAgrarsenseSettings::SetUltraWithRaytracingLevel ( )
private

Definition at line 756 of file AgrarsenseSettings.cpp.

757{
759 {
762 }
763 else
764 {
765 SimulatorLog::Log("Graphics settings: Ray tracing not supported on this hardware.");
766 }
767}
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 41 of file AgrarsenseSettings.cpp.

42{
43#if WITH_EDITOR
44 // In case the simulator was shutdown when it was paused,
45 // reset this static variable
47#endif
48
49 CurrentWorld = World;
50
51 UWorld* GameWorld = CurrentWorld.Get();
52
53 CurrentMapName = GameWorld->GetMapName().ToLower();
54 IsMainMenu = CurrentMapName.Contains("mainmenu");
55
56 if (GameWorld)
57 {
58 // Prioritize grass creation
59 // This allows turning grass on faster if it was turned off.
60 ULandscapeSubsystem* LandscapeSubsystem = CurrentWorld->GetSubsystem<ULandscapeSubsystem>();
61 if (LandscapeSubsystem)
62 {
63 LandscapeSubsystem->PrioritizeGrassCreation(true);
64 }
65 }
66
67 // Apply Graphics and Simulation settings when Simulator is started
68 ApplySettings(true);
69
70 // Apply few console commands. One time setup.
71 if (GEngine && World)
72 {
73 GEngine->Exec(World, TEXT("g.TimeoutForBlockOnRenderFence 600000"));
74 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0"));
75
76 // Disable application starting to throttle performance if Window loses focus
77 GEngine->Exec(World, TEXT("t.IdleWhenNotForeground 0"));
78 }
79
80#if UE_BUILD_SHIPPING
81 // In Shipping mode check for Fullscreen and WindowedFullscreen launch args,
82 // Otherwise set window to windowed by default.
83 if (FParse::Param(FCommandLine::Get(), TEXT("Fullscreen")))
84 {
85 SetWindowMode(EWindowMode::Type::Fullscreen);
86 }
87 else if (FParse::Param(FCommandLine::Get(), TEXT("WindowedFullscreen")))
88 {
89 SetWindowMode(EWindowMode::Type::WindowedFullscreen);
90 }
91 else
92 {
93 SetWindowMode(EWindowMode::Type::Windowed);
94 }
95#endif
96}
static FString CurrentMapName
void SetWindowMode(EWindowMode::Type WindowType)

References ApplySettings(), CurrentMapName, CurrentWorld, IsMainMenu, FGlobalSimulationSettings::IsSimulationPaused, 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 399 of file AgrarsenseSettings.cpp.

400{
401 UWorld* World = CurrentWorld.Get();
402 if (GEngine || World)
403 {
404 GraphicsSettings.UseVirtualShadowMaps = UseVirtualShadowMaps;
405
407 {
408 GEngine->Exec(World, TEXT("r.Shadow.Virtual.Enable 1"));
409 }
410 else
411 {
412 GEngine->Exec(World, TEXT("r.Shadow.Virtual.Enable 0"));
413 }
414
416 }
417}

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

204{
205 if (GEngine)
206 {
207 UGameUserSettings* UserSettings = GEngine->GetGameUserSettings();
208 if (UserSettings)
209 {
210 UserSettings->SetFullscreenMode(WindowType);
211 UserSettings->ApplySettings(false);
212 }
213 }
214}

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

483{
484 if (GEngine && GEngine->GameViewport)
485 {
486 GEngine->GameViewport->bDisableWorldRendering = !enabled;
488
489 FString msg = FString::Printf(TEXT("World rendering: %s"), enabled ? TEXT("On") : TEXT("Off"));
491
493 }
494}

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 390 of file AgrarsenseSettings.h.

Referenced by ACamera::SetupCamera().

◆ UnPauseSimulation()

void UAgrarsenseSettings::UnPauseSimulation ( )

Unpause the simulator immediately.

Definition at line 615 of file AgrarsenseSettings.cpp.

616{
617 UWorld* World = CurrentWorld.Get();
619 {
620 UGameplayStatics::SetGlobalTimeDilation(World, SimulationSettings.TimeDilation);
621 UGameplayStatics::SetGamePaused(World, false);
623
624 SimulatorLog::Log("Simulator unpaused");
625 }
626}

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 437 of file AgrarsenseSettings.h.

Member Data Documentation

◆ AdvanceFramesHandle

FDelegateHandle UAgrarsenseSettings::AdvanceFramesHandle
private

Definition at line 473 of file AgrarsenseSettings.h.

Referenced by AdvanceFrameCount().

◆ CurrentMapName

FString UAgrarsenseSettings::CurrentMapName
staticprivate

Definition at line 509 of file AgrarsenseSettings.h.

Referenced by Setup().

◆ CurrentWorld

TWeakObjectPtr<UWorld> UAgrarsenseSettings::CurrentWorld = nullptr
private

◆ EndOfFrameHandle

FDelegateHandle UAgrarsenseSettings::EndOfFrameHandle
private

Definition at line 477 of file AgrarsenseSettings.h.

Referenced by AdvanceFrameCount(), and PauseSimulationEndOfThisFrame().

◆ FrameCount

int32 UAgrarsenseSettings::FrameCount = 0
private

Definition at line 474 of file AgrarsenseSettings.h.

Referenced by AdvanceFrameCount().

◆ GraphicsSettings

FGlobalGraphicsSettings UAgrarsenseSettings::GraphicsSettings
private

◆ IsMainMenu

bool UAgrarsenseSettings::IsMainMenu = false
staticprivate

Definition at line 508 of file AgrarsenseSettings.h.

Referenced by Setup().

◆ MapNames

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

Definition at line 485 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/RovaniemiForest/RovaniemiForest_Dev",
"/Game/Agrarsense/Maps/Vindeln/Vindeln",
"/Game/Agrarsense/Maps/Vindeln/Vindeln_Dev",
"/Game/Agrarsense/Maps/SensorShowCase/SensorShowCase",
"/Game/Agrarsense/Maps/Playground"
}

Definition at line 497 of file AgrarsenseSettings.h.

Referenced by ChangeMapByName().

◆ OnGraphicsSettingsChanged

FGraphicsSettingsDelegate UAgrarsenseSettings::OnGraphicsSettingsChanged

◆ RenderCustomDepth

bool UAgrarsenseSettings::RenderCustomDepth = true
private

◆ SimulationSettings

FGlobalSimulationSettings UAgrarsenseSettings::SimulationSettings
private

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