bSimulateAnimPhysicsAfterReset

bSimulateAnimPhysicsAfterReset

#Overview

name: bSimulateAnimPhysicsAfterReset

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 10 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bSimulateAnimPhysicsAfterReset is to control whether animation physics nodes should be simulated in the tick where they are reset. This setting is primarily used in the physics simulation system of Unreal Engine, specifically for animation-driven physics.

This variable is mainly used in the Unreal Engine’s animation and physics systems, particularly in the RigidBody animation nodes. It’s referenced in both the experimental PhysicsControl plugin and the core AnimGraphRuntime module.

The value of this variable is set in the UPhysicsSettings class, which is part of the Engine’s physics configuration. It can be modified through the project settings in the Unreal Editor.

bSimulateAnimPhysicsAfterReset interacts closely with other physics-related variables such as AnimPhysicsMinDeltaTime and ResetSimulatedTeleportType. It’s used in conjunction with these variables to determine whether a physics simulation tick is needed after a reset.

Developers should be aware that enabling this option may lead to an additional physics simulation step immediately after a reset, which could impact performance or cause unexpected behavior in certain scenarios. It’s important to consider the trade-offs between accuracy and performance when using this setting.

Best practices for using this variable include:

  1. Only enable it if you need precise physics behavior immediately after resets.
  2. Monitor performance impact, especially in scenes with many physics-driven animations.
  3. Test thoroughly to ensure it doesn’t introduce unwanted jitter or instability in your animations.
  4. Consider the interaction with other physics settings, particularly AnimPhysicsMinDeltaTime and ResetSimulatedTeleportType.
  5. Use it in conjunction with proper physics asset setup and tuning for optimal results.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:335, section: [/Script/Engine.PhysicsSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/PhysicsControl/Source/PhysicsControl/Private/AnimNode_RigidBodyWithControl.cpp:157

Scope (from outer to inner):

file
function     FAnimNode_RigidBodyWithControl::FAnimNode_RigidBodyWithControl

Source code excerpt:

	, AccumulatedDeltaTime(0.0f)
	, AnimPhysicsMinDeltaTime(0.0f)
	, bSimulateAnimPhysicsAfterReset(false)
	, SkelMeshCompWeakPtr()
	, PhysicsSimulation(nullptr)
	, SolverSettings()
	, SolverIterations()
	, SimulationTask()
	, OutputBoneData()

#Loc: <Workspace>/Engine/Plugins/Experimental/PhysicsControl/Source/PhysicsControl/Private/AnimNode_RigidBodyWithControl.cpp:682

Scope (from outer to inner):

file
function     void FAnimNode_RigidBodyWithControl::EvaluateSkeletalControl_AnyThread

Source code excerpt:

		// Only need to tick physics if we didn't reset and we have some time to simulate
		const bool bNeedsSimulationTick = 
			((bSimulateAnimPhysicsAfterReset || (ResetSimulatedTeleportType != ETeleportType::ResetPhysics)) && 
				DeltaSeconds > AnimPhysicsMinDeltaTime);
		if (bNeedsSimulationTick)
		{
			// Update the pose data
			{
				SCOPE_CYCLE_COUNTER(STAT_RigidBodyNodeWithControl_PoseUpdate);

#Loc: <Workspace>/Engine/Plugins/Experimental/PhysicsControl/Source/PhysicsControl/Private/AnimNode_RigidBodyWithControl.cpp:985

Scope (from outer to inner):

file
function     void FAnimNode_RigidBodyWithControl::InitPhysics

Source code excerpt:

	{
		AnimPhysicsMinDeltaTime = Settings->AnimPhysicsMinDeltaTime;
		bSimulateAnimPhysicsAfterReset = Settings->bSimulateAnimPhysicsAfterReset;
	}
	else
	{
		AnimPhysicsMinDeltaTime = 0.f;
		bSimulateAnimPhysicsAfterReset = false;
	}
	
	bEnabled = PhysicsAssetToUse && SkeletalMeshComp->GetAllowRigidBodyAnimNode() && CVarEnableRigidBodyNodeWithControl.GetValueOnAnyThread() != 0;
	if(bEnabled)
	{
		PhysicsSimulation = new ImmediatePhysics::FSimulation();

#Loc: <Workspace>/Engine/Plugins/Experimental/PhysicsControl/Source/PhysicsControl/Public/AnimNode_RigidBodyWithControl.h:513

Scope: file

Source code excerpt:

	float AccumulatedDeltaTime;
	float AnimPhysicsMinDeltaTime;
	bool bSimulateAnimPhysicsAfterReset;
	/** This should only be used for removing the delegate during termination. Do NOT use this for any per frame work */
	TWeakObjectPtr<USkeletalMeshComponent> SkelMeshCompWeakPtr;

	ImmediatePhysics::FSimulation* PhysicsSimulation;
	FPhysicsAssetSolverSettings SolverSettings;
	FSolverIterations SolverIterations;	// to be deprecated

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_RigidBody.cpp:198

Scope (from outer to inner):

file
function     FAnimNode_RigidBody::FAnimNode_RigidBody

Source code excerpt:

	, AccumulatedDeltaTime(0.0f)
	, AnimPhysicsMinDeltaTime(0.0f)
	, bSimulateAnimPhysicsAfterReset(false)
	, SkelMeshCompWeakPtr()
	, PhysicsSimulation(nullptr)
	, SolverSettings()
	, SolverIterations()
	, SimulationTask()
	, OutputBoneData()

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_RigidBody.cpp:704

Scope (from outer to inner):

file
function     void FAnimNode_RigidBody::EvaluateSkeletalControl_AnyThread

Source code excerpt:


		// Only need to tick physics if we didn't reset and we have some time to simulate
		const bool bNeedsSimulationTick = ((bSimulateAnimPhysicsAfterReset || (ResetSimulatedTeleportType != ETeleportType::ResetPhysics)) && DeltaSeconds > AnimPhysicsMinDeltaTime);
		if (bNeedsSimulationTick)
		{
			// Transfer bone velocities previously captured.
			if (bTransferBoneVelocities && (CapturedBoneVelocityPose.GetPose().GetNumBones() > 0))
			{
				for (const FOutputBoneData& OutputData : OutputBoneData)

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_RigidBody.cpp:1051

Scope (from outer to inner):

file
function     void FAnimNode_RigidBody::InitPhysics

Source code excerpt:

	{
		AnimPhysicsMinDeltaTime = Settings->AnimPhysicsMinDeltaTime;
		bSimulateAnimPhysicsAfterReset = Settings->bSimulateAnimPhysicsAfterReset;
	}
	else
	{
		AnimPhysicsMinDeltaTime = 0.f;
		bSimulateAnimPhysicsAfterReset = false;
	}
	
	bEnabled = (UsePhysicsAsset && bEnableRigidBodyNode && SkeletalMeshComp->GetAllowRigidBodyAnimNode());
	if(bEnabled)
	{
		SCOPE_CYCLE_COUNTER(STAT_RigidBodyNodeInitTime_SetupSimulation);

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Public/BoneControllers/AnimNode_RigidBody.h:403

Scope: file

Source code excerpt:

	float AccumulatedDeltaTime;
	float AnimPhysicsMinDeltaTime;
	bool bSimulateAnimPhysicsAfterReset;
	/** This should only be used for removing the delegate during termination. Do NOT use this for any per frame work */
	TWeakObjectPtr<USkeletalMeshComponent> SkelMeshCompWeakPtr;

	ImmediatePhysics::FSimulation* PhysicsSimulation;
	FPhysicsAssetSolverSettings SolverSettings;
	FSolverIterations SolverIterations;	// to be deprecated

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/PhysicsEngine/PhysicsSettings.h:193

Scope (from outer to inner):

file
class        class UPhysicsSettings : public UPhysicsSettingsCore

Source code excerpt:

	/** Whether to simulate anim physics nodes in the tick where they're reset. */
	UPROPERTY(config, EditAnywhere, Category = Simulation)
	bool bSimulateAnimPhysicsAfterReset;

	/** Min Physics Delta Time; the simulation will not step if the delta time is below this value */
	UPROPERTY(config, EditAnywhere, meta = (ClampMin = "0.0", UIMin = "0.0", ClampMax = "0.0001", UIMax = "0.0001"), Category = Framerate)
	float MinPhysicsDeltaTime;

	/** Max Physics Delta Time to be clamped. */

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/PhysicsSettings.cpp:17

Scope (from outer to inner):

file
function     UPhysicsSettings::UPhysicsSettings

Source code excerpt:

	, bDisableActiveActors(false)
	, AnimPhysicsMinDeltaTime(0.f)
	, bSimulateAnimPhysicsAfterReset(false)
	, MinPhysicsDeltaTime(UE_SMALL_NUMBER)
	, MaxPhysicsDeltaTime(1.f / 30.f)
	, bSubstepping(false)
	, bTickPhysicsAsync(false)
	, AsyncFixedTimeStepSize(1.f / 30.f)
	, MaxSubstepDeltaTime(1.f / 60.f)