Files
FunnyGirl/Plugins/VRM4U/Source/VRM4UImporter/Private/AnimGraphNode_VrmCopyHandBone.cpp
T
2026-05-19 13:42:41 +07:00

132 lines
4.9 KiB
C++

// VRM4U Copyright (c) 2021-2024 Haruyoshi Yamamoto. This software is released under the MIT License.
#include "AnimGraphNode_VrmCopyHandBone.h"
#include "Misc/EngineVersionComparison.h"
#include "UnrealWidget.h"
#include "AnimNodeEditModes.h"
#include "Kismet2/CompilerResultsLog.h"
/////////////////////////////////////////////////////
// UAnimGraphNode_ModifyBone
#define LOCTEXT_NAMESPACE "A3Nodesaaaa"
UAnimGraphNode_VrmCopyHandBone::UAnimGraphNode_VrmCopyHandBone(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
#if UE_VERSION_OLDER_THAN(5,0,0)
CurWidgetMode = (int32)FWidget::WM_Rotate;
#else
CurWidgetMode = UE::Widget::EWidgetMode::WM_Rotate;
#endif
}
void UAnimGraphNode_VrmCopyHandBone::ValidateAnimNodeDuringCompilation(USkeleton* ForSkeleton, FCompilerResultsLog& MessageLog)
{
// Temporary fix where skeleton is not fully loaded during AnimBP compilation and thus virtual bone name check is invalid UE-39499 (NEED FIX)
if (ForSkeleton && !ForSkeleton->HasAnyFlags(RF_NeedPostLoad))
{
/*
//if (ForSkeleton->GetReferenceSkeleton().FindBoneIndex(Node.BoneToModify.BoneName) == INDEX_NONE)
if (ForSkeleton->GetReferenceSkeleton().FindBoneIndex(Node.BoneNameToModify) == INDEX_NONE)
{
//if (Node.BoneToModify.BoneName == NAME_None)
if (Node.BoneNameToModify == NAME_None)
{
MessageLog.Warning(*LOCTEXT("NoBoneSelectedToModify", "@@ - You must pick a bone to modify").ToString(), this);
}
else
{
FFormatNamedArguments Args;
//Args.Add(TEXT("BoneName"), FText::FromName(Node.BoneToModify.BoneName));
Args.Add(TEXT("BoneName"), FText::FromName(Node.BoneNameToModify));
FText Msg = FText::Format(LOCTEXT("NoBoneFoundToModify", "@@ - Bone {BoneName} not found in Skeleton"), Args);
MessageLog.Warning(*Msg.ToString(), this);
}
}
*/
}
//if ((Node.TranslationMode == BMM_Ignore) && (Node.RotationMode == BMM_Ignore) && (Node.ScaleMode == BMM_Ignore))
{
// MessageLog.Warning(*LOCTEXT("NothingToModify", "@@ - No components to modify selected. Either Rotation, Translation, or Scale should be set to something other than Ignore").ToString(), this);
}
Super::ValidateAnimNodeDuringCompilation(ForSkeleton, MessageLog);
}
FText UAnimGraphNode_VrmCopyHandBone::GetControllerDescription() const
{
return LOCTEXT("VrmCopyHandBone", "VrmCopyHandBone");
}
FText UAnimGraphNode_VrmCopyHandBone::GetTooltipText() const
{
return LOCTEXT("AnimGraphNode_VrmCopyHandBone_Tooltip", "VrmCopyHandBone");
}
FText UAnimGraphNode_VrmCopyHandBone::GetNodeTitle(ENodeTitleType::Type TitleType) const
{
//if ((TitleType == ENodeTitleType::ListView || TitleType == ENodeTitleType::MenuTitle) && (Node.BoneToModify.BoneName == NAME_None))
//if ((TitleType == ENodeTitleType::ListView || TitleType == ENodeTitleType::MenuTitle) && (Node.BoneNameToModify == NAME_None))
//{
return GetControllerDescription();
//}
// @TODO: the bone can be altered in the property editor, so we have to
// choose to mark this dirty when that happens for this to properly work
/*
else //if (!CachedNodeTitles.IsTitleCached(TitleType, this))
{
FFormatNamedArguments Args;
Args.Add(TEXT("ControllerDescription"), GetControllerDescription());
//Args.Add(TEXT("BoneName"), FText::FromName(Node.BoneToModify.BoneName));
Args.Add(TEXT("BoneName"), FText::FromName(Node.BoneNameToModify));
// FText::Format() is slow, so we cache this to save on performance
if (TitleType == ENodeTitleType::ListView || TitleType == ENodeTitleType::MenuTitle)
{
CachedNodeTitles.SetCachedTitle(TitleType, FText::Format(LOCTEXT("AnimGraphNode_ModifyBone_ListTitle", "{ControllerDescription} - Bone: {BoneName}"), Args), this);
}
else
{
CachedNodeTitles.SetCachedTitle(TitleType, FText::Format(LOCTEXT("AnimGraphNode_ModifyBone_Title", "{ControllerDescription}\nBone: {BoneName}"), Args), this);
}
}
return CachedNodeTitles[TitleType];
*/
}
void UAnimGraphNode_VrmCopyHandBone::CopyNodeDataToPreviewNode(FAnimNode_Base* InPreviewNode)
{
FAnimNode_VrmCopyHandBone* node = static_cast<FAnimNode_VrmCopyHandBone*>(InPreviewNode);
// no copy
}
//FEditorModeID UAnimGraphNode_VrmModifyBoneDynamic::GetEditorMode() const
//{
// return AnimNodeEditModes::ModifyBone;
//}
void UAnimGraphNode_VrmCopyHandBone::CopyPinDefaultsToNodeData(UEdGraphPin* InPin)
{
/*
if (InPin->GetName() == GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_ModifyBone, Translation))
{
GetDefaultValue(GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_ModifyBone, Translation), Node.Translation);
}
else if (InPin->GetName() == GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_ModifyBone, Rotation))
{
GetDefaultValue(GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_ModifyBone, Rotation), Node.Rotation);
}
else if (InPin->GetName() == GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_ModifyBone, Scale))
{
GetDefaultValue(GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_ModifyBone, Scale), Node.Scale);
}
*/
}
#undef LOCTEXT_NAMESPACE