p.gc.UseVolumeToComputeRelativeSize

p.gc.UseVolumeToComputeRelativeSize

#Overview

name: p.gc.UseVolumeToComputeRelativeSize

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.gc.UseVolumeToComputeRelativeSize is to determine the method used for computing relative size in geometry collections within Unreal Engine’s Chaos physics system. Specifically, it controls whether to use volume or the side of the cubic volume for this calculation.

This setting variable is primarily used in the Experimental Chaos module of Unreal Engine, particularly in the geometry collection subsystem. Based on the callsites, it’s utilized in the GeometryCollectionConvexUtility.cpp file, which is part of the physics simulation for destructible objects.

The value of this variable is set through a console variable (CVar) system. It’s initialized as a boolean with a default value of false, and can be changed at runtime using the console command “p.gc.UseVolumeToComputeRelativeSize”.

There is an associated variable named UseVolumeToComputeRelativeSize that directly interacts with this setting. They share the same value and are used interchangeably in the code.

Developers must be aware that changing this variable will affect how relative sizes are computed in geometry collections. When set to true, it uses the actual volume for calculations, while false (default) uses the side of the cubic volume.

Best practices when using this variable include:

  1. Consider the performance implications of using volume vs. cubic side for calculations.
  2. Test thoroughly when changing this setting, as it may affect physics simulations and destructible object behavior.
  3. Document any changes to this setting in project configuration to ensure consistency across the development team.

Regarding the associated variable UseVolumeToComputeRelativeSize:

Developers should be mindful of the performance and accuracy trade-offs when toggling between these calculation methods, and ensure that the chosen method aligns with the specific requirements of their geometry collection implementations.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/GeometryCollection/GeometryCollectionConvexUtility.cpp:19

Scope: file

Source code excerpt:


bool UseVolumeToComputeRelativeSize = false;
FAutoConsoleVariableRef CVarUseVolumeToComputeRelativeSize(TEXT("p.gc.UseVolumeToComputeRelativeSize"), UseVolumeToComputeRelativeSize, TEXT("Use Volume To Compute RelativeSize instead of the side of the cubic volume (def: false)"));

bool UseLargestClusterToComputeRelativeSize = false;
FAutoConsoleVariableRef CVarUseMaxClusterToComputeRelativeSize(TEXT("p.gc.UseLargestClusterToComputeRelativeSize"), UseVolumeToComputeRelativeSize, TEXT("Use the largest Cluster as reference for the releative size instead of the largest child (def: false)"));

static const Chaos::FVec3f IcoSphere_Subdiv0[] =
{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/GeometryCollection/GeometryCollectionConvexUtility.cpp:15

Scope: file

Source code excerpt:

#include "Operations/MeshBoolean.h"
#include "Operations/MeshSelfUnion.h"
#include "MeshQueries.h"
#include "GeometryCollection/GeometryCollectionClusteringUtility.h"

bool UseVolumeToComputeRelativeSize = false;
FAutoConsoleVariableRef CVarUseVolumeToComputeRelativeSize(TEXT("p.gc.UseVolumeToComputeRelativeSize"), UseVolumeToComputeRelativeSize, TEXT("Use Volume To Compute RelativeSize instead of the side of the cubic volume (def: false)"));

bool UseLargestClusterToComputeRelativeSize = false;
FAutoConsoleVariableRef CVarUseMaxClusterToComputeRelativeSize(TEXT("p.gc.UseLargestClusterToComputeRelativeSize"), UseVolumeToComputeRelativeSize, TEXT("Use the largest Cluster as reference for the releative size instead of the largest child (def: false)"));

static const Chaos::FVec3f IcoSphere_Subdiv0[] =
{
	{  0.000000f,  0.000000f, -1.000000f },
	{  0.525720f,  0.723600f, -0.447215f },
	{  0.850640f, -0.276385f, -0.447215f },
	{  0.000000f, -0.894425f, -0.447215f },
	{ -0.850640f, -0.276385f, -0.447215f },
	{ -0.525720f,  0.723600f, -0.447215f },
	{  0.850640f,  0.276385f,  0.447215f },
	{  0.525720f, -0.723600f,  0.447215f },

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

Scope (from outer to inner):

file
function     static float GetRelativeSizeDimensionFromVolume

Source code excerpt:

	}
}

static float GetRelativeSizeDimensionFromVolume(const float Volume)
{
	if (UseVolumeToComputeRelativeSize)
	{
		return Volume;
	}
	return FGenericPlatformMath::Pow(Volume, 1.0f / 3.0f);
}

void FGeometryCollectionConvexUtility::SetVolumeAttributes(FManagedArrayCollection* Collection)
{
	TManagedArray<float>& Volumes = Collection->AddAttribute<float>("Volume", FTransformCollection::TransformGroup);
	TManagedArray<float>& Sizes = Collection->AddAttribute<float>("Size", FTransformCollection::TransformGroup);