2021-03-03 08:23:59 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.UAnimGraphNode_MirrorPose
# include "AnimGraphNode_Mirror.h"
# include "Animation/AnimNode_Inertialization.h"
# include "Animation/MirrorDataTable.h"
2022-05-02 18:06:48 -04:00
# include "AssetRegistry/ARFilter.h"
# include "AssetRegistry/AssetRegistryModule.h"
2021-03-03 08:23:59 -04:00
# include "BlueprintActionFilter.h"
# include "BlueprintActionFilter.h"
# include "BlueprintActionDatabaseRegistrar.h"
# include "BlueprintNodeSpawner.h"
# include "Kismet2/CompilerResultsLog.h"
# define LOCTEXT_NAMESPACE "AnimGraphNode_MirrorPose"
FLinearColor UAnimGraphNode_Mirror : : GetNodeTitleColor ( ) const
{
return FLinearColor ( 0.7f , 0.7f , 0.7f ) ;
}
FText UAnimGraphNode_Mirror : : GetTooltipText ( ) const
{
return LOCTEXT ( " NodeToolTip " , " Mirror Pose " ) ;
}
FText UAnimGraphNode_Mirror : : GetNodeTitle ( ENodeTitleType : : Type TitleType ) const
{
if ( Node . GetMirrorDataTable ( ) )
{
FFormatNamedArguments Args ;
Args . Add ( TEXT ( " AssetName " ) , FText : : FromName ( Node . GetMirrorDataTable ( ) - > GetFName ( ) ) ) ;
2022-03-04 16:10:23 -05:00
return FText : : Format ( LOCTEXT ( " MirrorWithAssetNodeTitle " , " Mirror with {AssetName} " ) , Args ) ;
2021-03-03 08:23:59 -04:00
}
else
{
2022-03-04 16:10:23 -05:00
return LOCTEXT ( " MirrorNodeTitle " , " Mirror " ) ;
2021-03-03 08:23:59 -04:00
}
}
FText UAnimGraphNode_Mirror : : GetMenuCategory ( ) const
{
2022-06-15 10:37:36 -04:00
return LOCTEXT ( " NodeCategory " , " Animation|Misc. " ) ;
2021-03-03 08:23:59 -04:00
}
void UAnimGraphNode_Mirror : : GetOutputLinkAttributes ( FNodeAttributeArray & OutAttributes ) const
{
if ( Node . GetBlendTimeOnMirrorStateChange ( ) > 0.0 )
{
OutAttributes . Add ( UE : : Anim : : IInertializationRequester : : Attribute ) ;
}
}
2021-05-10 07:31:57 -04:00
void UAnimGraphNode_Mirror : : PreloadRequiredAssets ( )
{
if ( Node . GetMirrorDataTable ( ) )
{
PreloadObject ( Node . GetMirrorDataTable ( ) ) ;
PreloadObject ( Node . GetMirrorDataTable ( ) - > Skeleton ) ;
}
Super : : PreloadRequiredAssets ( ) ;
}
2021-03-03 08:23:59 -04:00
void UAnimGraphNode_Mirror : : ValidateAnimNodeDuringCompilation ( class USkeleton * ForSkeleton , class FCompilerResultsLog & MessageLog )
{
Super : : ValidateAnimNodeDuringCompilation ( ForSkeleton , MessageLog ) ;
if ( Node . GetMirrorDataTable ( ) = = nullptr )
{
MessageLog . Error ( TEXT ( " @@ does not have a mirror data table selected. Please select a table or delete the node. " ) , this ) ;
}
2021-04-30 13:45:03 -04:00
else if ( ForSkeleton )
{
2021-05-10 07:31:57 -04:00
const USkeleton * MirrorTableSkeleton = Node . GetMirrorDataTable ( ) - > Skeleton ;
2022-11-01 06:25:59 -04:00
if ( MirrorTableSkeleton = = nullptr )
2021-04-30 13:45:03 -04:00
{
2022-11-01 06:25:59 -04:00
MessageLog . Warning ( TEXT ( " @@ has a mirror data table that has a missing skeleton. Please update the table or create a new table for the skeleton. " ) , this ) ;
2021-04-30 13:45:03 -04:00
}
}
2021-03-03 08:23:59 -04:00
BindMirrorDataTableChangedDelegate ( ) ;
}
void UAnimGraphNode_Mirror : : PreEditChange ( FProperty * PropertyThatWillChange )
{
Super : : PreEditChange ( PropertyThatWillChange ) ;
if ( PropertyThatWillChange & & PropertyThatWillChange - > GetFName ( ) = = GET_MEMBER_NAME_STRING_CHECKED ( FAnimNode_Mirror , MirrorDataTable ) )
{
if ( Node . GetMirrorDataTable ( ) )
{
Node . GetMirrorDataTable ( ) - > OnDataTableChanged ( ) . RemoveAll ( this ) ;
}
}
}
void UAnimGraphNode_Mirror : : PostPlacedNewNode ( )
{
Super : : PostPlacedNewNode ( ) ;
BindMirrorDataTableChangedDelegate ( ) ;
}
void UAnimGraphNode_Mirror : : PostLoad ( )
{
Super : : PostLoad ( ) ;
BindMirrorDataTableChangedDelegate ( ) ;
}
void UAnimGraphNode_Mirror : : PostEditChangeProperty ( struct FPropertyChangedEvent & PropertyChangedEvent )
{
const FName PropertyName = ( PropertyChangedEvent . Property ? PropertyChangedEvent . Property - > GetFName ( ) : NAME_None ) ;
if ( PropertyName = = GET_MEMBER_NAME_STRING_CHECKED ( FAnimNode_Mirror , MirrorDataTable ) )
{
BindMirrorDataTableChangedDelegate ( ) ;
}
Super : : PostEditChangeProperty ( PropertyChangedEvent ) ;
}
void UAnimGraphNode_Mirror : : BindMirrorDataTableChangedDelegate ( )
{
if ( Node . GetMirrorDataTable ( ) )
{
Node . GetMirrorDataTable ( ) - > OnDataTableChanged ( ) . RemoveAll ( this ) ;
Node . GetMirrorDataTable ( ) - > OnDataTableChanged ( ) . AddUObject ( this , & UAnimGraphNode_Mirror : : OnMirrorDataTableChanged ) ;
}
}
void UAnimGraphNode_Mirror : : OnMirrorDataTableChanged ( )
{
if ( HasValidBlueprint ( ) )
{
UBlueprint * BP = GetBlueprint ( ) ;
BP - > Status = BS_Dirty ;
}
}
void UAnimGraphNode_Mirror : : GetMenuActions ( FBlueprintActionDatabaseRegistrar & ActionRegistrar ) const
{
auto LoadedAssetSetup = [ ] ( UEdGraphNode * NewNode , bool /*bIsTemplateNode*/ , TWeakObjectPtr < UMirrorDataTable > MirrorDataTablePtr )
{
UAnimGraphNode_Mirror * MirrorNode = CastChecked < UAnimGraphNode_Mirror > ( NewNode ) ;
MirrorNode - > Node . SetMirrorDataTable ( MirrorDataTablePtr . Get ( ) ) ;
} ;
auto UnloadedAssetSetup = [ ] ( UEdGraphNode * NewNode , bool bIsTemplateNode , const FAssetData AssetData )
{
UAnimGraphNode_Mirror * MirrorNode = CastChecked < UAnimGraphNode_Mirror > ( NewNode ) ;
if ( bIsTemplateNode )
{
AssetData . GetTagValue ( " Skeleton " , MirrorNode - > UnloadedSkeletonName ) ;
}
else
{
UMirrorDataTable * MirrorTable = Cast < UMirrorDataTable > ( AssetData . GetAsset ( ) ) ;
check ( MirrorTable ! = nullptr ) ;
MirrorNode - > Node . SetMirrorDataTable ( MirrorTable ) ;
}
} ;
const UObject * QueryObject = ActionRegistrar . GetActionKeyFilter ( ) ;
if ( QueryObject = = nullptr )
{
FAssetRegistryModule & AssetRegistryModule = FModuleManager : : LoadModuleChecked < FAssetRegistryModule > ( TEXT ( " AssetRegistry " ) ) ;
// define a filter to help in pulling UMirrrorDataTable asset data from the registry
FARFilter Filter ;
Deprecating ANY_PACKAGE.
This change consists of multiple changes:
Core:
- Deprecation of ANY_PACKAGE macro. Added ANY_PACKAGE_DEPRECATED macro which can still be used for backwards compatibility purposes (only used in CoreUObject)
- Deprecation of StaticFindObjectFast* functions that take bAnyPackage parameter
- Added UStruct::GetStructPathName function that returns FTopLevelAssetPath representing the path name (package + object FName, super quick compared to UObject::GetPathName) + wrapper UClass::GetClassPathName to make it look better when used with UClasses
- Added (Static)FindFirstObject* functions that find a first object given its Name (no Outer). These functions are used in places I consider valid to do global UObject (UClass) lookups like parsing command line parameters / checking for unique object names
- Added static UClass::TryFindType function which serves a similar purpose as FindFirstObject however it's going to throw a warning (with a callstack / maybe ensure in the future?) if short class name is provided. This function is used in places that used to use short class names but now should have been converted to use path names to catch any potential regressions and or edge cases I missed.
- Added static UClass::TryConvertShortNameToPathName utility function
- Added static UClass::TryFixShortClassNameExportPath utility function
- Object text export paths will now also include class path (Texture2D'/Game/Textures/Grass.Grass' -> /Script/Engine.Texture2D'/Game/Textures/Grass.Grass')
- All places that manually generated object export paths for objects will now use FObjectPropertyBase::GetExportPath
- Added a new startup test that checks for short type names in UClass/FProperty MetaData values
AssetRegistry:
- Deprecated any member variables (FAssetData / FARFilter) or functions that use FNames to represent class names and replaced them with FTopLevelAssetPath
- Added new member variables and new function overloads that use FTopLevelAssetPath to represent class names
- This also applies to a few other modules' APIs to match AssetRegistry changes
Everything else:
- Updated code that used ANY_PACKAGE (depending on the use case) to use FindObject(nullptr, PathToObject), UClass::TryFindType (used when path name is expected, warns if it's a short name) or FindFirstObject (usually for finding types based on user input but there's been a few legitimate use cases not related to user input)
- Updated code that used AssetRegistry API to use FTopLevelAssetPaths and USomeClass::StaticClass()->GetClassPathName() instead of GetFName()
- Updated meta data and hardcoded FindObject(ANY_PACKAGE, "EEnumNameOrClassName") calls to use path names
#jira UE-99463
#rb many.people
[FYI] Marcus.Wassmer
#preflight 629248ec2256738f75de9b32
#codereviewnumbers 20320742, 20320791, 20320799, 20320756, 20320809, 20320830, 20320840, 20320846, 20320851, 20320863, 20320780, 20320765, 20320876, 20320786
#ROBOMERGE-OWNER: robert.manuszewski
#ROBOMERGE-AUTHOR: robert.manuszewski
#ROBOMERGE-SOURCE: CL 20430220 via CL 20433854 via CL 20435474 via CL 20435484
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v949-20362246)
[CL 20448496 by robert manuszewski in ue5-main branch]
2022-06-01 03:46:59 -04:00
Filter . ClassPaths . Add ( UMirrorDataTable : : StaticClass ( ) - > GetClassPathName ( ) ) ;
2021-03-03 08:23:59 -04:00
Filter . bRecursiveClasses = true ;
// Find matching assets and add an entry for each one
TArray < FAssetData > MirrorDataTableList ;
AssetRegistryModule . Get ( ) . GetAssets ( Filter , /*out*/ MirrorDataTableList ) ;
for ( auto AssetIt = MirrorDataTableList . CreateConstIterator ( ) ; AssetIt ; + + AssetIt )
{
const FAssetData & Asset = * AssetIt ;
UBlueprintNodeSpawner * NodeSpawner = UBlueprintNodeSpawner : : Create ( GetClass ( ) ) ;
if ( Asset . IsAssetLoaded ( ) )
{
UMirrorDataTable * MirrorDataTable = Cast < UMirrorDataTable > ( Asset . GetAsset ( ) ) ;
if ( MirrorDataTable )
{
NodeSpawner - > CustomizeNodeDelegate = UBlueprintNodeSpawner : : FCustomizeNodeDelegate : : CreateStatic ( LoadedAssetSetup , TWeakObjectPtr < UMirrorDataTable > ( MirrorDataTable ) ) ;
NodeSpawner - > DefaultMenuSignature . MenuName = GetTitleGivenAssetInfo ( FText : : FromName ( MirrorDataTable - > GetFName ( ) ) ) ;
}
}
else
{
NodeSpawner - > CustomizeNodeDelegate = UBlueprintNodeSpawner : : FCustomizeNodeDelegate : : CreateStatic ( UnloadedAssetSetup , Asset ) ;
NodeSpawner - > DefaultMenuSignature . MenuName = GetTitleGivenAssetInfo ( FText : : FromName ( Asset . AssetName ) ) ;
}
ActionRegistrar . AddBlueprintAction ( Asset , NodeSpawner ) ;
}
}
else if ( const UMirrorDataTable * MirrorDataTable = Cast < UMirrorDataTable > ( QueryObject ) )
{
UBlueprintNodeSpawner * NodeSpawner = UBlueprintNodeSpawner : : Create ( GetClass ( ) ) ;
TWeakObjectPtr < UMirrorDataTable > MirrorDataTablePtr = MakeWeakObjectPtr ( const_cast < UMirrorDataTable * > ( MirrorDataTable ) ) ;
NodeSpawner - > CustomizeNodeDelegate = UBlueprintNodeSpawner : : FCustomizeNodeDelegate : : CreateStatic ( LoadedAssetSetup , MirrorDataTablePtr ) ;
NodeSpawner - > DefaultMenuSignature . MenuName = GetTitleGivenAssetInfo ( FText : : FromName ( MirrorDataTablePtr - > GetFName ( ) ) ) ;
NodeSpawner - > DefaultMenuSignature . Tooltip = GetTitleGivenAssetInfo ( FText : : FromString ( MirrorDataTablePtr - > GetPathName ( ) ) ) ;
ActionRegistrar . AddBlueprintAction ( QueryObject , NodeSpawner ) ;
}
else if ( QueryObject = = GetClass ( ) )
{
FAssetRegistryModule & AssetRegistryModule = FModuleManager : : LoadModuleChecked < FAssetRegistryModule > ( TEXT ( " AssetRegistry " ) ) ;
FARFilter Filter ;
Deprecating ANY_PACKAGE.
This change consists of multiple changes:
Core:
- Deprecation of ANY_PACKAGE macro. Added ANY_PACKAGE_DEPRECATED macro which can still be used for backwards compatibility purposes (only used in CoreUObject)
- Deprecation of StaticFindObjectFast* functions that take bAnyPackage parameter
- Added UStruct::GetStructPathName function that returns FTopLevelAssetPath representing the path name (package + object FName, super quick compared to UObject::GetPathName) + wrapper UClass::GetClassPathName to make it look better when used with UClasses
- Added (Static)FindFirstObject* functions that find a first object given its Name (no Outer). These functions are used in places I consider valid to do global UObject (UClass) lookups like parsing command line parameters / checking for unique object names
- Added static UClass::TryFindType function which serves a similar purpose as FindFirstObject however it's going to throw a warning (with a callstack / maybe ensure in the future?) if short class name is provided. This function is used in places that used to use short class names but now should have been converted to use path names to catch any potential regressions and or edge cases I missed.
- Added static UClass::TryConvertShortNameToPathName utility function
- Added static UClass::TryFixShortClassNameExportPath utility function
- Object text export paths will now also include class path (Texture2D'/Game/Textures/Grass.Grass' -> /Script/Engine.Texture2D'/Game/Textures/Grass.Grass')
- All places that manually generated object export paths for objects will now use FObjectPropertyBase::GetExportPath
- Added a new startup test that checks for short type names in UClass/FProperty MetaData values
AssetRegistry:
- Deprecated any member variables (FAssetData / FARFilter) or functions that use FNames to represent class names and replaced them with FTopLevelAssetPath
- Added new member variables and new function overloads that use FTopLevelAssetPath to represent class names
- This also applies to a few other modules' APIs to match AssetRegistry changes
Everything else:
- Updated code that used ANY_PACKAGE (depending on the use case) to use FindObject(nullptr, PathToObject), UClass::TryFindType (used when path name is expected, warns if it's a short name) or FindFirstObject (usually for finding types based on user input but there's been a few legitimate use cases not related to user input)
- Updated code that used AssetRegistry API to use FTopLevelAssetPaths and USomeClass::StaticClass()->GetClassPathName() instead of GetFName()
- Updated meta data and hardcoded FindObject(ANY_PACKAGE, "EEnumNameOrClassName") calls to use path names
#jira UE-99463
#rb many.people
[FYI] Marcus.Wassmer
#preflight 629248ec2256738f75de9b32
#codereviewnumbers 20320742, 20320791, 20320799, 20320756, 20320809, 20320830, 20320840, 20320846, 20320851, 20320863, 20320780, 20320765, 20320876, 20320786
#ROBOMERGE-OWNER: robert.manuszewski
#ROBOMERGE-AUTHOR: robert.manuszewski
#ROBOMERGE-SOURCE: CL 20430220 via CL 20433854 via CL 20435474 via CL 20435484
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v949-20362246)
[CL 20448496 by robert manuszewski in ue5-main branch]
2022-06-01 03:46:59 -04:00
Filter . ClassPaths . Add ( UMirrorDataTable : : StaticClass ( ) - > GetClassPathName ( ) ) ;
2021-03-03 08:23:59 -04:00
Filter . bRecursiveClasses = true ;
// Find matching assets and add an entry for each one
TArray < FAssetData > MirrorDataTableList ;
AssetRegistryModule . Get ( ) . GetAssets ( Filter , /*out*/ MirrorDataTableList ) ;
for ( auto AssetIt = MirrorDataTableList . CreateConstIterator ( ) ; AssetIt ; + + AssetIt )
{
const FAssetData & Asset = * AssetIt ;
if ( Asset . IsAssetLoaded ( ) )
{
continue ;
}
UBlueprintNodeSpawner * NodeSpawner = UBlueprintNodeSpawner : : Create ( GetClass ( ) ) ;
NodeSpawner - > CustomizeNodeDelegate = UBlueprintNodeSpawner : : FCustomizeNodeDelegate : : CreateStatic ( UnloadedAssetSetup , Asset ) ;
NodeSpawner - > DefaultMenuSignature . MenuName = GetTitleGivenAssetInfo ( FText : : FromName ( Asset . AssetName ) ) ;
2022-09-07 00:40:02 -04:00
NodeSpawner - > DefaultMenuSignature . Tooltip = GetTitleGivenAssetInfo ( FText : : FromString ( Asset . GetObjectPathString ( ) ) ) ;
2021-03-03 08:23:59 -04:00
ActionRegistrar . AddBlueprintAction ( Asset , NodeSpawner ) ;
}
}
2021-08-26 14:41:47 -04:00
UClass * ActionKey = GetClass ( ) ;
if ( ActionRegistrar . IsOpenForRegistration ( ActionKey ) )
{
// Add a default create option if there are no compatible tables. This action is filtered out when
// HasMirrorDataTableForBlueprints returns true because there is a table that can be used
UBlueprintNodeSpawner * EmptyNodeSpawner = UBlueprintNodeSpawner : : Create ( GetClass ( ) ) ;
EmptyNodeSpawner - > DefaultMenuSignature . MenuName = FText ( LOCTEXT ( " MirrorNodeTitle " , " Mirror " ) ) ;
ActionRegistrar . AddBlueprintAction ( ActionKey , EmptyNodeSpawner ) ;
}
}
bool UAnimGraphNode_Mirror : : HasMirrorDataTableForBlueprints ( const TArray < UBlueprint * > & Blueprints ) const
{
// check to see if any mirror data table is available for the blueprint
FAssetRegistryModule & AssetRegistryModule = FModuleManager : : LoadModuleChecked < FAssetRegistryModule > ( TEXT ( " AssetRegistry " ) ) ;
FARFilter Filter ;
Deprecating ANY_PACKAGE.
This change consists of multiple changes:
Core:
- Deprecation of ANY_PACKAGE macro. Added ANY_PACKAGE_DEPRECATED macro which can still be used for backwards compatibility purposes (only used in CoreUObject)
- Deprecation of StaticFindObjectFast* functions that take bAnyPackage parameter
- Added UStruct::GetStructPathName function that returns FTopLevelAssetPath representing the path name (package + object FName, super quick compared to UObject::GetPathName) + wrapper UClass::GetClassPathName to make it look better when used with UClasses
- Added (Static)FindFirstObject* functions that find a first object given its Name (no Outer). These functions are used in places I consider valid to do global UObject (UClass) lookups like parsing command line parameters / checking for unique object names
- Added static UClass::TryFindType function which serves a similar purpose as FindFirstObject however it's going to throw a warning (with a callstack / maybe ensure in the future?) if short class name is provided. This function is used in places that used to use short class names but now should have been converted to use path names to catch any potential regressions and or edge cases I missed.
- Added static UClass::TryConvertShortNameToPathName utility function
- Added static UClass::TryFixShortClassNameExportPath utility function
- Object text export paths will now also include class path (Texture2D'/Game/Textures/Grass.Grass' -> /Script/Engine.Texture2D'/Game/Textures/Grass.Grass')
- All places that manually generated object export paths for objects will now use FObjectPropertyBase::GetExportPath
- Added a new startup test that checks for short type names in UClass/FProperty MetaData values
AssetRegistry:
- Deprecated any member variables (FAssetData / FARFilter) or functions that use FNames to represent class names and replaced them with FTopLevelAssetPath
- Added new member variables and new function overloads that use FTopLevelAssetPath to represent class names
- This also applies to a few other modules' APIs to match AssetRegistry changes
Everything else:
- Updated code that used ANY_PACKAGE (depending on the use case) to use FindObject(nullptr, PathToObject), UClass::TryFindType (used when path name is expected, warns if it's a short name) or FindFirstObject (usually for finding types based on user input but there's been a few legitimate use cases not related to user input)
- Updated code that used AssetRegistry API to use FTopLevelAssetPaths and USomeClass::StaticClass()->GetClassPathName() instead of GetFName()
- Updated meta data and hardcoded FindObject(ANY_PACKAGE, "EEnumNameOrClassName") calls to use path names
#jira UE-99463
#rb many.people
[FYI] Marcus.Wassmer
#preflight 629248ec2256738f75de9b32
#codereviewnumbers 20320742, 20320791, 20320799, 20320756, 20320809, 20320830, 20320840, 20320846, 20320851, 20320863, 20320780, 20320765, 20320876, 20320786
#ROBOMERGE-OWNER: robert.manuszewski
#ROBOMERGE-AUTHOR: robert.manuszewski
#ROBOMERGE-SOURCE: CL 20430220 via CL 20433854 via CL 20435474 via CL 20435484
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v949-20362246)
[CL 20448496 by robert manuszewski in ue5-main branch]
2022-06-01 03:46:59 -04:00
Filter . ClassPaths . Add ( UMirrorDataTable : : StaticClass ( ) - > GetClassPathName ( ) ) ;
2021-08-26 14:41:47 -04:00
Filter . bRecursiveClasses = true ;
TArray < FAssetData > MirrorDataTableList ;
AssetRegistryModule . Get ( ) . GetAssets ( Filter , MirrorDataTableList ) ;
for ( UBlueprint * Blueprint : Blueprints )
{
if ( UAnimBlueprint * AnimBlueprint = Cast < UAnimBlueprint > ( Blueprint ) )
{
for ( auto AssetIt = MirrorDataTableList . CreateConstIterator ( ) ; AssetIt ; + + AssetIt )
{
const FAssetData & Asset = * AssetIt ;
if ( Asset . IsAssetLoaded ( ) )
{
UMirrorDataTable * MirrorDataTable = Cast < UMirrorDataTable > ( Asset . GetAsset ( ) ) ;
2022-11-01 06:25:59 -04:00
if ( AnimBlueprint - > TargetSkeleton & & AnimBlueprint - > TargetSkeleton - > IsCompatibleForEditor ( MirrorDataTable - > Skeleton ) )
2021-08-26 14:41:47 -04:00
{
return true ;
}
}
else
{
FString TableSkeletonName ;
Asset . GetTagValue ( " Skeleton " , TableSkeletonName ) ;
if ( AnimBlueprint - > TargetSkeleton & & AnimBlueprint - > TargetSkeleton - > GetName ( ) = = TableSkeletonName )
{
return true ;
}
}
}
}
}
return false ;
2021-03-03 08:23:59 -04:00
}
bool UAnimGraphNode_Mirror : : IsActionFilteredOut ( class FBlueprintActionFilter const & Filter )
{
bool bIsFilteredOut = false ;
FBlueprintActionContext const & FilterContext = Filter . Context ;
for ( UBlueprint * Blueprint : FilterContext . Blueprints )
{
if ( UAnimBlueprint * AnimBlueprint = Cast < UAnimBlueprint > ( Blueprint ) )
{
2021-06-14 08:21:54 -04:00
UMirrorDataTable * MirrorDataTable = Node . GetMirrorDataTable ( ) ;
if ( MirrorDataTable )
2021-03-03 08:23:59 -04:00
{
2022-11-01 06:25:59 -04:00
if ( AnimBlueprint - > TargetSkeleton = = nullptr | | ! AnimBlueprint - > TargetSkeleton - > IsCompatibleForEditor ( MirrorDataTable - > Skeleton ) )
2021-03-03 08:23:59 -04:00
{
// Mirror Data Table does not use the same skeleton as the Blueprint, cannot use
bIsFilteredOut = true ;
break ;
}
}
2021-06-14 08:21:54 -04:00
else if ( ! UnloadedSkeletonName . IsEmpty ( ) )
2021-03-03 08:23:59 -04:00
{
2022-11-01 06:25:59 -04:00
if ( AnimBlueprint - > TargetSkeleton = = nullptr | | ! AnimBlueprint - > TargetSkeleton - > IsCompatibleForEditor ( UnloadedSkeletonName ) )
2021-03-03 08:23:59 -04:00
{
bIsFilteredOut = true ;
break ;
}
}
2021-08-26 14:41:47 -04:00
else
{
// Only show the empty "Mirror" option if there is not a possible MirrorDataTable to select
if ( HasMirrorDataTableForBlueprints ( FilterContext . Blueprints ) )
{
bIsFilteredOut = true ;
break ;
}
}
2021-03-03 08:23:59 -04:00
}
else
{
// Not an animation Blueprint, cannot use
bIsFilteredOut = true ;
break ;
}
}
return bIsFilteredOut ;
}
FText UAnimGraphNode_Mirror : : GetTitleGivenAssetInfo ( const FText & AssetName )
{
FFormatNamedArguments Args ;
Args . Add ( TEXT ( " AssetName " ) , AssetName ) ;
2022-03-04 16:10:23 -05:00
return FText : : Format ( LOCTEXT ( " MirrorNodeTitle_WithAsset " , " Mirror with {AssetName} " ) , Args ) ;
2021-03-03 08:23:59 -04:00
}
EAnimAssetHandlerType UAnimGraphNode_Mirror : : SupportsAssetClass ( const UClass * AssetClass ) const
{
if ( AssetClass - > IsChildOf ( UMirrorDataTable : : StaticClass ( ) ) )
{
return EAnimAssetHandlerType : : PrimaryHandler ;
}
else
{
return EAnimAssetHandlerType : : NotSupported ;
}
}
# undef LOCTEXT_NAMESPACE