p.UseDeprecatedBehaviorUpdateMassScaleChanges

p.UseDeprecatedBehaviorUpdateMassScaleChanges

#Overview

name: p.UseDeprecatedBehaviorUpdateMassScaleChanges

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.UseDeprecatedBehaviorUpdateMassScaleChanges is to control the default behavior of mass updates when scale changes occur in the physics system of Unreal Engine 5. This setting variable is part of the physics core module and specifically affects the FBodyInstanceCore class.

The Unreal Engine subsystem that relies on this setting variable is the physics system, particularly the PhysicsCore module. It’s used to determine the default behavior of the bUpdateMassWhenScaleChanges flag in FBodyInstanceCore.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be changed at runtime through the console. By default, it’s initialized to 0.

This variable interacts with the bUpdateMassWhenScaleChanges member of FBodyInstanceCore. When UseDeprecatedBehaviorUpdateMassScaleChanges is 0 (default), bUpdateMassWhenScaleChanges is set to true. When it’s non-zero, bUpdateMassWhenScaleChanges is set to false.

Developers must be aware that using this variable can potentially cause issues with physics behavior, as mentioned in the comment. It’s primarily intended to allow existing projects to retain old behavior, which might be necessary for compatibility reasons.

Best practices when using this variable include:

  1. Only use it if absolutely necessary for maintaining compatibility with existing projects.
  2. Be aware of the potential issues that may arise from not updating mass when scale changes.
  3. Consider updating your project to work correctly with the new behavior (mass updating when scale changes) instead of relying on this deprecated behavior.

Regarding the associated variable UseDeprecatedBehaviorUpdateMassScaleChanges:

This is the actual integer variable that stores the value controlled by the console variable p.UseDeprecatedBehaviorUpdateMassScaleChanges. It’s used in the same way and for the same purpose as described above. The console variable provides a way to modify this value at runtime, while this associated variable is what’s actually referenced in the code to determine the behavior.

The value of this variable directly affects the initialization of bUpdateMassWhenScaleChanges in the FBodyInstanceCore constructor. Developers should be aware that changing this value will impact all newly created FBodyInstanceCore objects, potentially affecting the physics behavior throughout the entire game or application.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/BodyInstanceCore.cpp:7

Scope: file

Source code excerpt:


int32 UseDeprecatedBehaviorUpdateMassScaleChanges = 0;
FAutoConsoleVariableRef CVarUseDeprecatedBehaviorUpdateMassScaleChanges(TEXT("p.UseDeprecatedBehaviorUpdateMassScaleChanges"),
	UseDeprecatedBehaviorUpdateMassScaleChanges, TEXT("Allows FBodyInstanceCore::bUpdateMassWhenScaleChanges to default to false. This has potential issues, but allows existing projects to retain old behavior"));

FBodyInstanceCore::FBodyInstanceCore()
: bSimulatePhysics(false)
, bOverrideMass(false)
, bEnableGravity(true)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/BodyInstanceCore.cpp:6

Scope: file

Source code excerpt:

#include UE_INLINE_GENERATED_CPP_BY_NAME(BodyInstanceCore)

int32 UseDeprecatedBehaviorUpdateMassScaleChanges = 0;
FAutoConsoleVariableRef CVarUseDeprecatedBehaviorUpdateMassScaleChanges(TEXT("p.UseDeprecatedBehaviorUpdateMassScaleChanges"),
	UseDeprecatedBehaviorUpdateMassScaleChanges, TEXT("Allows FBodyInstanceCore::bUpdateMassWhenScaleChanges to default to false. This has potential issues, but allows existing projects to retain old behavior"));

FBodyInstanceCore::FBodyInstanceCore()
: bSimulatePhysics(false)
, bOverrideMass(false)
, bEnableGravity(true)
, bUpdateKinematicFromSimulation(false)

#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/BodyInstanceCore.cpp:18

Scope (from outer to inner):

file
function     FBodyInstanceCore::FBodyInstanceCore

Source code excerpt:

, bStartAwake(true)
, bGenerateWakeEvents(false)
, bUpdateMassWhenScaleChanges(!UseDeprecatedBehaviorUpdateMassScaleChanges)
, bDirtyMassProps(false)
{
}

bool FBodyInstanceCore::ShouldInstanceSimulatingPhysics() const
{