p.Chaos.GC.CreatePhysicsStateInEditor

p.Chaos.GC.CreatePhysicsStateInEditor

#Overview

name: p.Chaos.GC.CreatePhysicsStateInEditor

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.Chaos.GC.CreatePhysicsStateInEditor is to control whether physics states for Geometry Collections are created in the Unreal Editor outside of Play-In-Editor (PIE) mode.

This setting variable is primarily used in the Geometry Collection system, which is part of Unreal Engine’s Chaos physics engine. It is specifically utilized within the GeometryCollectionEngine module.

The value of this variable is set through the Unreal Engine console variable system. It’s initialized as false by default, meaning physics states for Geometry Collections are not created in the editor by default.

This variable interacts directly with its associated variable GeometryCollectionCreatePhysicsStateInEditor. They share the same value and are used interchangeably in the code.

Developers must be aware that enabling this variable will cause physics states to be created for Geometry Collections in the editor, which might impact editor performance and behavior. It’s typically used for debugging or specific editor-time physics simulations.

Best practices when using this variable include:

  1. Keep it disabled (false) by default for better editor performance.
  2. Enable it only when necessary for specific editor-time physics simulations or debugging.
  3. Be aware of potential performance implications when enabled.
  4. Use it in conjunction with other Geometry Collection settings for comprehensive control over editor-time physics behavior.

Regarding the associated variable GeometryCollectionCreatePhysicsStateInEditor:

The purpose of GeometryCollectionCreatePhysicsStateInEditor is the same as p.Chaos.GC.CreatePhysicsStateInEditor - to control the creation of physics states for Geometry Collections in the Unreal Editor.

This variable is used in the GeometryCollectionEngine module, specifically within the UGeometryCollectionComponent class.

The value is set through the console variable system and initialized as false by default.

It interacts directly with p.Chaos.GC.CreatePhysicsStateInEditor, sharing the same value.

Developers should be aware that this variable is checked in key functions like ResetDynamicCollection and OnCreatePhysicsState to determine whether to create physics states in the editor.

Best practices for using this variable are the same as those for p.Chaos.GC.CreatePhysicsStateInEditor, as they are essentially the same setting with different access points in the code.

#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:129

Scope: file

Source code excerpt:


bool GeometryCollectionCreatePhysicsStateInEditor = false;
FAutoConsoleVariableRef CVarGeometryCollectionCreatePhysicsStateInEditor(TEXT("p.Chaos.GC.CreatePhysicsStateInEditor"), GeometryCollectionCreatePhysicsStateInEditor, TEXT("when on , physics state for a GC will be create in editor ( non PIE )"));

bool GeometryCollectionEnableRootProxyComponents = true;
FAutoConsoleVariableRef CVarGeometryCollectionRootProxyComponents(TEXT("p.Chaos.GC.EnableRootProxyComponents"), GeometryCollectionEnableRootProxyComponents, TEXT("when on ( by default ) , create root proxy components"));

bool GeometryCollectionUseReplicationV2 = true;
FAutoConsoleVariableRef CVarGeometryCollectionUseReplicationV2(TEXT("p.Chaos.GC.UseReplicationV2"), GeometryCollectionUseReplicationV2, TEXT("When true use new replication data model"));

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

FAutoConsoleVariableRef CVarGeometryCollectionEmitRootBreakingEvent(TEXT("p.Chaos.GC.EmitRootBreakingEvent"), GeometryCollectionEmitRootBreakingEvent, TEXT("When true send a breaking event when root is breaking"));

bool GeometryCollectionCreatePhysicsStateInEditor = false;
FAutoConsoleVariableRef CVarGeometryCollectionCreatePhysicsStateInEditor(TEXT("p.Chaos.GC.CreatePhysicsStateInEditor"), GeometryCollectionCreatePhysicsStateInEditor, TEXT("when on , physics state for a GC will be create in editor ( non PIE )"));

bool GeometryCollectionEnableRootProxyComponents = true;
FAutoConsoleVariableRef CVarGeometryCollectionRootProxyComponents(TEXT("p.Chaos.GC.EnableRootProxyComponents"), GeometryCollectionEnableRootProxyComponents, TEXT("when on ( by default ) , create root proxy components"));

bool GeometryCollectionUseReplicationV2 = true;
FAutoConsoleVariableRef CVarGeometryCollectionUseReplicationV2(TEXT("p.Chaos.GC.UseReplicationV2"), GeometryCollectionUseReplicationV2, TEXT("When true use new replication data model"));

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

Scope (from outer to inner):

file
function     void UGeometryCollectionComponent::ResetDynamicCollection

Source code excerpt:

	if (UWorld* World = GetWorld())
	{
		if(World->IsGameWorld() || GeometryCollectionCreatePhysicsStateInEditor)
		{
			bCreateDynamicCollection = true;
		}
	}
#endif
	if (bCreateDynamicCollection && RestCollection && RestCollection->GetGeometryCollection())

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

Scope (from outer to inner):

file
function     void UGeometryCollectionComponent::OnCreatePhysicsState

Source code excerpt:

		}
#endif
		const bool bValidWorld = GetWorld() && (GetWorld()->IsGameWorld() || GetWorld()->IsPreviewWorld() || GeometryCollectionCreatePhysicsStateInEditor);
		const bool bValidCollection = DynamicCollection && DynamicCollection->GetNumTransforms() > 0;
		if (bValidWorld && bValidCollection)
		{
			FChaosUserData::Set<UPrimitiveComponent>(&PhysicsUserData, this);

			// If the Component is set to Dynamic, we look to the RestCollection for initial dynamic state override per transform.