bCenterZoomAroundCursor
bCenterZoomAroundCursor
#Overview
name: bCenterZoomAroundCursor
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of bCenterZoomAroundCursor is to control the zooming behavior in orthographic viewports within the Unreal Engine editor. Specifically, it determines whether zooming should center around the cursor position or the center of the viewport.
This setting variable is primarily used by the editor’s viewport system, particularly in the LevelEditor module. It is referenced in the CurveEditorViewportClient and EditorViewportClient classes, which are responsible for handling user input and view manipulation in the editor’s viewports.
The value of this variable is set in the LevelEditorViewportSettings class, which is part of the UnrealEd module. It is defined as a configuration property, meaning its value can be persisted and loaded from configuration files.
bCenterZoomAroundCursor interacts with other viewport-related variables and functions, such as GetOrthoZoom(), SetOrthoZoom(), and GetOrthoUnitsPerPixel(). It is used in conjunction with mouse input handling and viewport size calculations to determine the new view location after zooming.
Developers should be aware that this variable only affects orthographic viewports, not perspective views. It’s also important to note that this setting is user-configurable, so the behavior may change based on user preferences.
Best practices when using this variable include:
- Respecting the user’s setting and not overriding it unnecessarily in custom viewport implementations.
- When implementing custom zooming functionality, checking this variable to maintain consistent behavior with the rest of the editor.
- Considering the performance implications of centering zoom around the cursor, as it requires additional calculations compared to zooming around the viewport center.
- Ensuring that any custom viewport controls or tools that involve zooming take this setting into account for a consistent user experience.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:326, section: [/Script/UnrealEd.LevelEditorViewportSettings]
- INI Section:
/Script/UnrealEd.LevelEditorViewportSettings
- Raw value:
True
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/DistCurveEditor/Private/CurveEditorViewportClient.cpp:601
Scope (from outer to inner):
file
function bool FCurveEditorViewportClient::InputKey
Source code excerpt:
float NewEndOut = SharedData->EndOut - DeltaOut;
if (GetDefault<ULevelEditorViewportSettings>()->bCenterZoomAroundCursor)
{
float MouseX = Viewport->GetMouseX()-LabelWidth;
float MouseY = Viewport->GetMouseY();
float ViewportWidth = Viewport->GetSizeXY().X-LabelWidth;
float ViewportHeight = Viewport->GetSizeXY().Y;
check(ViewportWidth > 0);
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/LevelEditorViewportSettings.h:295
Scope (from outer to inner):
file
class class ULevelEditorViewportSettings : public UObject
Source code excerpt:
/** If checked, in orthographic view ports zooming will center on the mouse position. If unchecked, the zoom is around the center of the viewport. */
UPROPERTY(EditAnywhere, config, Category=Controls, meta=(DisplayName = "Orthographic Zoom to Cursor Position"))
uint32 bCenterZoomAroundCursor:1;
/** The closest possible distance allowed when viewing through an orthographic camera */
UPROPERTY(EditAnywhere, config, Category = Controls, meta=(UIMin = "1.0", ClampMin = "1.0"))
float MinimumOrthographicZoom;
/** Allow translate/rotate widget */
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:3680
Scope (from outer to inner):
file
function void FEditorViewportClient::OnOrthoZoom
Source code excerpt:
FVector OldOffsetFromCenter;
const bool bCenterZoomAroundCursor = GetDefault<ULevelEditorViewportSettings>()->bCenterZoomAroundCursor && (Key == EKeys::MouseScrollDown || Key == EKeys::MouseScrollUp );
if (bCenterZoomAroundCursor)
{
//Y is actually backwards, but since we're move the camera opposite the cursor to center, we negate both
//therefore the x is negated
//X Is backwards, negate it
//default to viewport mouse position
int32 CenterX = InputStateViewport->GetMouseX();
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:3733
Scope (from outer to inner):
file
function void FEditorViewportClient::OnOrthoZoom
Source code excerpt:
SetOrthoZoom( FMath::Clamp<float>( GetOrthoZoom(), GetMinimumOrthoZoom(), MAX_ORTHOZOOM ) );
if (bCenterZoomAroundCursor)
{
//This is the equivalent to moving the viewport to center about the cursor, zooming, and moving it back a proportional amount towards the cursor
FVector FinalDelta = (GetOrthoUnitsPerPixel(Viewport) - OldUnitsPerPixel)*OldOffsetFromCenter;
//now move the view location proportionally
SetViewLocation( GetViewLocation() + FinalDelta );