p.GeometryCollectionRepLinearMatchStrength

p.GeometryCollectionRepLinearMatchStrength

#Overview

name: p.GeometryCollectionRepLinearMatchStrength

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.GeometryCollectionRepLinearMatchStrength is to control the linear correction acceleration for replicated Geometry Collection components in Unreal Engine 5. This setting is primarily used in the physics and networking systems for Geometry Collections.

This setting variable is relied upon by the Experimental GeometryCollectionEngine module, specifically within the GeometryCollectionComponent. It’s used in the replication and physics simulation of Geometry Collections, which are part of Unreal Engine’s physics and destruction system.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands or configuration files. Its default value is 50.

The associated variable GeometryCollectionRepLinearMatchStrength interacts directly with p.GeometryCollectionRepLinearMatchStrength, as they share the same value. This variable is used in the actual code logic for updating cluster positions and velocities during replication.

Developers must be aware that this variable affects the smoothness and accuracy of replicated Geometry Collection movements. A higher value will result in faster corrections but may cause more abrupt movements, while a lower value will lead to smoother but potentially less accurate replication.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of your project’s networking requirements and visual expectations.
  2. Testing with various network conditions to find the optimal value.
  3. Considering the trade-off between smooth movement and accurate replication.

Regarding the associated variable GeometryCollectionRepLinearMatchStrength:

The purpose of GeometryCollectionRepLinearMatchStrength is to directly apply the console variable’s value in the physics simulation code. It’s used to calculate the correction velocity for replicated Geometry Collection clusters.

This variable is used within the UpdateClusterPositionAndVelocitiesFromReplication function in the GeometryCollectionComponent. It’s multiplied by the time delta to determine the correction velocity to apply to the cluster.

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

Developers should be aware that this variable directly impacts the physics simulation of replicated Geometry Collections. It’s used in a velocity calculation, so changes to its value will immediately affect how quickly replicated objects correct their positions.

Best practices for this variable include:

  1. Ensuring it’s not modified directly in code, but rather adjusted through the console variable.
  2. Monitoring its impact on both visual quality and network performance when adjusting the associated console variable.
  3. Considering its interaction with other replication settings, such as GeometryCollectionRepAngularMatchTime and GeometryCollectionRepMaxExtrapolationTime.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionComponent.cpp:2491

Scope: file

Source code excerpt:


float GeometryCollectionRepLinearMatchStrength = 50;
FAutoConsoleVariableRef CVarGeometryCollectionRepLinearMatchStrength(TEXT("p.GeometryCollectionRepLinearMatchStrength"), GeometryCollectionRepLinearMatchStrength, TEXT("Units can be interpreted as %/s^2 - acceleration of percent linear correction"));

float GeometryCollectionRepAngularMatchTime = .5f;
FAutoConsoleVariableRef CVarGeometryCollectionRepAngularMatchTime(TEXT("p.GeometryCollectionRepAngularMatchTime"), GeometryCollectionRepAngularMatchTime, TEXT("In seconds, how quickly should the angle match the replicated target angle"));

float GeometryCollectionRepMaxExtrapolationTime = 3.f;
FAutoConsoleVariableRef CVarGeometryCollectionRepMaxExtrapolationTime(TEXT("p.GeometryCollectionRepMaxExtrapolationTime"), GeometryCollectionRepMaxExtrapolationTime, TEXT("Number of seconds that replicated physics data will persist for a GC, extrapolating velocities"));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionComponent.cpp:2490

Scope: file

Source code excerpt:

}

float GeometryCollectionRepLinearMatchStrength = 50;
FAutoConsoleVariableRef CVarGeometryCollectionRepLinearMatchStrength(TEXT("p.GeometryCollectionRepLinearMatchStrength"), GeometryCollectionRepLinearMatchStrength, TEXT("Units can be interpreted as %/s^2 - acceleration of percent linear correction"));

float GeometryCollectionRepAngularMatchTime = .5f;
FAutoConsoleVariableRef CVarGeometryCollectionRepAngularMatchTime(TEXT("p.GeometryCollectionRepAngularMatchTime"), GeometryCollectionRepAngularMatchTime, TEXT("In seconds, how quickly should the angle match the replicated target angle"));

float GeometryCollectionRepMaxExtrapolationTime = 3.f;
FAutoConsoleVariableRef CVarGeometryCollectionRepMaxExtrapolationTime(TEXT("p.GeometryCollectionRepMaxExtrapolationTime"), GeometryCollectionRepMaxExtrapolationTime, TEXT("Number of seconds that replicated physics data will persist for a GC, extrapolating velocities"));

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionComponent.cpp:2618

Scope (from outer to inner):

file
namespace    anonymous
function     bool UpdateClusterPositionAndVelocitiesFromReplication

Source code excerpt:

			const Chaos::FVec3 DeltaX = RepExtrapPos - Cluster.GetX();
			const float DeltaXMagSq = DeltaX.SizeSquared();
			if (DeltaXMagSq > SMALL_NUMBER && GeometryCollectionRepLinearMatchStrength > SMALL_NUMBER)
			{
				bWake = true;
				//
				// DeltaX * MatchStrength is an acceleration, m/s^2, which is integrated
				// by multiplying by DeltaTime.
				//

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionComponent.cpp:2628

Scope (from outer to inner):

file
namespace    anonymous
function     bool UpdateClusterPositionAndVelocitiesFromReplication

Source code excerpt:

				// step, ie. correction velocities are framerate independent.
				//
				Cluster.SetV(RepVel + (DeltaX * FMath::Min(1.0f, GeometryCollectionRepLinearMatchStrength * DeltaTime)));
			}

			//
			// Match angular velocity
			//
			const FVector RepAngVel = AngularVelocity;