ShowFlag.CameraAspectRatioBars

ShowFlag.CameraAspectRatioBars

#Overview

name: ShowFlag.CameraAspectRatioBars

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.CameraAspectRatioBars is to control the rendering of camera aspect ratio bars in the Unreal Engine editor viewport. This setting is primarily used for visualization and composition purposes in the editor.

This setting variable is mainly used by the Unreal Engine’s editor subsystem, specifically within the viewport rendering module. It’s primarily referenced in the EditorViewportClient class, which is responsible for managing editor viewport functionality.

The value of this variable is set through the SHOWFLAG_FIXED_IN_SHIPPING macro in the ShowFlagsValues.inl file. It’s initialized to 0, meaning it’s disabled by default.

This variable interacts closely with another setting, CameraSafeFrames. Both are often used together to provide visual guides for camera framing in the editor viewport.

Developers should be aware that this setting is only available in the editor and will not affect the final shipped game. It’s categorized as an advanced show flag, which means it’s not typically exposed in basic user interfaces.

Best practices when using this variable include:

  1. Use it in conjunction with CameraSafeFrames for comprehensive composition guides.
  2. Remember that it’s an editor-only feature, so don’t rely on it for runtime functionality.
  3. Consider performance impact when enabling multiple show flags in complex scenes.

Regarding the associated variable CameraAspectRatioBars:

The purpose of CameraAspectRatioBars is identical to ShowFlag.CameraAspectRatioBars. It’s the actual variable that stores the state of whether the aspect ratio bars should be displayed.

This variable is used in the same subsystem as ShowFlag.CameraAspectRatioBars, primarily within the EditorViewportClient class.

The value of CameraAspectRatioBars is set based on the ShowFlag.CameraAspectRatioBars value. When ShowFlag.CameraAspectRatioBars is 1, CameraAspectRatioBars is considered active.

CameraAspectRatioBars interacts directly with the DrawSafeFrames function in EditorViewportClient, which is responsible for rendering the aspect ratio bars.

Developers should be aware that this variable represents the actual state used for rendering, while ShowFlag.CameraAspectRatioBars is the user-facing setting.

Best practices for using CameraAspectRatioBars include:

  1. Don’t modify this variable directly; instead, use the ShowFlag.CameraAspectRatioBars setting.
  2. When implementing custom viewport rendering, check this variable’s state to determine if aspect ratio bars should be drawn.
  3. Consider performance optimizations in the DrawSafeFrames function if aspect ratio bars are frequently toggled in your project.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(1, Cloud, SFG_Normal, NSLOCTEXT("UnrealEd", "CloudSF", "Cloud"))
/** Render safe frames bars*/
SHOWFLAG_FIXED_IN_SHIPPING(0, CameraAspectRatioBars, SFG_Advanced, NSLOCTEXT("UnrealEd", "CameraAspectRatioBarsSF", "Camera Aspect Ratio Bars"))
/** Render safe frames */
SHOWFLAG_FIXED_IN_SHIPPING(1, CameraSafeFrames, SFG_Advanced, NSLOCTEXT("UnrealEd", "CameraSafeFramesSF", "Camera Safe Frames"))
/** Render TextRenderComponents (3D text), for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(TextRender, SFG_Advanced, NSLOCTEXT("UnrealEd", "TextRenderSF", "Render (3D) Text"))
/** Any rendering/buffer clearing  (good for benchmarking and for pausing rendering while the app is not in focus to save cycles). */
SHOWFLAG_ALWAYS_ACCESSIBLE(Rendering, SFG_Hidden, NSLOCTEXT("UnrealEd", "RenderingSF", "Any Rendering")) // do not make it FIXED_IN_SHIPPING, used by Oculus plugin.

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:2159

Scope (from outer to inner):

file
function     void FEditorViewportClient::DrawSafeFrames

Source code excerpt:

void FEditorViewportClient::DrawSafeFrames(FViewport& InViewport, FSceneView& View, FCanvas& Canvas)
{
	if (EngineShowFlags.CameraAspectRatioBars || EngineShowFlags.CameraSafeFrames)
	{
		FSlateRect SafeRect;
		if (CalculateEditorConstrainedViewRect(SafeRect, &InViewport, Canvas.GetDPIScale()))
		{
			if (EngineShowFlags.CameraSafeFrames)
			{

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:2172

Scope (from outer to inner):

file
function     void FEditorViewportClient::DrawSafeFrames

Source code excerpt:

			}

			if (EngineShowFlags.CameraAspectRatioBars)
			{
				const int32 SizeX = InViewport.GetSizeXY().X;
				const int32 SizeY = InViewport.GetSizeXY().Y;
				FCanvasLineItem LineItem;
				LineItem.SetColor(FLinearColor(0.0f, 0.0f, 0.0f, 0.75f));

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Public/EditorViewportClient.h:1274

Scope (from outer to inner):

file
class        class FEditorViewportClient : public FCommonViewportClient, public FViewElementDrawer, public FGCObject
function     bool IsShowingAspectRatioBarDisplay

Source code excerpt:

	bool IsShowingAspectRatioBarDisplay() const
	{
		return EngineShowFlags.CameraAspectRatioBars == 1;
	}

	bool IsShowingSafeFrameBoxDisplay() const
	{
		return EngineShowFlags.CameraSafeFrames == 1;
	}

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

Scope: file

Source code excerpt:

SHOWFLAG_FIXED_IN_SHIPPING(1, Cloud, SFG_Normal, NSLOCTEXT("UnrealEd", "CloudSF", "Cloud"))
/** Render safe frames bars*/
SHOWFLAG_FIXED_IN_SHIPPING(0, CameraAspectRatioBars, SFG_Advanced, NSLOCTEXT("UnrealEd", "CameraAspectRatioBarsSF", "Camera Aspect Ratio Bars"))
/** Render safe frames */
SHOWFLAG_FIXED_IN_SHIPPING(1, CameraSafeFrames, SFG_Advanced, NSLOCTEXT("UnrealEd", "CameraSafeFramesSF", "Camera Safe Frames"))
/** Render TextRenderComponents (3D text), for now SHOWFLAG_ALWAYS_ACCESSIBLE because it's exposed in SceneCapture */
SHOWFLAG_ALWAYS_ACCESSIBLE(TextRender, SFG_Advanced, NSLOCTEXT("UnrealEd", "TextRenderSF", "Render (3D) Text"))
/** Any rendering/buffer clearing  (good for benchmarking and for pausing rendering while the app is not in focus to save cycles). */
SHOWFLAG_ALWAYS_ACCESSIBLE(Rendering, SFG_Hidden, NSLOCTEXT("UnrealEd", "RenderingSF", "Any Rendering")) // do not make it FIXED_IN_SHIPPING, used by Oculus plugin.