DefaultDeformer

DefaultDeformer

#Overview

name: DefaultDeformer

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 DefaultDeformer is to provide a default mesh deformer for skinned meshes in Unreal Engine’s animation system. It is specifically used within the DeformerGraph plugin, which is part of the animation subsystem in Unreal Engine 5.

The DeformerGraph plugin and the OptimusSettings module rely on this setting variable. It is primarily used in the FOptimusSettingsModule class, which is responsible for managing Optimus settings and providing default mesh deformers.

The value of this variable is set in the UOptimusSettings class, which inherits from UDeveloperSettings. It is defined as a config property, meaning it can be configured in the project settings.

DefaultDeformer interacts with another variable called DefaultRecomputeTangentDeformer. Both are used to provide default deformers for skinned meshes, with the latter specifically used when the mesh has requested to recompute tangents.

Developers must be aware that the usage of DefaultDeformer is conditional. It is only loaded and used when the DefaultMode in the settings is not set to EOptimusDefaultDeformerMode::Never. Additionally, it is stored as a TSoftObjectPtr, which means it is loaded asynchronously to improve performance.

Best practices when using this variable include:

  1. Ensure that a valid deformer is assigned in the project settings if you want to use the default deformer functionality.
  2. Consider the performance implications of loading the default deformer, especially in performance-critical scenarios.
  3. Be aware of the interaction between DefaultDeformer and DefaultRecomputeTangentDeformer, and set them appropriately based on your project’s needs.
  4. When creating custom deformers, consider whether they should be used as default deformers and update the settings accordingly.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Plugins/Animation/DeformerGraph/Config/BaseDeformerGraph.ini:46, section: [/Script/OptimusSettings.OptimusSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Animation/DeformerGraph/Source/OptimusSettings/Private/OptimusSettingsModule.cpp:84

Scope (from outer to inner):

file
function     void FOptimusSettingsModule::CacheDefaultMeshDeformers

Source code excerpt:

{
	const bool bLoadDeformers = InSettings != nullptr && InSettings->DefaultMode != EOptimusDefaultDeformerMode::Never;
	DefaultDeformer = TStrongObjectPtr<UMeshDeformer>(bLoadDeformers && !InSettings->DefaultDeformer.IsNull() ? InSettings->DefaultDeformer.LoadSynchronous() : nullptr);
	DefaultRecomputeTangentDeformer = TStrongObjectPtr<UMeshDeformer>(bLoadDeformers && !InSettings->DefaultRecomputeTangentDeformer.IsNull() ? InSettings->DefaultRecomputeTangentDeformer.LoadSynchronous() : nullptr);
}

TObjectPtr<UMeshDeformer> FOptimusSettingsModule::GetDefaultMeshDeformer(FDefaultMeshDeformerSetup const& Setup)
{
	const UOptimusSettings* Settings = GetDefault<UOptimusSettings>();

#Loc: <Workspace>/Engine/Plugins/Animation/DeformerGraph/Source/OptimusSettings/Private/OptimusSettingsModule.cpp:99

Scope (from outer to inner):

file
function     TObjectPtr<UMeshDeformer> FOptimusSettingsModule::GetDefaultMeshDeformer

Source code excerpt:

			return DefaultRecomputeTangentDeformer.Get();
		}
		if (DefaultDeformer)
		{ 
			return DefaultDeformer.Get();
		}
	}
	return nullptr;
}

IMPLEMENT_MODULE(FOptimusSettingsModule, OptimusSettings)

#Loc: <Workspace>/Engine/Plugins/Animation/DeformerGraph/Source/OptimusSettings/Private/OptimusSettingsModule.h:22

Scope (from outer to inner):

file
class        class FOptimusSettingsModule : public IModuleInterface, public IMeshDeformerProvider

Source code excerpt:

	void CacheDefaultMeshDeformers(UOptimusSettings const* InSettings);

	TStrongObjectPtr<UMeshDeformer> DefaultDeformer;
	TStrongObjectPtr<UMeshDeformer> DefaultRecomputeTangentDeformer;
};

#Loc: <Workspace>/Engine/Plugins/Animation/DeformerGraph/Source/OptimusSettings/Public/OptimusSettings.h:34

Scope (from outer to inner):

file
class        class UOptimusSettings : public UDeveloperSettings

Source code excerpt:

	/** A default deformer that will be used on a skinned mesh if no other deformer has been set. */
	UPROPERTY(config, EditAnywhere, Category = DeformerGraph, meta = (AllowedClasses = "/Script/OptimusCore.OptimusDeformer", EditCondition = "DefaultMode != EOptimusDefaultDeformerMode::Never"))
	TSoftObjectPtr<UMeshDeformer> DefaultDeformer;

	/** A default deformer that will be used on a skinned mesh if no other deformer has been set, and if the mesh has requested to recompute tangets. */
	UPROPERTY(config, EditAnywhere, Category = DeformerGraph, meta = (AllowedClasses = "/Script/OptimusCore.OptimusDeformer", EditCondition = "DefaultMode != EOptimusDefaultDeformerMode::Never"))
	TSoftObjectPtr<UMeshDeformer> DefaultRecomputeTangentDeformer;

#if WITH_EDITOR