a.SkinWeightProfile.LoadByDefaultMode
a.SkinWeightProfile.LoadByDefaultMode
#Overview
name: a.SkinWeightProfile.LoadByDefaultMode
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables/disables run-time optimization to override the original skin weights with a profile designated as the default to replace it. Can be used to optimize memory for specific platforms or devices-1 = disabled0 = static disabled1 = static enabled2 = dynamic disabled3 = dynamic enabled
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of a.SkinWeightProfile.LoadByDefaultMode is to control the run-time optimization for overriding original skin weights with a designated default profile. This setting is primarily used in the animation system of Unreal Engine 5, specifically for managing skin weight profiles in skeletal meshes.
This setting variable is mainly used in the Engine module, particularly in the animation and skeletal mesh subsystems. It’s referenced in the SkinWeightProfile.cpp and SkeletalMesh.cpp files, which are part of the core animation system in Unreal Engine.
The value of this variable is set through the console variable system in Unreal Engine. It’s defined as an FAutoConsoleVariableRef, which allows it to be changed at runtime through console commands or configuration files.
The associated variable GSkinWeightProfilesLoadByDefaultMode interacts directly with a.SkinWeightProfile.LoadByDefaultMode. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable has different behaviors based on its value:
- -1: The feature is disabled
- 0: Static disabled
- 1: Static enabled
- 2: Dynamic disabled
- 3: Dynamic enabled
When using this variable, developers should consider the following best practices:
- Use it judiciously, as it affects memory optimization for specific platforms or devices.
- Be aware of its impact on performance and memory usage, especially when enabling dynamic modes.
- Test thoroughly with different values to ensure the desired behavior is achieved across all target platforms.
- Consider the implications in both editor and runtime environments, as some behaviors (like overriding the base buffer) are restricted in the editor to prevent unintended asset serialization.
Regarding the associated variable GSkinWeightProfilesLoadByDefaultMode: The purpose of GSkinWeightProfilesLoadByDefaultMode is to serve as the internal representation of the a.SkinWeightProfile.LoadByDefaultMode setting. It’s used directly in the C++ code to control the behavior of skin weight profile loading and application.
This variable is used in various functions related to skin weight profile management, such as OverrideBaseBufferSkinWeightData and SetDynamicDefaultSkinWeightProfile. It affects how and when skin weight profiles are applied to skeletal meshes, particularly at different LOD levels.
The value of GSkinWeightProfilesLoadByDefaultMode is set through the console variable system, mirroring a.SkinWeightProfile.LoadByDefaultMode.
Developers should be aware that changes to GSkinWeightProfilesLoadByDefaultMode can trigger immediate updates to skeletal mesh LODs through the OnDefaultProfileCVarsChanged function. This can have performance implications if changed frequently during runtime.
Best practices for using GSkinWeightProfilesLoadByDefaultMode include:
- Avoid changing its value frequently during performance-critical sections of the game.
- Understand its interactions with other skin weight profile-related variables and functions.
- Use it in conjunction with proper LOD management for optimal performance across different hardware configurations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Animation/SkinWeightProfile.cpp:109
Scope: file
Source code excerpt:
int32 GSkinWeightProfilesLoadByDefaultMode = -1;
FAutoConsoleVariableRef CVarSkinWeightsLoadByDefaultMode(
TEXT("a.SkinWeightProfile.LoadByDefaultMode"),
GSkinWeightProfilesLoadByDefaultMode,
TEXT("Enables/disables run-time optimization to override the original skin weights with a profile designated as the default to replace it. Can be used to optimize memory for specific platforms or devices")
TEXT("-1 = disabled")
TEXT("0 = static disabled")
TEXT("1 = static enabled")
TEXT("2 = dynamic disabled")
#Associated Variable and Callsites
This variable is associated with another variable named GSkinWeightProfilesLoadByDefaultMode
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Animation/SkinWeightProfile.cpp:67
Scope (from outer to inner):
file
function static void OnDefaultProfileCVarsChanged
Source code excerpt:
static void OnDefaultProfileCVarsChanged(IConsoleVariable* Variable)
{
if (GSkinWeightProfilesLoadByDefaultMode >= 0)
{
const bool bClearBuffer = GSkinWeightProfilesLoadByDefaultMode == 2 || GSkinWeightProfilesLoadByDefaultMode == 0;
const bool bSetBuffer = GSkinWeightProfilesLoadByDefaultMode == 3;
if (bClearBuffer || bSetBuffer)
{
// Make sure no pending skeletal mesh LOD updates
if (IStreamingManager::Get_Concurrent() && IStreamingManager::Get().IsRenderAssetStreamingEnabled(EStreamableRenderAssetType::SkeletalMesh))
{
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Animation/SkinWeightProfile.cpp:107
Scope: file
Source code excerpt:
}
int32 GSkinWeightProfilesLoadByDefaultMode = -1;
FAutoConsoleVariableRef CVarSkinWeightsLoadByDefaultMode(
TEXT("a.SkinWeightProfile.LoadByDefaultMode"),
GSkinWeightProfilesLoadByDefaultMode,
TEXT("Enables/disables run-time optimization to override the original skin weights with a profile designated as the default to replace it. Can be used to optimize memory for specific platforms or devices")
TEXT("-1 = disabled")
TEXT("0 = static disabled")
TEXT("1 = static enabled")
TEXT("2 = dynamic disabled")
TEXT("3 = dynamic enabled"),
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Animation/SkinWeightProfile.cpp:262
Scope (from outer to inner):
file
function void FSkinWeightProfilesData::OverrideBaseBufferSkinWeightData
Source code excerpt:
void FSkinWeightProfilesData::OverrideBaseBufferSkinWeightData(USkeletalMesh* Mesh, int32 LODIndex)
{
if (GSkinWeightProfilesLoadByDefaultMode == 1)
{
const TArray<FSkinWeightProfileInfo>& Profiles = Mesh->GetSkinWeightProfiles();
// Try and find a default buffer and whether or not it is set for this LOD index
int32 DefaultProfileIndex = INDEX_NONE;
// Setup to not apply any skin weight profiles at this LOD level
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Animation/SkinWeightProfile.cpp:310
Scope (from outer to inner):
file
function void FSkinWeightProfilesData::SetDynamicDefaultSkinWeightProfile
Source code excerpt:
}
if (GSkinWeightProfilesLoadByDefaultMode == 3)
{
const TArray<FSkinWeightProfileInfo>& Profiles = Mesh->GetSkinWeightProfiles();
// Try and find a default buffer and whether or not it is set for this LOD index
const int32 DefaultProfileIndex = Profiles.IndexOfByPredicate([LODIndex](FSkinWeightProfileInfo ProfileInfo)
{
// Setup to not apply any skin weight profiles at this LOD level
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMesh.cpp:5831
Scope (from outer to inner):
file
function void USkeletalMesh::SetSkinWeightProfilesData
Source code excerpt:
{
#if !WITH_EDITOR
if (GSkinWeightProfilesLoadByDefaultMode == 1)
{
// Only allow overriding the base buffer in non-editor builds as it could otherwise be serialized into the asset
SkinWeightProfilesData.OverrideBaseBufferSkinWeightData(this, LODIndex);
}
else
#endif
if (GSkinWeightProfilesLoadByDefaultMode == 3)
{
SkinWeightProfilesData.SetDynamicDefaultSkinWeightProfile(this, LODIndex, true);
}
}
FSkinWeightProfilesData* USkeletalMesh::GetSkinWeightProfilesData(int32 LODIndex)
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/Animation/SkinWeightProfile.h:22
Scope: file
Source code excerpt:
}
extern ENGINE_API int32 GSkinWeightProfilesLoadByDefaultMode;
extern ENGINE_API int32 GSkinWeightProfilesDefaultLODOverride;
extern ENGINE_API int32 GSkinWeightProfilesAllowedFromLOD;
extern ENGINE_API FAutoConsoleVariableRef CVarSkinWeightsLoadByDefaultMode;
extern ENGINE_API FAutoConsoleVariableRef CVarSkinWeightProfilesDefaultLODOverride;
extern ENGINE_API FAutoConsoleVariableRef CVarSkinWeightProfilesAllowedFromLOD;