landscape.CollisionMesh.Show

landscape.CollisionMesh.Show

#Overview

name: landscape.CollisionMesh.Show

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.Show is to control the visualization of the landscape collision mesh when the ShowFlags.Collision is enabled. It allows developers to select which heightfield to display for debugging and visualization purposes.

This setting variable is primarily used in the Landscape module of Unreal Engine 5, specifically within the collision system for landscapes. It’s referenced in the LandscapeCollision.cpp file, which is part of the Landscape runtime system.

The value of this variable is set through a console command. It’s initialized with a default value of 1 (EHeightfieldSource::Simple) and can be changed at runtime.

The variable interacts with the ShowFlags.Collision flag and is used to determine which type of collision mesh to display. It works in conjunction with other landscape collision-related variables and systems.

Developers should be aware that:

  1. This variable affects only the visualization of the collision mesh, not the actual collision detection.
  2. It has four possible values: 0 (disable), 1 (simple), 2 (complex), and 3 (editor only).
  3. Changes to this variable trigger a callback (OnCVarLandscapeShowCollisionMeshChanged) that likely updates the rendering of the collision mesh.

Best practices when using this variable include:

  1. Use it primarily for debugging and development purposes.
  2. Be cautious when changing its value in a shipping game, as it may impact performance.
  3. Coordinate its use with other collision visualization tools and settings in Unreal Engine.

Regarding the associated variable CVarLandscapeCollisionMeshShow:

This is the actual C++ variable that corresponds to the console variable landscape.CollisionMesh.Show. It’s an instance of TAutoConsoleVariable, which is Unreal Engine’s way of exposing variables to the console command system.

The purpose of CVarLandscapeCollisionMeshShow is to provide programmatic access to the landscape.CollisionMesh.Show setting within the C++ code. It’s used in the CreateSceneProxy function of the ULandscapeHeightfieldCollisionComponent to determine which type of collision mesh to display.

This variable is set up in the global scope of the LandscapeCollision.cpp file and can be accessed from various parts of the Landscape module. Its value is retrieved using the GetValueOnGameThread() method, which ensures thread-safe access to the current setting.

Developers should be aware that:

  1. Changes to this variable will immediately affect the collision mesh visualization.
  2. It’s marked as ECVF_RenderThreadSafe, meaning it can be safely accessed from the render thread.

Best practices for using CVarLandscapeCollisionMeshShow include:

  1. Use GetValueOnGameThread() when accessing its value to ensure thread safety.
  2. Consider performance implications when frequently querying or changing this value, especially in performance-critical code paths.
  3. Use this variable in conjunction with other landscape and collision-related systems for comprehensive debugging and visualization.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarLandscapeCollisionMeshShow(
	TEXT("landscape.CollisionMesh.Show"),
	static_cast<int>(EHeightfieldSource::Simple),
	TEXT("Selects which heightfield to visualize when ShowFlags.Collision is used. 0 to disable, 1 for simple, 2 for complex, 3 for editor only."),
	FConsoleVariableDelegate::CreateStatic(OnCVarLandscapeShowCollisionMeshChanged),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarLandscapeCollisionMeshHeightOffset(

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

}

static TAutoConsoleVariable<int32> CVarLandscapeCollisionMeshShow(
	TEXT("landscape.CollisionMesh.Show"),
	static_cast<int>(EHeightfieldSource::Simple),
	TEXT("Selects which heightfield to visualize when ShowFlags.Collision is used. 0 to disable, 1 for simple, 2 for complex, 3 for editor only."),
	FConsoleVariableDelegate::CreateStatic(OnCVarLandscapeShowCollisionMeshChanged),
	ECVF_RenderThreadSafe);

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

Scope (from outer to inner):

file
function     FPrimitiveSceneProxy* ULandscapeHeightfieldCollisionComponent::CreateSceneProxy

Source code excerpt:

		FLinearColor WireframeColor;

		switch (static_cast<EHeightfieldSource>(CVarLandscapeCollisionMeshShow.GetValueOnGameThread()))
		{
		case EHeightfieldSource::None:
			WireframeColor = FColor(0, 0, 0, 0);
			break;
		case EHeightfieldSource::Simple:
			if (HeightfieldRef->HeightfieldSimpleGeometry.IsValid())