p.Chaos.MeshContactGenerator.FixContactNormal.FixEnabled
p.Chaos.MeshContactGenerator.FixContactNormal.FixEnabled
#Overview
name: p.Chaos.MeshContactGenerator.FixContactNormal.FixEnabled
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Until new code path is well tested
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.MeshContactGenerator.FixContactNormal.FixEnabled is to control a fix for contact normal calculation in the Chaos physics engine’s mesh contact generator. This setting is specifically related to the collision detection and contact generation system within the Chaos physics module of Unreal Engine 5.
This setting variable is primarily used in the Chaos physics subsystem, which is part of the experimental features in Unreal Engine 5. It’s specifically utilized in the mesh contact generation module.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands. It’s initially set to true, indicating that the fix is enabled by default.
The associated variable bMeshContactGeneratorFixContactNormalFixEnabled directly interacts with this setting. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable controls a fix for an issue with invalid normals on spikey meshes. The comment in the code suggests that this fix was implemented close to a release, and the option to roll back was added as a precaution.
Best practices when using this variable include:
- Testing thoroughly with and without the fix enabled to ensure it doesn’t introduce new issues in your specific use case.
- Monitoring performance impact, if any, when the fix is enabled.
- Being prepared to disable the fix if unexpected behavior occurs, especially on spikey meshes.
Regarding the associated variable bMeshContactGeneratorFixContactNormalFixEnabled:
- Its purpose is the same as p.Chaos.MeshContactGenerator.FixContactNormal.FixEnabled, acting as a boolean flag to control the contact normal fix.
- It’s used directly in the FMeshContactGenerator::FixContactNormal function to determine whether to apply the fix.
- The value is set in the same location as the console variable, ensuring they always have the same value.
- Developers should treat this variable as read-only within their code, as its value is controlled by the console 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/Collision/MeshContactGenerator.cpp:15
Scope (from outer to inner):
file
namespace Chaos::CVars
Source code excerpt:
bool bMeshContactGeneratorFixContactNormalFixEnabled = true;
FAutoConsoleVariableRef CVarChaosMeshContactGeneratorFixContactNormalFixEnabled(TEXT("p.Chaos.MeshContactGenerator.FixContactNormal.FixEnabled"), bMeshContactGeneratorFixContactNormalFixEnabled, TEXT("Until new code path is well tested"));
}
namespace Chaos::Private
{
FMeshContactGeneratorSettings::FMeshContactGeneratorSettings()
{
#Associated Variable and Callsites
This variable is associated with another variable named bMeshContactGeneratorFixContactNormalFixEnabled
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/MeshContactGenerator.cpp:14
Scope (from outer to inner):
file
namespace Chaos::CVars
Source code excerpt:
extern int32 ChaosSolverDebugDrawMeshContacts;
bool bMeshContactGeneratorFixContactNormalFixEnabled = true;
FAutoConsoleVariableRef CVarChaosMeshContactGeneratorFixContactNormalFixEnabled(TEXT("p.Chaos.MeshContactGenerator.FixContactNormal.FixEnabled"), bMeshContactGeneratorFixContactNormalFixEnabled, TEXT("Until new code path is well tested"));
}
namespace Chaos::Private
{
FMeshContactGeneratorSettings::FMeshContactGeneratorSettings()
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/MeshContactGenerator.cpp:261
Scope (from outer to inner):
file
namespace Chaos::Private
function void FMeshContactGenerator::FixContactNormal
Source code excerpt:
// NOTE: the code in the cvar fixes an issue which would leave invalid normals on spikey meshes,
// but we're very close to a release, so adding option to rollback if this version is flased
if (CVars::bMeshContactGeneratorFixContactNormalFixEnabled)
{
const int32 VertexIndexA = ContactPointData.GetVertexID();
FVec3 VertexA;
if (!Triangle.GetVertexWithID(VertexIndexA, VertexA))
{
// @todo(chaos): this is an error condition