p.NormalAveraging2

p.NormalAveraging2

#Overview

name: p.NormalAveraging2

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

It is referenced in 14 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.NormalAveraging2 is to control normal averaging in collision detection and resolution within the Chaos physics system of Unreal Engine 5. This setting variable is used to determine whether normal averaging should be applied when sampling collision objects for contact points.

Regarding the associated variable NormalAveraging:

The purpose of NormalAveraging is to serve as the actual control flag for normal averaging operations within the collision resolution code. It’s directly used in conditional statements to determine whether normal averaging should be performed.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:158

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions

Source code excerpt:


		int32 NormalAveraging = 0;
		FAutoConsoleVariableRef CVarNormalAveraging(TEXT("p.NormalAveraging2"), NormalAveraging, TEXT(""));

		int32 SampleMinParticlesForAcceleration = 2048;
		FAutoConsoleVariableRef CVarSampleMinParticlesForAcceleration(TEXT("p.SampleMinParticlesForAcceleration"), SampleMinParticlesForAcceleration, TEXT("The minimum number of particles needed before using an acceleration structure when sampling"));


#if INTEL_ISPC && 0

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:157

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions

Source code excerpt:

		DECLARE_CYCLE_STAT(TEXT("TPBDCollisionConstraints::SampleObject"), STAT_SampleObject, STATGROUP_ChaosWide);

		int32 NormalAveraging = 0;
		FAutoConsoleVariableRef CVarNormalAveraging(TEXT("p.NormalAveraging2"), NormalAveraging, TEXT(""));

		int32 SampleMinParticlesForAcceleration = 2048;
		FAutoConsoleVariableRef CVarSampleMinParticlesForAcceleration(TEXT("p.SampleMinParticlesForAcceleration"), SampleMinParticlesForAcceleration, TEXT("The minimum number of particles needed before using an acceleration structure when sampling"));


#if INTEL_ISPC && 0

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:209

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     FContactPoint SampleObject

Source code excerpt:

						const TUniformGrid<FReal, 3>& Grid = LevelSet->GetGrid();

						if (NormalAveraging && UpdateType != ECollisionUpdateType::Any)
						{
							ispc::SampleLevelSetNormalAverage(
								(ispc::FVector&)Grid.MinCorner(),
								(ispc::FVector&)Grid.MaxCorner(),
								(ispc::FVector&)Grid.Dx(),
								(ispc::FIntVector&)Grid.Counts(),

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:254

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     FContactPoint SampleObject

Source code excerpt:

						const FVec3 BoxMax = Box->Max();

						if (NormalAveraging && UpdateType != ECollisionUpdateType::Any)
						{
							ispc::SampleBoxNormalAverage(
								(ispc::FVector&)BoxMin,
								(ispc::FVector&)BoxMax,
								(ispc::FTransform&)SampleToObjectTM,
								(ispc::FVector*)&SampleParticles.XArray()[0],

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:291

Scope (from outer to inner):

file
namespace    Collisions
function     FContactPoint SampleObject

Source code excerpt:

						for (int32 i : PotentialParticles)
						{
							if (NormalAveraging && UpdateType != ECollisionUpdateType::Any)
							{
								SampleObjectNormalAverageHelper(Object, ObjectTransform, SampleToObjectTM, SampleParticles.X(i), CullingDistance, WeightSum, AvgContact);
							}
							else
							{
								if (SampleObjectNoNormal(Object, ObjectTransform, SampleToObjectTM, SampleParticles.X(i), CullingDistance, AvgContact))

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:319

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     FContactPoint SampleObject

Source code excerpt:

					const TUniformGrid<FReal, 3>& Grid = LevelSet->GetGrid();

					if (NormalAveraging && UpdateType != ECollisionUpdateType::Any)
					{
						ispc::SampleLevelSetNormalAverageAll(
							(ispc::FVector&)Grid.MinCorner(),
							(ispc::FVector&)Grid.MaxCorner(),
							(ispc::FVector&)Grid.Dx(),
							(ispc::FIntVector&)Grid.Counts(),

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:359

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     FContactPoint SampleObject

Source code excerpt:

					const TPlane<FReal, 3>* Plane = Object.GetObject<Chaos::TPlane<FReal, 3>>();

					if (NormalAveraging && UpdateType != ECollisionUpdateType::Any)
					{
						ispc::SamplePlaneNormalAverageAll(
							(ispc::FVector&)Plane->Normal(),
							(ispc::FVector&)Plane->X(),
							(ispc::FTransform&)SampleToObjectTM,
							(ispc::FVector*)&SampleParticles.XArray()[0],

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:393

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     FContactPoint SampleObject

Source code excerpt:

					const TSphere<FReal, 3>* Sphere = Object.GetObject<Chaos::TSphere<FReal, 3>>();

					if (NormalAveraging && UpdateType != ECollisionUpdateType::Any)
					{
						ispc::SampleSphereNormalAverageAll(
							Sphere->GetRadius(),
							(ispc::FVector&)Sphere->GetCenter(),
							(ispc::FTransform&)SampleToObjectTM,
							(ispc::FVector*) & SampleParticles.XArray()[0],

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:429

Scope (from outer to inner):

file
namespace    Collisions
function     FContactPoint SampleObject

Source code excerpt:

					const FVec3 BoxMax = Box->Max();

					if (NormalAveraging && UpdateType != ECollisionUpdateType::Any)
					{
						ispc::SampleBoxNormalAverageAll(
							(ispc::FVector&)BoxMin,
							(ispc::FVector&)BoxMax,
							(ispc::FTransform&)SampleToObjectTM,
							(ispc::FVector*)&SampleParticles.XArray()[0],

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:464

Scope (from outer to inner):

file
function     FContactPoint SampleObject

Source code excerpt:

					for (int32 i = 0; i < NumParticles; ++i)
					{
						if (NormalAveraging && UpdateType != ECollisionUpdateType::Any)
						{
							SampleObjectNormalAverageHelper(Object, ObjectTransform, SampleToObjectTM, SampleParticles.X(i), CullingDistance, WeightSum, AvgContact);
						}
						else
						{
							if (SampleObjectNoNormal(Object, ObjectTransform, SampleToObjectTM, SampleParticles.X(i), CullingDistance, AvgContact))

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:484

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     FContactPoint SampleObject

Source code excerpt:

			}

			if (NormalAveraging)
			{
				if (WeightSum < -KINDA_SMALL_NUMBER)
				{
					FVec3 LocalPoint = AvgContact.ShapeContactPoints[0] / WeightSum;
					FVec3 LocalNormal;
					const FReal NewPhi = Object.PhiWithNormal(LocalPoint, LocalNormal);

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:553

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     FContactPoint SampleObject

Source code excerpt:

					for (int32 i : PotentialParticles)
					{
						if (NormalAveraging && UpdateType != ECollisionUpdateType::Any)	//if we just want one don't bother with normal
						{
							SampleObjectNormalAverageHelper(Object, ObjectTransform, SampleToObjectTM, SampleParticles.GetX(i), CullingDistance, WeightSum, AvgContact);
						}
						else
						{
							if (SampleObjectNoNormal(Object, ObjectTransform, SampleToObjectTM, SampleParticles.GetX(i), CullingDistance, AvgContact))

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:577

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     FContactPoint SampleObject

Source code excerpt:

				for (int32 i = 0; i < NumParticles; ++i)
				{
					if (NormalAveraging && UpdateType != ECollisionUpdateType::Any)	//if we just want one don't bother with normal
					{
						const bool bInside = SampleObjectNormalAverageHelper(Object, ObjectTransform, SampleToObjectTM, SampleParticles.GetX(i), CullingDistance, WeightSum, AvgContact);
					}
					else
					{
						if (SampleObjectNoNormal(Object, ObjectTransform, SampleToObjectTM, SampleParticles.GetX(i), CullingDistance, AvgContact))

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/CollisionResolutionUtil.cpp:596

Scope (from outer to inner):

file
namespace    Chaos
namespace    Collisions
function     FContactPoint SampleObject

Source code excerpt:

			}

			if (NormalAveraging)
			{
				if (WeightSum < -UE_KINDA_SMALL_NUMBER)
				{
					FVec3 LocalPoint = AvgContact.ShapeContactPoints[0] / WeightSum;
					FVec3 LocalNormal;
					const FReal NewPhi = Object.PhiWithNormal(LocalPoint, LocalNormal);