p.Resim.AllowRewindToResimulatedFrames

p.Resim.AllowRewindToResimulatedFrames

#Overview

name: p.Resim.AllowRewindToResimulatedFrames

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Resim.AllowRewindToResimulatedFrames is to control the behavior of the physics resimulation system in Unreal Engine’s Chaos physics engine. Specifically, it determines whether the engine is allowed to rewind to frames that were previously part of a resimulation.

This setting variable is primarily used in the Chaos physics engine, which is part of Unreal Engine’s experimental features. It’s referenced in the RewindData.cpp file, which suggests it’s closely tied to the physics simulation’s ability to rewind and replay certain frames.

The value of this variable is set through a console variable (CVar) system, which allows it to be changed at runtime. It’s initialized as false by default.

The associated variable bResimAllowRewindToResimulatedFrames directly interacts with p.Resim.AllowRewindToResimulatedFrames. They share the same value, with the console variable controlling the boolean flag.

Developers must be aware that enabling this variable can change the behavior of physics resimulation. When enabled, it allows rewinding to frames that were previously part of a resimulation. This can be useful for more flexible physics debugging but may also introduce complexities in the simulation process.

Best practices when using this variable include:

  1. Use it primarily for debugging purposes.
  2. Be aware of potential performance implications when allowing rewinding to resimulated frames.
  3. Ensure that any code relying on the resimulation behavior is prepared to handle the possibility of rewinding to previously resimulated frames.

Regarding the associated variable bResimAllowRewindToResimulatedFrames:

The purpose of bResimAllowRewindToResimulatedFrames is to serve as the actual boolean flag that controls the resimulation behavior within the engine’s code.

This variable is used directly in the Chaos physics engine, specifically in the FRewindData::RewindToFrame function. It determines how the BlockResimFrame is set, which affects the resimulation process.

The value of this variable is set by the console variable p.Resim.AllowRewindToResimulatedFrames.

No other variables directly interact with bResimAllowRewindToResimulatedFrames based on the provided information, but it’s crucial in determining the behavior of the RewindToFrame function.

Developers should be aware that this variable directly affects the physics simulation behavior and should be used cautiously, especially in production environments.

Best practices for using bResimAllowRewindToResimulatedFrames include:

  1. Use it in conjunction with other debugging tools when investigating physics anomalies.
  2. Be prepared to handle potential changes in simulation behavior when this flag is enabled.
  3. Consider the implications on performance and simulation consistency when enabling this feature.

#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:258

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


CHAOS_API bool bResimAllowRewindToResimulatedFrames = false;
FAutoConsoleVariableRef CVarResimAllowRewindToResimulatedFrames(TEXT("p.Resim.AllowRewindToResimulatedFrames"), bResimAllowRewindToResimulatedFrames, TEXT("Allow rewinding back to a frame that was previously part of a resimulation. If a resimulation is performed between frame 100-110, allow a new resim from 105-115 if needed, else next resim will be able to start from frame 111."));

bool FRewindData::RewindToFrame(int32 Frame)
{
	QUICK_SCOPE_CYCLE_COUNTER(RewindToFrame);

	EnsureIsInPhysicsThreadContext();

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

}

CHAOS_API bool bResimAllowRewindToResimulatedFrames = false;
FAutoConsoleVariableRef CVarResimAllowRewindToResimulatedFrames(TEXT("p.Resim.AllowRewindToResimulatedFrames"), bResimAllowRewindToResimulatedFrames, TEXT("Allow rewinding back to a frame that was previously part of a resimulation. If a resimulation is performed between frame 100-110, allow a new resim from 105-115 if needed, else next resim will be able to start from frame 111."));

bool FRewindData::RewindToFrame(int32 Frame)
{
	QUICK_SCOPE_CYCLE_COUNTER(RewindToFrame);

	EnsureIsInPhysicsThreadContext();

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

Scope (from outer to inner):

file
namespace    Chaos
function     bool FRewindData::RewindToFrame

Source code excerpt:

	FFrameAndPhase CurFrameAndPhase{ CurFrame, FFrameAndPhase::PrePushData };

	BlockResimFrame = bResimAllowRewindToResimulatedFrames ? Frame : CurFrame;

	auto RewindHelper = [RewindFrameAndPhase, CurFrameAndPhase, this](auto Obj, bool bResimAsFollower, auto& Property, const auto& RewindFunc) -> bool
	{
		if (bResimAsFollower)
		{
			//If we're rewinding a particle that doesn't need to save head (resim as follower never checks for desync so we don't care about head)