p.ComNudgeAffectsInertia
p.ComNudgeAffectsInertia
#Overview
name: p.ComNudgeAffectsInertia
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.ComNudgeAffectsInertia is to control whether the center of mass (COM) nudge affects the inertia tensor calculation in the physics system of Unreal Engine 5.
This setting variable is primarily used in the physics engine subsystem of Unreal Engine 5, specifically within the BodyUtils namespace. It’s part of the engine’s core functionality for handling physics simulations.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be changed at runtime through the console or configuration files. It’s initialized to true by default.
The associated variable bPhysicsComNudgeAdjustInertia directly interacts with p.ComNudgeAffectsInertia. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable affects the calculation of the inertia tensor, which is crucial for accurate physics simulations. When enabled, it adjusts the inertia tensor based on the COM nudge, potentially changing the object’s rotational behavior.
Best practices when using this variable include:
- Understanding the implications of enabling or disabling this feature on physics simulations.
- Testing physics behavior with both settings to ensure desired results.
- Documenting any custom settings used in projects for consistency.
Regarding the associated variable bPhysicsComNudgeAdjustInertia:
- Its purpose is identical to p.ComNudgeAffectsInertia, serving as an internal boolean representation.
- It’s used directly in the ApplyMassPropertiesModifiers function to determine whether to apply the COM nudge adjustment to the inertia tensor.
- The value is set through the console variable p.ComNudgeAffectsInertia.
- Developers should treat this variable as read-only within their code, modifying it only through the console variable interface.
- Best practices include using this variable for conditional logic related to COM nudge inertia adjustments in physics calculations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodyUtils.cpp:13
Scope (from outer to inner):
file
namespace BodyUtils
namespace CVars
Source code excerpt:
{
bool bPhysicsComNudgeAdjustInertia = true;
FAutoConsoleVariableRef CVarPhysicsComNudgeAffectsInertia(TEXT("p.ComNudgeAffectsInertia"), bPhysicsComNudgeAdjustInertia, TEXT(""));
}
inline float KgPerM3ToKgPerCm3(float KgPerM3)
{
//1m = 100cm => 1m^3 = (100cm)^3 = 1000000cm^3
#Associated Variable and Callsites
This variable is associated with another variable named bPhysicsComNudgeAdjustInertia
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodyUtils.cpp:12
Scope (from outer to inner):
file
namespace BodyUtils
namespace CVars
Source code excerpt:
namespace CVars
{
bool bPhysicsComNudgeAdjustInertia = true;
FAutoConsoleVariableRef CVarPhysicsComNudgeAffectsInertia(TEXT("p.ComNudgeAffectsInertia"), bPhysicsComNudgeAdjustInertia, TEXT(""));
}
inline float KgPerM3ToKgPerCm3(float KgPerM3)
{
//1m = 100cm => 1m^3 = (100cm)^3 = 1000000cm^3
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodyUtils.cpp:93
Scope (from outer to inner):
file
namespace BodyUtils
function Chaos::FMassProperties ApplyMassPropertiesModifiers
Source code excerpt:
// NOTE: This must come after ScaleInertia because ScaleInertia effectively calculates the "equivalent box" dimensions
// which is not always possible, e.g., if we move the CoM outside of a box you will get negative elements in the scaled inertia!
if (CVars::bPhysicsComNudgeAdjustInertia)
{
MassProps.InertiaTensor.M[0][0] += MassProps.Mass * OwningBodyInstance->COMNudge.X * OwningBodyInstance->COMNudge.X;
MassProps.InertiaTensor.M[1][1] += MassProps.Mass * OwningBodyInstance->COMNudge.Y * OwningBodyInstance->COMNudge.Y;
MassProps.InertiaTensor.M[2][2] += MassProps.Mass * OwningBodyInstance->COMNudge.Z * OwningBodyInstance->COMNudge.Z;
}