p.LevelSetAvgDistErrorTolerance

p.LevelSetAvgDistErrorTolerance

#Overview

name: p.LevelSetAvgDistErrorTolerance

This variable is created as a Console Variable (cvar).

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.LevelSetAvgDistErrorTolerance is to set the error tolerance for the average distance between triangles and the generated levelset in Unreal Engine’s Chaos physics system. This setting is used in the level set generation process, which is part of the physics simulation for collision detection and response.

This setting variable is primarily used in the Chaos physics module, which is an experimental physics engine in Unreal Engine 5. It’s specifically utilized in the levelset generation and validation process.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through the console or configuration files. It’s initialized with a default value of 1.0f.

The p.LevelSetAvgDistErrorTolerance interacts with several other variables:

  1. p.LevelSetMaxDistErrorTolerance
  2. p.LevelSetAvgAngleErrorTolerance
  3. p.LevelSetFailureOnHighError

These variables work together to define the acceptable error margins for generated level sets.

Developers must be aware that:

  1. The tolerance is a fraction of the average bounding box dimensions.
  2. Higher values allow for more error, potentially reducing accuracy but improving performance.
  3. Lower values increase accuracy but may lead to more level set generation failures or performance impacts.

Best practices when using this variable:

  1. Adjust it carefully based on the specific needs of your project, balancing accuracy and performance.
  2. Test thoroughly after changes to ensure physics behavior remains as expected.
  3. Consider using it in conjunction with the other related tolerance variables for comprehensive error control.

Regarding the associated variable AvgDistErrorTolerance: This is the actual float variable that stores the value set by p.LevelSetAvgDistErrorTolerance. It’s used directly in the code to perform error checking calculations. The purpose and usage considerations are the same as for p.LevelSetAvgDistErrorTolerance, as they represent the same value in different contexts (console variable vs. in-memory variable).

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Levelset.cpp:23

Scope: file

Source code excerpt:


Chaos::FRealSingle AvgDistErrorTolerance = 1.f;
FAutoConsoleVariableRef CVarAvgDistErrorTolerance(TEXT("p.LevelSetAvgDistErrorTolerance"), AvgDistErrorTolerance, TEXT("Error tolerance for average distance between the triangles and generated levelset.  Note this is a fraction of the average bounding box dimensions."));

Chaos::FRealSingle MaxDistErrorTolerance = 1.f;
FAutoConsoleVariableRef CVarMaxDistErrorTolerance(TEXT("p.LevelSetMaxDistErrorTolerance"), MaxDistErrorTolerance, TEXT("Max error for the highest error triangle generated from a levelset.  Note this is a fraction of the average bounding box dimensions."));

Chaos::FRealSingle AvgAngleErrorTolerance = 1.;
FAutoConsoleVariableRef CVarAvgAngleErrorTolerance(TEXT("p.LevelSetAvgAngleErrorTolerance"), AvgAngleErrorTolerance, TEXT("Average error in of the mesh normal and computed normal on the level set."));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Levelset.cpp:22

Scope: file

Source code excerpt:

FAutoConsoleVariableRef CVarFailureOnHighError(TEXT("p.LevelSetFailureOnHighError"), FailureOnHighError, TEXT("Set level sets with high error to null in the solver"));

Chaos::FRealSingle AvgDistErrorTolerance = 1.f;
FAutoConsoleVariableRef CVarAvgDistErrorTolerance(TEXT("p.LevelSetAvgDistErrorTolerance"), AvgDistErrorTolerance, TEXT("Error tolerance for average distance between the triangles and generated levelset.  Note this is a fraction of the average bounding box dimensions."));

Chaos::FRealSingle MaxDistErrorTolerance = 1.f;
FAutoConsoleVariableRef CVarMaxDistErrorTolerance(TEXT("p.LevelSetMaxDistErrorTolerance"), MaxDistErrorTolerance, TEXT("Max error for the highest error triangle generated from a levelset.  Note this is a fraction of the average bounding box dimensions."));

Chaos::FRealSingle AvgAngleErrorTolerance = 1.;
FAutoConsoleVariableRef CVarAvgAngleErrorTolerance(TEXT("p.LevelSetAvgAngleErrorTolerance"), AvgAngleErrorTolerance, TEXT("Average error in of the mesh normal and computed normal on the level set."));

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Levelset.cpp:582

Scope (from outer to inner):

file
namespace    Chaos
function     bool FLevelSet::CheckData

Source code excerpt:


	// Report high error, but don't report it as an invalid level set
	if (AvgDistError > AvgDistErrorTolerance*MGrid.Dx().Size() || AvgAngleError > AvgAngleErrorTolerance || MaxDistError > MaxDistErrorTolerance*MGrid.Dx().Size())
	{
		if (OutputFailedLevelSetDebugData)
		{
			FString Prefix = FString::Printf(TEXT("AVGDIST_%f__MAXDIST_%f__ANGLE_%f___"), AvgDistError, MaxDistError, AvgAngleError) + ObjectNamePrefixNoSpace;
			OutputDebugData(ErrorReporter, InParticles, Normals, Mesh, Prefix);
		}

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Levelset.cpp:593

Scope (from outer to inner):

file
namespace    Chaos
function     bool FLevelSet::CheckData

Source code excerpt:

		{
			FString ErrorStr = FString::Printf(TEXT("High error for level set: AvgDistError: %f (Max: %f*%f), MaxDistError: %f (Max: %f*%f), AvgAngleError: %f (Max: %f)"), 
				AvgDistError, AvgDistErrorTolerance, MGrid.Dx().Size(),
				MaxDistError, MaxDistErrorTolerance, MGrid.Dx().Size(),
				AvgAngleError, AvgAngleErrorTolerance);
			ErrorReporter.ReportError(*ErrorStr);
			return false;
		}
		else

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Levelset.cpp:603

Scope (from outer to inner):

file
namespace    Chaos
function     bool FLevelSet::CheckData

Source code excerpt:

			UE_LOG(LogChaos, Log, TEXT("%s: High error for level set: AvgDistError: %f (Max: %f*%f), MaxDistError: %f (Max: %f*%f), AvgAngleError: %f (Max: %f)"), 
				*ErrorReporter.GetPrefix(), 
				AvgDistError, AvgDistErrorTolerance, MGrid.Dx().Size(),
				MaxDistError, MaxDistErrorTolerance, MGrid.Dx().Size(),
				AvgAngleError, AvgAngleErrorTolerance);
		}
	}

	return true;