p.Resim.ResimFrameValidation

p.Resim.ResimFrameValidation

#Overview

name: p.Resim.ResimFrameValidation

This variable is created as a Console Variable (cvar).

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Resim.ResimFrameValidation is to control the level of validation leniency for resimulation frames in the Chaos physics system of Unreal Engine 5. This setting variable is used to determine how strictly the engine should validate particles when finding a valid frame for resimulation.

The Chaos physics system, which is part of Unreal Engine’s experimental features, relies on this setting variable. It is primarily used in the RewindData.cpp file, which is part of the Chaos module.

The value of this variable is set through a console variable (CVar) named “p.Resim.ResimFrameValidation”. It is initialized with the value of EResimFrameValidation::IslandValidation, which corresponds to an integer value of 1.

The ResimFrameValidation variable interacts with the EResimFrameValidation enum, which defines three levels of validation: 0 - No leniency (all dirty particles need a valid target) 1 - Island leniency (all particles in resim islands need a valid target) 2 - Full leniency (only the particle triggering the resim needs a valid target)

Developers must be aware that this variable significantly affects the behavior of the resimulation process in the Chaos physics system. Changing this value can impact performance and simulation accuracy.

Best practices when using this variable include:

  1. Use the default value (1 - Island leniency) unless there’s a specific need for stricter or more lenient validation.
  2. When debugging physics issues, experimenting with different validation levels may help isolate problems.
  3. Be cautious when using full leniency (2), as it may lead to less accurate resimulations.

The associated variable ResimFrameValidation is an integer that directly stores the value set by the console variable. It is used throughout the FindValidResimFrame function to determine the validation behavior. The same considerations and best practices apply to this variable as they do to the console variable.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/RewindData.cpp:891

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

};
CHAOS_API int32 ResimFrameValidation = (int32)EResimFrameValidation::IslandValidation;
FAutoConsoleVariableRef CVarResimFrameValidationLeniency(TEXT("p.Resim.ResimFrameValidation"), ResimFrameValidation, TEXT("0 = no leniency, all dirty particles need a valid target. 1 = Island leniency, all particles in resim islands need a valid target. 2 = Full leniency, only the particle triggering the resim need a valid target."));
CHAOS_API bool bResimIncompleteHistory = false;
FAutoConsoleVariableRef CVarResimIncompleteHistory(TEXT("p.Resim.IncompleteHistory"), bResimIncompleteHistory, TEXT("If a valid resim frame can't be found, use the requested resim frame and perform a resimulation with incomplete data."));

int32 FRewindData::FindValidResimFrame(const int32 RequestedFrame)
{
	int32 ValidFrame = INDEX_NONE;

#Associated Variable and Callsites

This variable is associated with another variable named ResimFrameValidation. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/RewindData.cpp:890

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	TriggerParticleValidation = 2 // Only validate the resim triggering particle(s)
};
CHAOS_API int32 ResimFrameValidation = (int32)EResimFrameValidation::IslandValidation;
FAutoConsoleVariableRef CVarResimFrameValidationLeniency(TEXT("p.Resim.ResimFrameValidation"), ResimFrameValidation, TEXT("0 = no leniency, all dirty particles need a valid target. 1 = Island leniency, all particles in resim islands need a valid target. 2 = Full leniency, only the particle triggering the resim need a valid target."));
CHAOS_API bool bResimIncompleteHistory = false;
FAutoConsoleVariableRef CVarResimIncompleteHistory(TEXT("p.Resim.IncompleteHistory"), bResimIncompleteHistory, TEXT("If a valid resim frame can't be found, use the requested resim frame and perform a resimulation with incomplete data."));

int32 FRewindData::FindValidResimFrame(const int32 RequestedFrame)
{
	int32 ValidFrame = INDEX_NONE;

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/RewindData.cpp:933

Scope (from outer to inner):

file
namespace    Chaos
function     int32 FRewindData::FindValidResimFrame

Source code excerpt:

	// Cache all particles in islands that have a resim triggering particle
	TArray<const FGeometryParticleHandle*> ResimIslandParticles;
	if (ResimFrameValidation == (int32)EResimFrameValidation::IslandValidation)
	{
		TArray<const Private::FPBDIsland*> ResimIslands;
		for (FDirtyParticleInfo& DirtyParticleInfo : DirtyParticles)
		{
			FGeometryParticleHandle* Handle = DirtyParticleInfo.GetObjectPtr();
			if (IslandManager.GetParticleResimFrame(Handle) != INDEX_NONE)

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/RewindData.cpp:958

Scope (from outer to inner):

file
namespace    Chaos
function     int32 FRewindData::FindValidResimFrame

Source code excerpt:

		
#if DEBUG_REWIND_DATA
		UE_LOG(LogTemp, Log, TEXT("COMMON | PT | FindValidResimFrame | Processing resim particles | History Frame: %d | Total Particle Count: %d | ResimIslands Particle Count: %d | ResimFrameValidation: %d"), ValidFrame, DirtyParticles.Num(), ResimIslandParticles.Num(), ResimFrameValidation);
#endif

		if ((EResimFrameValidation)ResimFrameValidation == EResimFrameValidation::IslandValidation)
		{
			// Iterate over islands previously found having resim particles in them and check if the particles in the islands have targets
			for (const FGeometryParticleHandle* IslandParticle : ResimIslandParticles)
			{
				// Cache particle handles for objects in islands that need resim
				if (FDirtyParticleInfo* DirtyParticleInfo = FindDirtyObj(*IslandParticle))

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/RewindData.cpp:982

Scope (from outer to inner):

file
namespace    Chaos
function     int32 FRewindData::FindValidResimFrame

Source code excerpt:

			{
				// If running validation leniency, check if the particle is marked for resimulation else don't bother checking for valid target states.
				if ((EResimFrameValidation)ResimFrameValidation == EResimFrameValidation::TriggerParticleValidation)
				{
					FGeometryParticleHandle* Handle = DirtyParticleInfo.GetObjectPtr();
					if(IslandManager.GetParticleResimFrame(Handle) == INDEX_NONE)
					{
						continue;
					}

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/RewindData.cpp:1038

Scope (from outer to inner):

file
namespace    Chaos
function     int32 FRewindData::FindValidResimFrame

Source code excerpt:


#if DEBUG_REWIND_DATA
		UE_LOG(LogTemp, Warning, TEXT("COMMON | PT | FindValidResimFrame | No valid resim frame found | RequestedFrame: %d | ValidFrame: %d | EarliestFrame: %d | HasTargetHistory: %d | EarliestHistoryFrame: %d | CurrentFrame: %d | FramesSaved: %d | ResimFrameValidation: %d"), RequestedFrame, ValidFrame, EarliestFrame, bHasTargetHistory, GetEarliestFrame_Internal(), CurrentFrame(), FramesSaved, ResimFrameValidation);
#endif
	}

	return ValidFrame;
}