Files
UnrealEngineUWP/Engine/Source/Editor/AnimationEditor/Private/AnimationEditor.h
Thomas Sarkanen 5419497f90 BlendSpace 2.0: Blendspace Graph Node
Added a new animation graph node that hosts its own UBlendSpaceBase. Modified UBlendSpaceBase to allow for pose links to be evaluated as the sample points.
The new blend space graphs can be spawned from existing UBlendSpace and UBlendSpace1D assets, or they can be created from scratch, or they can be converted from existing blendspace player nodes via the context menu.

Fixed anim node conversion functions so that their transactions work correctly.

Updated FBlueprintEditorUtils::IsGraphNameUnique to allow it to work with any object as the outer, not just UBlueprint. UBlueprint still has a special case for functions and events. This is to support GenerateUniqueGraphName within a scope (e.g. an outer graph).

Formalized the concept of 'node sub-graphs' (as well as the composite node pattern a little). Previously a number of known node types that contained sub-graphs (e.g. UK2Node_Composite) had special case logic for dealing with node/graph deletion etc. Now  any node can opt into this behaviour via the GetSubGraphs() override.

Added status bar readouts for the blendspace grid, so we dont have to stuff the prompts into the tooltip any more.

Moved anim BP related APIs out of FBlueprintEditor. They are always used via FAnimationBlueprintEditor.

Refactored graph title bar widget creation out into a function to allow other document tab factories to create it.

Altered breadcrumb trail click callbacks and SMyBlueprint::ExecuteAction to always JumpToHyperLink rather than calling OpenDocument directly. This allows unknown (to FBlueprintEditor) document types that reference objects to be correctly jumped to using the breadcrumb trail. Derived asset editors (i.e. FAnimationBlueprintEditor) can intercept the JumpToHyperlink call to ensure that the correct document is presented (i.e. the correct tab payload is generated).

Instead of making yet another bunch of duplicated code for handling the various alpha blend options, refactored this into FAnimGraphNodeAlphaOptions (for editor code) and FAnimNodeAlphaOptions (for runtime code).

Added OnCopyTermDefaultsToDefaultObject for per-node copying of default values from editor node to runtime node, rather than another special-case in the compiler.

#rb Jurre.deBaare,Phillip.Kavan

[CL 15177316 by Thomas Sarkanen in ue5-main branch]
2021-01-25 08:43:19 -04:00

203 lines
6.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Stats/Stats.h"
#include "Widgets/SWidget.h"
#include "UObject/GCObject.h"
#include "Toolkits/IToolkitHost.h"
#include "IAnimationEditor.h"
#include "TickableEditorObject.h"
#include "Containers/ArrayView.h"
struct FAssetData;
class FMenuBuilder;
class IAnimationSequenceBrowser;
class IDetailsView;
class IPersonaToolkit;
class IPersonaViewport;
class ISkeletonTree;
class UAnimationAsset;
class USkeletalMeshComponent;
class UAnimSequence;
class UAnimSequenceBase;
class ISkeletonTreeItem;
class IAnimSequenceCurveEditor;
struct FRichCurve;
struct FToolMenuContext;
namespace AnimationEditorModes
{
// Mode identifiers
extern const FName AnimationEditorMode;
}
namespace AnimationEditorTabs
{
// Tab identifiers
extern const FName DetailsTab;
extern const FName SkeletonTreeTab;
extern const FName ViewportTab;
extern const FName AdvancedPreviewTab;
extern const FName DocumentTab;
extern const FName CurveEditorTab;
extern const FName AssetBrowserTab;
extern const FName AssetDetailsTab;
extern const FName CurveNamesTab;
extern const FName SlotNamesTab;
extern const FName AnimMontageSectionsTab;
}
class FAnimationEditor : public IAnimationEditor, public FGCObject, public FTickableEditorObject
{
public:
virtual ~FAnimationEditor();
/** Edits the specified Skeleton object */
void InitAnimationEditor(const EToolkitMode::Type Mode, const TSharedPtr<class IToolkitHost>& InitToolkitHost, class UAnimationAsset* InAnimationAsset);
/** IAnimationEditor interface */
virtual void SetAnimationAsset(UAnimationAsset* AnimAsset) override;
virtual IAnimationSequenceBrowser* GetAssetBrowser() const override;
virtual void EditCurves(UAnimSequenceBase* InAnimSequence, const TArray<FCurveEditInfo>& InCurveInfo, const TSharedPtr<ITimeSliderController>& InExternalTimeSliderController) override;
virtual void StopEditingCurves(const TArray<FCurveEditInfo>& InCurveInfo) override;
/** IHasPersonaToolkit interface */
virtual TSharedRef<class IPersonaToolkit> GetPersonaToolkit() const override { return PersonaToolkit.ToSharedRef(); }
/** IToolkit interface */
virtual void RegisterTabSpawners(const TSharedRef<class FTabManager>& TabManager) override;
virtual void UnregisterTabSpawners(const TSharedRef<class FTabManager>& TabManager) override;
virtual FName GetToolkitFName() const override;
virtual FText GetBaseToolkitName() const override;
virtual FString GetWorldCentricTabPrefix() const override;
virtual FLinearColor GetWorldCentricTabColorScale() const override;
virtual void InitToolMenuContext(FToolMenuContext& MenuContext) override;
/** FTickableEditorObject Interface */
virtual void Tick(float DeltaTime) override;
virtual TStatId GetStatId() const override;
virtual ETickableTickType GetTickableTickType() const override { return ETickableTickType::Always; }
/** @return the documentation location for this editor */
virtual FString GetDocumentationLink() const override
{
return FString(TEXT("Engine/Animation/AnimationEditor"));
}
/** FGCObject interface */
virtual void AddReferencedObjects(FReferenceCollector& Collector) override;
/** Get the skeleton tree widget */
TSharedRef<class ISkeletonTree> GetSkeletonTree() const { return SkeletonTree.ToSharedRef(); }
void HandleDetailsCreated(const TSharedRef<class IDetailsView>& InDetailsView);
UObject* HandleGetAsset();
void HandleOpenNewAsset(UObject* InNewAsset);
void HandleAnimationSequenceBrowserCreated(const TSharedRef<class IAnimationSequenceBrowser>& InSequenceBrowser);
void HandleSelectionChanged(const TArrayView<TSharedPtr<ISkeletonTreeItem>>& InSelectedItems, ESelectInfo::Type InSelectInfo);
void HandleObjectSelected(UObject* InObject);
void HandleObjectsSelected(const TArray<UObject*>& InObjects);
private:
/** Options for asset export */
enum class EExportSourceOption : uint8
{
CurrentAnimation_AnimData,
CurrentAnimation_PreviewMesh,
Max
};
void HandleSectionsChanged();
bool HasValidAnimationSequence() const;
bool CanSetKey() const;
void OnSetKey();
void OnReimportAnimation();
void OnApplyCompression();
void OnExportToFBX(const EExportSourceOption Option);
//Return true mean the asset was exported, false it was cancel or it fail
bool ExportToFBX(const TArray<UObject*> NewAssets, bool bRecordAnimation);
void OnAddLoopingInterpolation();
void OnRemoveBoneTrack();
TSharedRef< SWidget > GenerateExportAssetMenu() const;
void FillCopyToSoundWaveMenu(FMenuBuilder& MenuBuilder) const;
void FillExportAssetMenu(FMenuBuilder& MenuBuilder) const;
void CopyCurveToSoundWave(const FAssetData& SoundWaveAssetData) const;
void ConditionalRefreshEditor(UObject* InObject);
void HandlePostReimport(UObject* InObject, bool bSuccess);
void HandlePostImport(class UFactory* InFactory, UObject* InObject);
private:
void ExtendMenu();
void ExtendToolbar();
void BindCommands();
TSharedPtr<SDockTab> OpenNewAnimationDocumentTab(UAnimationAsset* InAnimAsset);
bool RecordMeshToAnimation(USkeletalMeshComponent* PreviewComponent, UAnimSequence* NewAsset) const;
public:
/** Multicast delegate fired on global undo/redo */
FSimpleMulticastDelegate OnLODChanged;
/** Multicast delegate fired on sections changing */
FSimpleMulticastDelegate OnSectionsChanged;
private:
/** The animation asset we are editing */
UAnimationAsset* AnimationAsset;
/** Toolbar extender */
TSharedPtr<FExtender> ToolbarExtender;
/** Menu extender */
TSharedPtr<FExtender> MenuExtender;
/** Persona toolkit */
TSharedPtr<class IPersonaToolkit> PersonaToolkit;
/** Skeleton tree */
TSharedPtr<class ISkeletonTree> SkeletonTree;
/** Viewport */
TSharedPtr<class IPersonaViewport> Viewport;
/** Details panel */
TSharedPtr<class IDetailsView> DetailsView;
/** The animation document currently being edited */
TWeakPtr<SDockTab> SharedAnimDocumentTab;
/** The animation document's curves that are currently being edited */
TWeakPtr<SDockTab> AnimCurveDocumentTab;
/** Sequence Browser **/
TWeakPtr<class IAnimationSequenceBrowser> SequenceBrowser;
/** The anim sequence curve editor */
TWeakPtr<IAnimSequenceCurveEditor> CurveEditor;
};