p.Chaos.Cache.UseInterpolation

p.Chaos.Cache.UseInterpolation

#Overview

name: p.Chaos.Cache.UseInterpolation

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.Chaos.Cache.UseInterpolation is to control the interpolation behavior in the Chaos physics caching system. This setting variable is used to determine whether the cache should interpolate between keyframes when evaluating particle transforms.

This setting variable is primarily used in the Chaos Caching module, which is part of the Experimental Chaos physics system in Unreal Engine 5. It’s specifically utilized in the ChaosCaching plugin.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be modified at runtime through the console or configuration files. It’s initialized with a default value of true.

The associated variable bChaosCacheUseInterpolation directly interacts with p.Chaos.Cache.UseInterpolation. They share the same value, and bChaosCacheUseInterpolation is used in the actual code logic to determine whether interpolation should be applied.

Developers must be aware that this variable affects the smoothness and accuracy of cached physics simulations. When enabled, it interpolates between keyframes, potentially providing smoother motion but at the cost of some performance overhead. When disabled, it uses the nearest keyframe without interpolation, which may be faster but could result in less smooth motion.

Best practices when using this variable include:

  1. Keep it enabled (true) for most scenarios to ensure smooth physics playback.
  2. Consider disabling it in performance-critical situations where the slight visual improvement from interpolation is less important than performance.
  3. Test your specific use case with both settings to determine the best balance between visual quality and performance.

Regarding the associated variable bChaosCacheUseInterpolation:

The purpose of bChaosCacheUseInterpolation is to serve as the in-code representation of the p.Chaos.Cache.UseInterpolation console variable. It’s used directly in the codebase to control the interpolation behavior.

This variable is used within the ChaosCaching plugin, specifically in the FParticleTransformTrack::Evaluate function, where it determines whether to blend between two transforms or use a single transform without interpolation.

The value of bChaosCacheUseInterpolation is set by the FAutoConsoleVariableRef mechanism, which links it to the p.Chaos.Cache.UseInterpolation console variable.

There are no other variables that directly interact with bChaosCacheUseInterpolation beyond its connection to p.Chaos.Cache.UseInterpolation.

Developers should be aware that changes to p.Chaos.Cache.UseInterpolation will directly affect bChaosCacheUseInterpolation, and vice versa. They should use bChaosCacheUseInterpolation in their code when they need to check the current interpolation setting.

Best practices for using bChaosCacheUseInterpolation include:

  1. Use it as a read-only variable in most cases, relying on the console variable for changes.
  2. If modification is necessary, consider using the console variable system to ensure consistency.
  3. Be aware of its impact on physics simulation playback when used in conditional statements.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/ChaosCaching/Source/ChaosCaching/Private/Chaos/ChaosCache.cpp:12

Scope: file

Source code excerpt:

bool bChaosCacheUseInterpolation = true;
FAutoConsoleVariableRef CVarChaosCacheUseInterpolation(
	TEXT("p.Chaos.Cache.UseInterpolation"),
	bChaosCacheUseInterpolation,
	TEXT("When enabled, cache interpolates between keys.[def: true]"));

bool bChaosCacheCompressTracksAfterRecording = true;
FAutoConsoleVariableRef CVarChaosCacheCompressTracksAfterRecording(
	TEXT("p.Chaos.Cache.CompressTracksAfterRecording"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/ChaosCaching/Source/ChaosCaching/Private/Chaos/ChaosCache.cpp:10

Scope: file

Source code excerpt:

#include UE_INLINE_GENERATED_CPP_BY_NAME(ChaosCache)

bool bChaosCacheUseInterpolation = true;
FAutoConsoleVariableRef CVarChaosCacheUseInterpolation(
	TEXT("p.Chaos.Cache.UseInterpolation"),
	bChaosCacheUseInterpolation,
	TEXT("When enabled, cache interpolates between keys.[def: true]"));

bool bChaosCacheCompressTracksAfterRecording = true;
FAutoConsoleVariableRef CVarChaosCacheCompressTracksAfterRecording(
	TEXT("p.Chaos.Cache.CompressTracksAfterRecording"),
	bChaosCacheCompressTracksAfterRecording,

#Loc: <Workspace>/Engine/Plugins/Experimental/ChaosCaching/Source/ChaosCaching/Private/Chaos/ChaosCache.cpp:873

Scope (from outer to inner):

file
function     FTransform FParticleTransformTrack::Evaluate

Source code excerpt:

		ensure(Alpha >= 0.f && Alpha <= 1.f); 

		if (bChaosCacheUseInterpolation)
		{
			Result.Blend(TransformA, TransformB, Alpha);
		}
		else
		{
			Result = TransformA;