landscape.CollisionMesh.HeightOffset
landscape.CollisionMesh.HeightOffset
#Overview
name: landscape.CollisionMesh.HeightOffset
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Offsets the collision mesh wireframe to assist in viewing from distances where the lower landscape lods might hide it.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of landscape.CollisionMesh.HeightOffset is to offset the collision mesh wireframe of a landscape to improve visibility from distances where lower landscape LODs might obscure it.
This setting variable is primarily used in the Landscape system of Unreal Engine 5. It is specifically utilized in the collision mesh rendering for landscapes.
The value of this variable is set through the console variable system in Unreal Engine. It is defined as a TAutoConsoleVariable with a default value of 0.0f.
The associated variable CVarLandscapeCollisionMeshHeightOffset directly interacts with landscape.CollisionMesh.HeightOffset. They share the same value and purpose.
Developers should be aware that this variable affects the visual representation of the landscape collision mesh and does not affect the actual collision calculations. It’s purely for debugging and visualization purposes.
Best practices when using this variable include:
- Use it sparingly and only when needed for debugging collision issues.
- Remember to reset it to 0.0f after debugging to ensure accurate visual representation.
- Be cautious when using large offset values as they might mislead about the actual collision area.
Regarding the associated variable CVarLandscapeCollisionMeshHeightOffset:
The purpose of CVarLandscapeCollisionMeshHeightOffset is identical to landscape.CollisionMesh.HeightOffset. It’s an implementation detail that allows the console variable system to interact with the game code.
This variable is used in the Landscape module of Unreal Engine, specifically in the collision rendering system.
The value of CVarLandscapeCollisionMeshHeightOffset is set when the console variable landscape.CollisionMesh.HeightOffset is modified.
It interacts directly with the FLandscapeHeightfieldCollisionComponentSceneProxy class, affecting how the collision mesh is rendered.
Developers should be aware that changes to this variable will be reflected in real-time on the render thread.
Best practices for using CVarLandscapeCollisionMeshHeightOffset include:
- Access it using the GetValueOnRenderThread() method when in render thread context.
- Avoid modifying it directly; instead, use the console variable system to change landscape.CollisionMesh.HeightOffset.
- Consider the performance impact of frequently reading this value in performance-critical sections of code.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeCollision.cpp:91
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarLandscapeCollisionMeshHeightOffset(
TEXT("landscape.CollisionMesh.HeightOffset"),
0.0f,
TEXT("Offsets the collision mesh wireframe to assist in viewing from distances where the lower landscape lods might hide it."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<bool> CVarLandscapeCollisionMeshShowPhysicalMaterial(
TEXT("landscape.CollisionMesh.ShowPhysicalMaterial"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarLandscapeCollisionMeshHeightOffset
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeCollision.cpp:90
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<float> CVarLandscapeCollisionMeshHeightOffset(
TEXT("landscape.CollisionMesh.HeightOffset"),
0.0f,
TEXT("Offsets the collision mesh wireframe to assist in viewing from distances where the lower landscape lods might hide it."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<bool> CVarLandscapeCollisionMeshShowPhysicalMaterial(
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeCollision.cpp:689
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 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;
const TUniquePtr<FColoredMaterialRenderProxy>& MaterialToUse = bShowPhysicalMaterial ? VertexColorMaterialInstance : WireframeMaterialInstance;