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)
 
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
 
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 OnSensorSpawned (ASensor *SensorPtr)
 
void OnSensorDestroyed (ASensor *SensorPtr)
 
void SetUltraWithRaytracingLevel ()
 
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 38 of file AgrarsenseSettings.cpp.

39{
40}

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

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

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

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

Referenced by UROSCommands::HandleAdvanceTime().

◆ ApplySettings()

void UAgrarsenseSettings::ApplySettings ( bool  bCheckForCommandLineOverrides)
override

Definition at line 134 of file AgrarsenseSettings.cpp.

135{
136 Super::ApplySettings(bCheckForCommandLineOverrides);
137
140}
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 760 of file AgrarsenseSettings.cpp.

761{
762 UWorld* World = CurrentWorld.Get();
763 if (World)
764 {
765 UGameplayStatics::OpenLevel(World, *Path, TRAVEL_Absolute);
766 }
767}

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

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

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

Referenced by UROSCommands::HandleChangeMap().

◆ DisableRaytracing()

void UAgrarsenseSettings::DisableRaytracing ( )
private

Definition at line 868 of file AgrarsenseSettings.cpp.

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

References CurrentWorld.

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

◆ EnableRaytracing()

void UAgrarsenseSettings::EnableRaytracing ( )
private

Definition at line 832 of file AgrarsenseSettings.cpp.

833{
834 UWorld* World = CurrentWorld.Get();
835 if (!World || !GEngine)
836 {
837 return;
838 }
839
840 GEngine->Exec(World, TEXT("r.RayTracing 1"));
841 GEngine->Exec(World, TEXT("r.Lumen.HardwareRayTracing 1")); // Enable lumen raytracing
842 GEngine->Exec(World, TEXT("r.RayTracing.Geometry 1")); // Enable ray tracing geometry
843 GEngine->Exec(World, TEXT("r.RayTracing.Reflections 1")); // Enable ray tracing reflections
844 GEngine->Exec(World, TEXT("r.RayTracing.AmbientOcclusion 1")); // Enable ray tracing ambient occlusion
845 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination 1")); // Enable ray tracing global illumination
846 GEngine->Exec(World, TEXT("r.RayTracing.Translucency 1")); // Enable ray tracing translucency
847 GEngine->Exec(World, TEXT("r.RayTracing.SkyLight 1")); // Enable ray tracing sky light
848
849 // Couldn't get Nanite trees with WPO to work with Raytracing
850 //GEngine->Exec(World, TEXT("r.RayTracing.Shadows 1")); // Enable ray tracing shadows
851 //GEngine->Exec(World, TEXT("r.RayTracing.Shadows.SoftShadows 1"));
852 //GEngine->Exec(World, TEXT("r.RayTracing.Shadows.SamplesPerPixel 4"));
853
854 GEngine->Exec(World, TEXT("r.RayTracing.Reflections.MaxRoughness 1.0")); // Enable reflections on all surfaces
855 GEngine->Exec(World, TEXT("r.RayTracing.Reflections.Shadows 1")); // Enable ray-traced shadows in reflections
856 GEngine->Exec(World, TEXT("r.RayTracing.Reflections.SortTiles 1")); // Optimized tile sorting for performance
857 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination.Quality 4")); // Increase RT GI quality (0-4)
858 GEngine->Exec(World, TEXT("r.RayTracing.GlobalIllumination.SamplesPerPixel 4")); // Improve GI smoothness
859
860 GEngine->Exec(World, TEXT("r.Lumen.Reflections 1")); // Enable Lumen reflections
861 GEngine->Exec(World, TEXT("r.Lumen.ScreenProbeGather.ScreenTraces 1")); // Improve Lumen probe accuracy
862
863 GEngine->Exec(World, TEXT("r.RayTracing.Denoiser 1")); // Enable denoiser
864 GEngine->Exec(World, TEXT("r.RayTracing.Denoiser.TemporalAccumulation 1")); // Temporal stability
865 GEngine->Exec(World, TEXT("r.RayTracing.Denoiser.ReuseRadiance 1")); // Improves light reuse
866}

References CurrentWorld.

Referenced by SetUltraWithRaytracingLevel().

◆ GetAgrarsenseSettings()

UAgrarsenseSettings * UAgrarsenseSettings::GetAgrarsenseSettings ( )
static

Definition at line 124 of file AgrarsenseSettings.cpp.

125{
126 return Cast<UAgrarsenseSettings>(UGameUserSettings::GetGameUserSettings());
127}

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

◆ GetAntiAliasingMethod()

EAntiAliasing UAgrarsenseSettings::GetAntiAliasingMethod ( ) const

Get current anti aliasing method

Returns

Definition at line 442 of file AgrarsenseSettings.cpp.

443{
445}

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

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

◆ 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()

int UAgrarsenseSettings::GetGlobalTargetFrameRate ( ) const

Get the global target frame rate for the Simulator

Returns
int TargetFrameRate

Definition at line 544 of file AgrarsenseSettings.cpp.

545{
546 return GetFrameRateLimit();
547}

◆ GetGlobalTimeDilation()

float UAgrarsenseSettings::GetGlobalTimeDilation ( ) const

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

Returns
float TimeDilation

Definition at line 555 of file AgrarsenseSettings.cpp.

556{
557 UWorld* World = CurrentWorld.Get();
558
559 if (!World)
560 {
562 }
563
564 return UGameplayStatics::GetGlobalTimeDilation(World);
565}

References CurrentWorld, SimulationSettings, and FGlobalSimulationSettings::TimeDilation.

◆ GetGrassVisibility()

bool UAgrarsenseSettings::GetGrassVisibility ( ) const

Get if grass visible or not

Returns
Grass visibility

Definition at line 240 of file AgrarsenseSettings.cpp.

References GraphicsSettings, and FGlobalGraphicsSettings::RenderGrass.

◆ GetIsRenderingCustomDepthPass()

bool UAgrarsenseSettings::GetIsRenderingCustomDepthPass ( ) const

Get is rendering custom depth pass on.

Definition at line 437 of file AgrarsenseSettings.cpp.

438{
439 return RenderCustomDepth;
440}

References RenderCustomDepth.

◆ GetIsUsingVirtualShadowMaps()

bool UAgrarsenseSettings::GetIsUsingVirtualShadowMaps ( ) const

Get is rendering virtual shadow maps on.

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

187{
188 return FPlatformMisc::NumberOfWorkerThreadsToSpawn();
189}

◆ GetShadowCacheInvalidationBehavior()

EShadowCacheInvalidationBehavior UAgrarsenseSettings::GetShadowCacheInvalidationBehavior ( ) const

◆ GetShadowCSMCache()

bool UAgrarsenseSettings::GetShadowCSMCache ( ) const

Get Shadow CSM cache

Returns
Shadow CSM cache on/off

Definition at line 274 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 385 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 818 of file AgrarsenseSettings.cpp.

819{
820 bool RayTracingSupported = false;
821
822 // Check if the hardware supports ray tracing
823 IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing"));
824 if (CVar && CVar->GetInt() > 0 && GRHISupportsRayTracing)
825 {
826 RayTracingSupported = true;
827 }
828
829 return RayTracingSupported;
830}

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

130{
131 Super::LoadSettings(bForceReload);
132}

◆ OnSensorDestroyed()

void UAgrarsenseSettings::OnSensorDestroyed ( ASensor SensorPtr)
private

Definition at line 785 of file AgrarsenseSettings.cpp.

786{
787 if (!SensorPtr)
788 {
789 return;
790 }
791
792 ESensorTypes type = SensorPtr->GetSensorType();
794 {
797 {
798 // If there's no more sensors that need CustomDepthPass to work,
799 // disable it to save rendering performance
801 }
802 }
803}
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 769 of file AgrarsenseSettings.cpp.

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

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

Referenced by Setup().

◆ ParseLaunchArguments()

bool UAgrarsenseSettings::ParseLaunchArguments ( )
private

Definition at line 142 of file AgrarsenseSettings.cpp.

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

616{
617 UWorld* World = CurrentWorld.Get();
619 {
620 UGameplayStatics::SetGlobalTimeDilation(World, 0.0f);
621 UGameplayStatics::SetGamePaused(World, true);
623
624 SimulatorLog::Log("Simulator paused");
625 }
626}

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

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

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

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

◆ PostInitProperties()

void UAgrarsenseSettings::PostInitProperties ( )
overridevirtual

Definition at line 112 of file AgrarsenseSettings.cpp.

113{
114 Super::PostInitProperties();
115
116#if UE_BUILD_SHIPPING || UE_BUILD_DEVELOPMENT
118 {
119 SaveConfig();
120 }
121#endif
122}

References ParseLaunchArguments().

◆ SetAntiAliasingMethod()

void UAgrarsenseSettings::SetAntiAliasingMethod ( EAntiAliasing  AntiAliasingMethod)

Override anti aliasing method. Default TAA.

Parameters
AntiAliasingMethod

Definition at line 447 of file AgrarsenseSettings.cpp.

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

490{
491 EAntiAliasing NewMethod = UEnumUtilities::ConvertStringToAntiAliasingMethod(AntiAliasingMethodString);
492 SetAntiAliasingMethod(NewMethod);
493}
void SetAntiAliasingMethod(EAntiAliasing AntiAliasingMethod)
static EAntiAliasing ConvertStringToAntiAliasingMethod(const FString &String)

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

◆ SetBalancedQualityLevel()

void UAgrarsenseSettings::SetBalancedQualityLevel ( )
private

Definition at line 927 of file AgrarsenseSettings.cpp.

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

550{
551 SetFrameRateLimit(NewTargetFrameRate);
552 ApplySettings(false);
553}
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 567 of file AgrarsenseSettings.cpp.

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

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

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

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

305{
306 UWorld* World = CurrentWorld.Get();
307
308 if (World)
309 {
311 if (InstanceRenderer)
312 {
313 InstanceRenderer->SetInstancedRendering(Visible);
314 }
315 }
316}
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 965 of file AgrarsenseSettings.cpp.

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

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

Referenced by SetQualityLevel().

◆ SetNaniteMaxPixelsPerEdge()

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

Definition at line 324 of file AgrarsenseSettings.cpp.

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

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

510{
511 GraphicsSettings.QualityLevel = newQualityLevel;
512
514 {
517 break;
518
521 break;
522
525 break;
526
529 break;
530 }
531
533 FString Msg = FString::Printf(TEXT("Graphics settings: %s"), *QualityLevelString);
535
537}
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 539 of file AgrarsenseSettings.cpp.

540{
542}

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

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

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

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

References SetShadowCacheInvalidationBehavior().

◆ SetShadowCSMCache()

void UAgrarsenseSettings::SetShadowCSMCache ( bool  CacheShadowCSM)

Definition at line 279 of file AgrarsenseSettings.cpp.

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

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

599{
600 UWorld* World = CurrentWorld.Get();
601 if (!World)
602 {
603 return;
604 }
605
607
608 if (IsValid(Spectator))
609 {
610 Spectator->SetNiagaraComponentVisibility(Show);
612 }
613}
bool IsNiagaraComponentVisible()
Definition: Spectator.h:100
void SetNiagaraComponentVisibility(bool Visible)
Definition: Spectator.cpp:187
static ASpectator * GetSpectator(const UObject *WorldContextObject)

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

Referenced by SetSimulationSettings().

◆ SetSimulationSettings()

void UAgrarsenseSettings::SetSimulationSettings ( FGlobalSimulationSettings  NewSettings)

◆ SetSpectatorMaxSpeed()

void UAgrarsenseSettings::SetSpectatorMaxSpeed ( float  MaxSpeed)

Set the max speed of the spectator pawn

Definition at line 582 of file AgrarsenseSettings.cpp.

583{
584 UWorld* World = CurrentWorld.Get();
585 if (!World)
586 {
587 return;
588 }
589
591 if (IsValid(Spectator))
592 {
593 Spectator->SetMaxSpeed(MaxSpeed);
595 }
596}
void SetMaxSpeed(float MaxSpeed=1500.0f)
Definition: Spectator.cpp:195
float GetMaxSpeed()
Definition: Spectator.cpp:204

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

Referenced by SetSimulationSettings().

◆ SetStartWindowInitiallyMinimized()

void UAgrarsenseSettings::SetStartWindowInitiallyMinimized ( bool  Minimized)

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

Definition at line 390 of file AgrarsenseSettings.cpp.

391{
393}

References SimulationSettings, and FGlobalSimulationSettings::StartCameraWindowsMinimized.

Referenced by SetSimulationSettings().

◆ SetUltraQualityLevel()

void UAgrarsenseSettings::SetUltraQualityLevel ( )
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 // https://dev.epicgames.com/documentation/en-us/unreal-engine/scalability-reference-for-unreal-engine?application_version=5.3
899 GEngine->Exec(World, TEXT("sg.PostProcessQuality 3"));
900 GEngine->Exec(World, TEXT("sg.ShadowQuality 3"));
901 GEngine->Exec(World, TEXT("sg.TextureQuality 4"));
902 GEngine->Exec(World, TEXT("sg.EffectsQuality 4"));
903 GEngine->Exec(World, TEXT("sg.FoliageQuality 4"));
904
905 GEngine->Exec(World, TEXT("r.MinScreenRadiusForLights 0.03"));
906 GEngine->Exec(World, TEXT("r.SeparateTranslucency 1"));
907 GEngine->Exec(World, TEXT("r.DepthOfFieldQuality 2"));
908 GEngine->Exec(World, TEXT("r.TranslucencyVolumeBlur 1"));
909 GEngine->Exec(World, TEXT("r.TranslucencyLightingVolumeDim 64"));
910 GEngine->Exec(World, TEXT("r.MaxAnisotropy 8"));
911 GEngine->Exec(World, TEXT("r.LensFlareQuality 2"));
912 GEngine->Exec(World, TEXT("r.SceneColorFringeQuality 1"));
913 GEngine->Exec(World, TEXT("r.FastBlurThreshold 7"));
914 GEngine->Exec(World, TEXT("r.EarlyZPassMovable 1"));
915 GEngine->Exec(World, TEXT("r.ShadowQuality 5"));
916 GEngine->Exec(World, TEXT("r.TranslucentLightingVolume 1"));
917 GEngine->Exec(World, TEXT("r.LightShaftDownSampleFactor 2"));
918 GEngine->Exec(World, TEXT("r.DetailMode 2"));
919 GEngine->Exec(World, TEXT("foliage.DensityScale 1"));
920 GEngine->Exec(World, TEXT("grass.DensityScale 1"));
921 GEngine->Exec(World, TEXT("r.Streaming.PoolSize 0 "));
922 GEngine->Exec(World, TEXT("r.Shadow.RadiusThreshold 0.00"));
923
924 SetShadowCacheInvalidationBehavior(EShadowCacheInvalidationBehavior::Auto);
925}

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

Referenced by SetQualityLevel(), and SetUltraWithRaytracingLevel().

◆ SetUltraWithRaytracingLevel()

void UAgrarsenseSettings::SetUltraWithRaytracingLevel ( )
private

Definition at line 805 of file AgrarsenseSettings.cpp.

806{
808 {
811 }
812 else
813 {
814 SimulatorLog::Log("Graphics settings: Ray tracing not supported on this hardware.");
815 }
816}
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 42 of file AgrarsenseSettings.cpp.

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

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

Referenced by AAgrarsenseGameModeBase::SpawnNeededActorsInitGame().

◆ SetUseVirtualShadowMaps()

void UAgrarsenseSettings::SetUseVirtualShadowMaps ( bool  UseVirtualShadowMaps)

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

Definition at line 412 of file AgrarsenseSettings.cpp.

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

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

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

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

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

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 FUnrealWindow::FUnrealWindow().

◆ UnPauseSimulation()

void UAgrarsenseSettings::UnPauseSimulation ( )

Unpause the simulator immediately.

Definition at line 628 of file AgrarsenseSettings.cpp.

629{
630 UWorld* World = CurrentWorld.Get();
632 {
633 UGameplayStatics::SetGlobalTimeDilation(World, SimulationSettings.TimeDilation);
634 UGameplayStatics::SetGamePaused(World, false);
636
637 SimulatorLog::Log("Simulator unpaused");
638 }
639}

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

Referenced by AdvanceFrameCount().

◆ CurrentMapName

FString UAgrarsenseSettings::CurrentMapName
staticprivate

Definition at line 513 of file AgrarsenseSettings.h.

Referenced by Setup().

◆ CurrentWorld

TWeakObjectPtr<UWorld> UAgrarsenseSettings::CurrentWorld = nullptr
private

◆ EndOfFrameHandle

FDelegateHandle UAgrarsenseSettings::EndOfFrameHandle
private

Definition at line 485 of file AgrarsenseSettings.h.

Referenced by AdvanceFrameCount(), and PauseSimulationEndOfThisFrame().

◆ FrameCount

int32 UAgrarsenseSettings::FrameCount = 0
private

Definition at line 482 of file AgrarsenseSettings.h.

Referenced by AdvanceFrameCount().

◆ GraphicsSettings

FGlobalGraphicsSettings UAgrarsenseSettings::GraphicsSettings
private

◆ IsMainMenu

bool UAgrarsenseSettings::IsMainMenu = false
staticprivate

Definition at line 512 of file AgrarsenseSettings.h.

Referenced by Setup().

◆ MapNames

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

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

Referenced by ChangeMapByName().

◆ NumberOfPostProcessingSensors

int UAgrarsenseSettings::NumberOfPostProcessingSensors = 0
private

Definition at line 467 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: