landscape.CollisionMesh.ShowPhysicalMaterial

landscape.CollisionMesh.ShowPhysicalMaterial

#Overview

name: landscape.CollisionMesh.ShowPhysicalMaterial

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 landscape.CollisionMesh.ShowPhysicalMaterial is to control the visual representation of physical materials on the landscape collision mesh. This setting is part of the Unreal Engine’s landscape system, specifically related to collision visualization.

This setting variable is primarily used in the Landscape module of Unreal Engine 5. It’s referenced in the LandscapeCollision.cpp file, which is part of the Runtime/Landscape subsystem.

The value of this variable is set as a console variable (CVar) with an initial value of false. It can be changed at runtime through the console or programmatically.

The associated variable CVarLandscapeCollisionMeshShowPhysicalMaterial directly interacts with this setting. They share the same value and purpose.

Developers should be aware that:

  1. This setting is render thread safe, meaning it can be safely accessed from the render thread.
  2. When enabled, it affects the vertex colors of the collision mesh based on the physical material.
  3. It’s used in conjunction with other rendering flags like ViewFamily.EngineShowFlags.Collision and ViewFamily.EngineShowFlags.Landscape.

Best practices when using this variable include:

  1. Use it primarily for debugging or visualization purposes, not for gameplay mechanics.
  2. Be mindful of performance implications when enabling this in large landscapes or complex scenes.
  3. Combine it with other debugging tools to get a comprehensive view of landscape collision behavior.

Regarding the associated variable CVarLandscapeCollisionMeshShowPhysicalMaterial:

Its purpose is identical to landscape.CollisionMesh.ShowPhysicalMaterial, serving as the internal representation of the console variable.

It’s used in the GetDynamicMeshElements function of the FLandscapeHeightfieldCollisionComponentSceneProxy class, which is responsible for generating the visual representation of the landscape collision.

The value is accessed using GetValueOnRenderThread(), ensuring thread-safe access in rendering contexts.

When working with this variable, developers should:

  1. Ensure any modifications are made through the appropriate console commands or engine APIs.
  2. Be aware that changes to this variable will affect the visual debug output of landscape collisions.
  3. Use it in conjunction with other landscape debugging tools for a comprehensive understanding of the collision system.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeCollision.cpp:97

Scope: file

Source code excerpt:


static TAutoConsoleVariable<bool> CVarLandscapeCollisionMeshShowPhysicalMaterial(
	TEXT("landscape.CollisionMesh.ShowPhysicalMaterial"),
	false,
	TEXT("When enabled, vertex colors of the collision mesh are chosen based on the physical material"),
	ECVF_RenderThreadSafe);

static FAutoConsoleVariable CVarAllowPhysicsStripping(
	TEXT("landscape.AllowPhysicsStripping"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeCollision.cpp:96

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<bool> CVarLandscapeCollisionMeshShowPhysicalMaterial(
	TEXT("landscape.CollisionMesh.ShowPhysicalMaterial"),
	false,
	TEXT("When enabled, vertex colors of the collision mesh are chosen based on the physical material"),
	ECVF_RenderThreadSafe);

static FAutoConsoleVariable CVarAllowPhysicsStripping(

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeCollision.cpp:688

Scope (from outer to inner):

file
function     FPrimitiveSceneProxy* ULandscapeHeightfieldCollisionComponent::CreateSceneProxy
class        class FLandscapeHeightfieldCollisionComponentSceneProxy final : public FPrimitiveSceneProxy
function     virtual void GetDynamicMeshElements

Source code excerpt:

			const bool bDrawCollision = ViewFamily.EngineShowFlags.Collision && ViewFamily.EngineShowFlags.Landscape && IsCollisionEnabled();

			const bool bShowPhysicalMaterial = CVarLandscapeCollisionMeshShowPhysicalMaterial.GetValueOnRenderThread();
			const float HeightOffset = CVarLandscapeCollisionMeshHeightOffset.GetValueOnRenderThread();
			FVector ZAxis = LocalToWorldNoScale.GetUnitAxis(EAxis::Z);
			LocalToWorldNoScale = LocalToWorldNoScale.ConcatTranslation(FVector(0.0, 0.0, HeightOffset));
			FBoxSphereBounds Bounds = GetBounds();
			Bounds.Origin += ZAxis * HeightOffset;