p.gc.UseLargestClusterToComputeRelativeSize
p.gc.UseLargestClusterToComputeRelativeSize
#Overview
name: p.gc.UseLargestClusterToComputeRelativeSize
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Use the largest Cluster as reference for the releative size instead of the largest child (def: false)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.gc.UseLargestClusterToComputeRelativeSize is to control the method of computing relative size in the Geometry Collection system of Unreal Engine’s Chaos physics engine. Specifically, it determines whether to use the largest cluster or the largest child as a reference for calculating relative sizes.
This setting variable is primarily used in the Geometry Collection subsystem, which is part of the Chaos physics module in Unreal Engine 5. It’s referenced in the GeometryCollectionConvexUtility.cpp file, which suggests it’s involved in convex hull calculations for geometry collections.
The value of this variable is set through an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands. By default, it’s set to false.
Interestingly, this variable interacts with another variable named UseVolumeToComputeRelativeSize. In fact, there seems to be a mistake in the code where the CVarUseMaxClusterToComputeRelativeSize console variable is actually setting UseVolumeToComputeRelativeSize instead of UseLargestClusterToComputeRelativeSize.
Developers must be aware of this apparent bug in the code. The intention seems to be to have two separate variables (UseLargestClusterToComputeRelativeSize and UseVolumeToComputeRelativeSize), but due to the error, they are effectively sharing the same value.
Best practices when using this variable would include:
- Be aware of the potential bug and its implications.
- If you need to use this setting, consider fixing the bug first by changing the console variable to set UseLargestClusterToComputeRelativeSize instead of UseVolumeToComputeRelativeSize.
- Use this setting in conjunction with UseVolumeToComputeRelativeSize to fine-tune the relative size calculations for your specific use case.
Regarding the associated variable UseVolumeToComputeRelativeSize:
The purpose of UseVolumeToComputeRelativeSize is to determine whether to use volume or the side of the cubic volume when computing relative sizes in the Geometry Collection system.
This variable is also part of the Geometry Collection subsystem in the Chaos physics module. It’s used in the GetRelativeSizeDimensionFromVolume function, which suggests it’s involved in calculations related to the dimensions of geometry collections.
Like UseLargestClusterToComputeRelativeSize, this variable is set through an FAutoConsoleVariableRef and defaults to false. It can be modified at runtime through console commands.
As mentioned earlier, there’s an interaction (and a bug) with UseLargestClusterToComputeRelativeSize, where both variables are effectively sharing the same value due to an error in the console variable setup.
Developers should be aware that when UseVolumeToComputeRelativeSize is true, the GetRelativeSizeDimensionFromVolume function will return the volume directly. When it’s false, it returns the cube root of the volume, effectively giving the side length of a cube with that volume.
Best practices for using this variable include:
- Understand how it affects your relative size calculations and choose the appropriate setting based on your specific requirements.
- Be aware of its interaction with UseLargestClusterToComputeRelativeSize and the potential bug.
- Consider the performance implications of using volume versus side length in your calculations.
#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:22
Scope: file
Source code excerpt:
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 },
#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);