p.AllowKinematicKinematicConstraints

p.AllowKinematicKinematicConstraints

#Overview

name: p.AllowKinematicKinematicConstraints

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.AllowKinematicKinematicConstraints is to control whether constraints can be created between two kinematic rigid bodies in the physics simulation system of Unreal Engine 5.

This setting variable is primarily used in the physics engine subsystem of Unreal Engine 5, specifically in the constraint system. It’s referenced in the ConstraintInstance.cpp file, which is part of the Engine module.

The value of this variable is set using an FAutoConsoleVariableRef, which creates a console variable that can be modified at runtime. By default, it’s set to true.

The associated variable bAllowKinematicKinematicConstraints directly interacts with p.AllowKinematicKinematicConstraints. They share the same value and are used interchangeably in the code.

Developers must be aware that setting this variable to false can have negative impacts on ragdolls, particularly if they start in a kinematic state and then have their bodies turned dynamic. This is explicitly mentioned in a comment in the code.

Best practices when using this variable include:

  1. Keeping it set to true unless there’s a specific reason to disable constraints between kinematic bodies.
  2. Being cautious when changing its value, especially in projects that heavily use ragdolls or other physics-based animations.
  3. Testing thoroughly if the value is changed, particularly focusing on ragdoll behavior and any other physics simulations that involve kinematic bodies.

Regarding the associated variable bAllowKinematicKinematicConstraints:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ConstraintInstance.cpp:50

Scope: file

Source code excerpt:

// warning : setting the value to false can have negative impact on ragdoll, if they start in a kinematic state and then have their bodies turned dynamic
bool bAllowKinematicKinematicConstraints = true;
FAutoConsoleVariableRef CVarAllowKinematicKinematicConstraints(TEXT("p.AllowKinematicKinematicConstraints"), bAllowKinematicKinematicConstraints, TEXT("Do not create constraints between two rigid kinematics."));

/** Handy macro for setting BIT of VAR based on the bool CONDITION */
#define SET_DRIVE_PARAM(VAR, CONDITION, BIT)   (VAR) = (CONDITION) ? ((VAR) | (BIT)) : ((VAR) & ~(BIT))

float RevolutionsToRads(const float Revolutions)
{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ConstraintInstance.cpp:49

Scope: file

Source code excerpt:


// warning : setting the value to false can have negative impact on ragdoll, if they start in a kinematic state and then have their bodies turned dynamic
bool bAllowKinematicKinematicConstraints = true;
FAutoConsoleVariableRef CVarAllowKinematicKinematicConstraints(TEXT("p.AllowKinematicKinematicConstraints"), bAllowKinematicKinematicConstraints, TEXT("Do not create constraints between two rigid kinematics."));

/** Handy macro for setting BIT of VAR based on the bool CONDITION */
#define SET_DRIVE_PARAM(VAR, CONDITION, BIT)   (VAR) = (CONDITION) ? ((VAR) | (BIT)) : ((VAR) & ~(BIT))

float RevolutionsToRads(const float Revolutions)
{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ConstraintInstance.cpp:582

Scope (from outer to inner):

file
function     void FConstraintInstance::InitConstraint

Source code excerpt:

		const bool bBody1Valid = Interface->AreAllValid({ &Body1, 1 });
		const bool bBody2Valid = Interface->AreAllValid({ &Body2, 1 });
		if (!bAllowKinematicKinematicConstraints && (!bBody1Valid || Interface->AreAllKinematic({ &Body1, 1 })) && (!bBody2Valid || Interface->AreAllKinematic({ &Body2, 1 })))
		{
			return;
		}
	}

	FPhysicsCommand::ExecuteWrite(Body1, Body2, [&](Chaos::FPhysicsObject* ActorA, Chaos::FPhysicsObject* ActorB)