ShowFlag.BSPTriangles

ShowFlag.BSPTriangles

#Overview

name: ShowFlag.BSPTriangles

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ShowFlag.BSPTriangles is to control the visibility of BSP (Binary Space Partitioning) triangles in the Unreal Engine editor and rendering system. It is primarily used for debugging and visualization purposes in the editor environment.

This setting variable is primarily relied upon by the Unreal Engine’s rendering system, particularly in the following subsystems and modules:

  1. The editor’s viewport rendering system
  2. The model rendering system (ModelRender.cpp)
  3. The actor positioning system in the editor (ActorPositioning.cpp)

The value of this variable is set in the engine’s show flags system, which is typically controlled through the editor’s viewport settings or programmatically. It is defined in the ShowFlagsValues.inl file with a default value of 1 (enabled) for non-shipping builds.

The BSPTriangles variable interacts closely with other show flags, particularly:

Developers should be aware of the following when using this variable:

  1. It is primarily intended for editor and debug use, not for shipping builds.
  2. It affects the visibility of BSP geometry in the editor viewports.
  3. It can impact performance when enabled, especially in scenes with complex BSP geometry.

Best practices when using this variable include:

  1. Use it sparingly and primarily for debugging or level editing purposes.
  2. Disable it when not needed to improve editor performance.
  3. Be aware of its interaction with other show flags, especially BSP and Selection flags.

Regarding the associated variable BSPTriangles:

The purpose of BSPTriangles is the same as ShowFlag.BSPTriangles. It is used interchangeably in the code to refer to the same functionality.

This variable is used in the same subsystems and modules as ShowFlag.BSPTriangles, particularly in the model rendering system and editor viewport.

The value of BSPTriangles is typically set through the engine’s show flags system, similar to ShowFlag.BSPTriangles.

It interacts with the same variables as ShowFlag.BSPTriangles, including EngineShowFlags.BSP and EngineShowFlags.Selection.

Developers should be aware that BSPTriangles and ShowFlag.BSPTriangles are essentially the same setting, just accessed through different naming conventions in different parts of the engine code.

The best practices for using BSPTriangles are the same as those for ShowFlag.BSPTriangles, focusing on its use for debugging and editor visualization while being mindful of potential performance impacts.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:235

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(0, Editor, SFG_Hidden, NSLOCTEXT("UnrealEd", "EditorSF", "Editor"))
/** needed for VMI_BrushWireframe and VMI_LitLightmapDensity, Draws BSP triangles */
SHOWFLAG_FIXED_IN_SHIPPING(1, BSPTriangles, SFG_Hidden, NSLOCTEXT("UnrealEd", "BSPTrianglesSF", "BSP Triangles"))
/** Displays large clickable icons on static mesh vertices, only needed for the editor */
SHOWFLAG_FIXED_IN_SHIPPING(0, LargeVertices, SFG_Advanced, NSLOCTEXT("UnrealEd", "LargeVerticesSF", "Large Vertices"))
/** To show the grid in editor (grey lines and red dots) */
SHOWFLAG_FIXED_IN_SHIPPING(0, Grid, SFG_Normal, NSLOCTEXT("UnrealEd", "GridSF", "Grid"))
/** To show the snap in editor (only for editor view ports, red dots) */
SHOWFLAG_FIXED_IN_SHIPPING(0, Snap, SFG_Hidden, NSLOCTEXT("UnrealEd", "SnapSF", "Snap"))

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Editor/ActorPositioning.cpp:137

Scope (from outer to inner):

file
function     bool IsHitIgnoredRenderingThread

Source code excerpt:

		// Only use this component if it is visible in the specified scene views
		const FPrimitiveViewRelevance ViewRelevance = PrimitiveComponent->SceneProxy->GetViewRelevance(&InSceneView);
		// BSP is a bit special in that its bDrawRelevance is false even when drawn as wireframe because InSceneView.Family->EngineShowFlags.BSPTriangles is off
		const bool bIsRenderedOnScreen = ViewRelevance.bDrawRelevance || (PrimitiveComponent->IsA(UModelComponent::StaticClass()) && InSceneView.Family->EngineShowFlags.BSP);
		const bool bIgnoreTranslucentPrimitive = ViewRelevance.HasTranslucency() && !GetDefault<UEditorPerProjectUserSettings>()->bAllowSelectTranslucent;
		
		return (!bIsRenderedOnScreen && !bConsiderInvisibleComponentForPlacement) || bIgnoreTranslucentPrimitive;
	}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ModelRender.cpp:305

Scope (from outer to inner):

file
class        class FModelSceneProxy final : public FPrimitiveSceneProxy
function     virtual void GetDynamicMeshElements

Source code excerpt:

				bool bShowSelection = GIsEditor && !View->bIsGameView && ViewFamily.EngineShowFlags.Selection;
				bool bDynamicBSPTriangles = bShowSelection || IsRichView(ViewFamily);
				bool bShowBSPTriangles = ViewFamily.EngineShowFlags.BSPTriangles;
				bool bShowBSP = ViewFamily.EngineShowFlags.BSP;

#if WITH_EDITOR
				bool bDrawCollision = false;
				const bool bInCollisionView = IsCollisionView(View, bDrawCollision);
				// draw bsp as dynamic when in collision view mode

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ModelRender.cpp:539

Scope (from outer to inner):

file
class        class FModelSceneProxy final : public FPrimitiveSceneProxy
function     virtual FPrimitiveViewRelevance GetViewRelevance

Source code excerpt:

	{
		FPrimitiveViewRelevance Result;
		Result.bDrawRelevance = IsShown(View) && View->Family->EngineShowFlags.BSPTriangles && View->Family->EngineShowFlags.BSP;
		bool bShowSelectedTriangles = GIsEditor && !View->bIsGameView && View->Family->EngineShowFlags.Selection;
		bool bCollisionView = View->Family->EngineShowFlags.CollisionPawn || View->Family->EngineShowFlags.CollisionVisibility;
		if (IsRichView(*View->Family) || HasViewDependentDPG() || bCollisionView
			|| (bShowSelectedTriangles && HasSelectedSurfaces()))
		{
			Result.bDynamicRelevance = true;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:235

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(0, Editor, SFG_Hidden, NSLOCTEXT("UnrealEd", "EditorSF", "Editor"))
/** needed for VMI_BrushWireframe and VMI_LitLightmapDensity, Draws BSP triangles */
SHOWFLAG_FIXED_IN_SHIPPING(1, BSPTriangles, SFG_Hidden, NSLOCTEXT("UnrealEd", "BSPTrianglesSF", "BSP Triangles"))
/** Displays large clickable icons on static mesh vertices, only needed for the editor */
SHOWFLAG_FIXED_IN_SHIPPING(0, LargeVertices, SFG_Advanced, NSLOCTEXT("UnrealEd", "LargeVerticesSF", "Large Vertices"))
/** To show the grid in editor (grey lines and red dots) */
SHOWFLAG_FIXED_IN_SHIPPING(0, Grid, SFG_Normal, NSLOCTEXT("UnrealEd", "GridSF", "Grid"))
/** To show the snap in editor (only for editor view ports, red dots) */
SHOWFLAG_FIXED_IN_SHIPPING(0, Snap, SFG_Hidden, NSLOCTEXT("UnrealEd", "SnapSF", "Snap"))