bUsePowerOf2SnapSize
bUsePowerOf2SnapSize
#Overview
name: bUsePowerOf2SnapSize
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 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of bUsePowerOf2SnapSize is to control the grid snapping behavior in the Unreal Engine editor, specifically in the Level Editor viewports. It determines whether the grid snap sizes should use power-of-two values or decimal values.
This setting variable is primarily used by the Unreal Engine’s editor subsystem, particularly the Level Editor and viewport-related modules. It’s referenced in the UnrealEd module, which is responsible for many editor functionalities.
The value of this variable is set in the LevelEditorViewportSettings class, which is part of the editor’s configuration. It can be modified through the editor’s settings interface or programmatically.
bUsePowerOf2SnapSize interacts with several other variables, notably:
- DecimalGridSizes: Used when bUsePowerOf2SnapSize is false.
- Pow2GridSizes: Used when bUsePowerOf2SnapSize is true.
- Pow2GridIntervals and DecimalGridIntervals: Used for determining grid intervals based on the snap size type.
Developers should be aware that changing this variable affects:
- The grid snap sizes available in the Level Editor.
- The BSP (Binary Space Partitioning) texel scale, which is set to 128.0f when true and 100.0f when false.
- The behavior of various snapping and grid-related functions in the editor.
Best practices when using this variable include:
- Consider the project’s specific needs when choosing between power-of-two and decimal grid sizes.
- Be aware that changing this setting may affect existing level layouts and snapped objects.
- Ensure consistency across the project to avoid confusion in multi-user environments.
- When programmatically changing this value, consider updating related settings and notifying users of the change.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:351, section: [/Script/UnrealEd.LevelEditorViewportSettings]
- INI Section:
/Script/UnrealEd.LevelEditorViewportSettings
- Raw value:
False
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/LevelEditorViewportSettings.h:397
Scope (from outer to inner):
file
class class ULevelEditorViewportSettings : public UObject
Source code excerpt:
/** If enabled will use power of 2 grid settings (e.g, 1,2,4,8,16,...,1024) instead of decimal grid sizes */
UPROPERTY(EditAnywhere, config, Category=GridSnapping, meta=(DisplayName = "Use Power of Two Snap Size"))
bool bUsePowerOf2SnapSize;
/** Decimal grid sizes (for translation snapping and grid rendering) */
UPROPERTY(EditAnywhere, config, AdvancedDisplay, Category=GridSnapping)
TArray<float> DecimalGridSizes;
/** The number of lines between each major line interval for decimal grids */
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorConstraints.cpp:27
Scope (from outer to inner):
file
function bool UEditorEngine::IsGridSizePowerOfTwo
Source code excerpt:
const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
return ViewportSettings->bUsePowerOf2SnapSize;
}
void UEditorEngine::SetGridSize( int32 InIndex )
{
FinishAllSnaps();
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorConstraints.cpp:60
Scope (from outer to inner):
file
function const TArray<float>& UEditorEngine::GetCurrentPositionGridArray
Source code excerpt:
const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
return (ViewportSettings->bUsePowerOf2SnapSize) ?
ViewportSettings->Pow2GridSizes :
ViewportSettings->DecimalGridSizes;
}
const TArray<float>& UEditorEngine::GetCurrentIntervalGridArray() const
{
const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
return (ViewportSettings->bUsePowerOf2SnapSize ?
ViewportSettings->Pow2GridIntervals :
ViewportSettings->DecimalGridIntervals);
}
FRotator UEditorEngine::GetRotGridSize()
{
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorEngine.cpp:1202
Scope (from outer to inner):
file
function void UEditorEngine::Init
Source code excerpt:
float BSPTexelScale = 100.0f;
if( GetDefault<ULevelEditorViewportSettings>()->bUsePowerOf2SnapSize )
{
BSPTexelScale=128.0f;
}
UModel::SetGlobalBSPTexelScale(BSPTexelScale);
GLog->EnableBacklog( false );
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/STransformViewportToolbar.cpp:786
Scope (from outer to inner):
file
function TSharedRef<SWidget> STransformViewportToolBar::FillLocationGridSnapMenu
Source code excerpt:
const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
return BuildLocationGridCheckBoxList("Snap", LOCTEXT("LocationSnapText", "Snap Sizes"), ViewportSettings->bUsePowerOf2SnapSize ? ViewportSettings->Pow2GridSizes : ViewportSettings->DecimalGridSizes );
}
TSharedRef<SWidget> STransformViewportToolBar::BuildLocationGridCheckBoxList(FName InExtentionHook, const FText& InHeading, const TArray<float>& InGridSizes) const
{
const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:1027
Scope (from outer to inner):
file
function void ULevelEditorViewportSettings::PostEditChangeProperty
Source code excerpt:
}
}
else if (Name == GET_MEMBER_NAME_CHECKED(ULevelEditorViewportSettings, bUsePowerOf2SnapSize))
{
const float BSPSnapSize = bUsePowerOf2SnapSize ? 128.0f : 100.0f;
UModel::SetGlobalBSPTexelScale(BSPSnapSize);
}
else if (Name == GET_MEMBER_NAME_CHECKED(ULevelEditorViewportSettings, BillboardScale))
{
UBillboardComponent::SetEditorScale(BillboardScale);
UArrowComponent::SetEditorScale(BillboardScale);