Skip to content

Commit

Permalink
Update 4.22
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxwell21 committed Apr 7, 2019
1 parent 1bba38e commit 6e468d6
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void FMovieSceneFlipbookAnimationSectionTemplate::Evaluate(const FMovieSceneEval
// calculate the time at which to evaluate the animation
float EvalTime = Params.MapTimeToAnimation(Context.GetTime(), Context.GetFrameRate());

FOptionalMovieSceneBlendType BlendType = SourceSection->GetBlendType();
FOptionalMovieSceneBlendType BlendType = GetSourceSection()->GetBlendType();
check(BlendType.IsValid());

// Ensure the accumulator knows how to actually apply component transforms
Expand All @@ -271,17 +271,17 @@ float FMovieSceneFlipbookAnimationSectionTemplateParameters::MapTimeToAnimation(
const float SectionPlayRate = PlayRate;
const float AnimPlayRate = FMath::IsNearlyZero(SectionPlayRate) ? 1.0f : SectionPlayRate;

const float SeqLength = GetSequenceLength() - (StartOffset + EndOffset);
const float SeqLength = GetSequenceLength() - InFrameRate.AsSeconds(StartOffset + EndOffset);

float AnimPosition = FFrameTime::FromDecimal((InPosition - SectionStartTime).AsDecimal() * AnimPlayRate) / InFrameRate;
if (SeqLength > 0.f)
{
AnimPosition = FMath::Fmod(AnimPosition, SeqLength);
}
AnimPosition += StartOffset;
AnimPosition += InFrameRate.AsSeconds(StartOffset);
if (bReverse)
{
AnimPosition = (SeqLength - (AnimPosition - StartOffset)) + StartOffset;
AnimPosition = (SeqLength - (AnimPosition - InFrameRate.AsSeconds(StartOffset))) + InFrameRate.AsSeconds(StartOffset);
}

return AnimPosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,24 @@ namespace
FMovieSceneFlipbookAnimationParams::FMovieSceneFlipbookAnimationParams()
{
Animation = nullptr;
StartOffset = 0.f;
EndOffset = 0.f;
StartOffset = FFrameNumber(0);
EndOffset = FFrameNumber(0);
PlayRate = 1.f;
bReverse = false;
}

FFrameNumber GetStartOffsetAtTrimTime(FQualifiedFrameTime TrimTime, const FMovieSceneFlipbookAnimationParams& Params, FFrameNumber StartFrame, FFrameRate FrameRate)
{
float AnimPlayRate = FMath::IsNearlyZero(Params.PlayRate) ? 1.0f : Params.PlayRate;
float AnimPosition = (TrimTime.Time - StartFrame) / TrimTime.Rate * AnimPlayRate;
float SeqLength = Params.GetSequenceLength() - FrameRate.AsSeconds(Params.StartOffset + Params.EndOffset) / AnimPlayRate;

FFrameNumber NewOffset = FrameRate.AsFrameNumber(FMath::Fmod(AnimPosition, SeqLength));
NewOffset += Params.StartOffset;

return NewOffset;
}

UMovieSceneFlipbookAnimationSection::UMovieSceneFlipbookAnimationSection(const FObjectInitializer& ObjectInitializer)
: Super( ObjectInitializer )
{
Expand Down Expand Up @@ -92,11 +104,9 @@ float UMovieSceneFlipbookAnimationSection::MapTimeToAnimation(FFrameTime InPosit

UMovieSceneSection* UMovieSceneFlipbookAnimationSection::SplitSection(FQualifiedFrameTime SplitTime)
{
float AnimPlayRate = FMath::IsNearlyZero(Params.PlayRate) ? 1.0f : Params.PlayRate;
float AnimPosition = (SplitTime.Time.GetSubFrame() - (float)GetInclusiveStartFrame().Value) * AnimPlayRate;
float SeqLength = Params.GetSequenceLength() - (Params.StartOffset + Params.EndOffset);
FFrameRate FrameRate = GetTypedOuter<UMovieScene>()->GetTickResolution();

float NewOffset = FMath::Fmod(AnimPosition, SeqLength);
FFrameNumber NewOffset = HasStartFrame() ? GetStartOffsetAtTrimTime(SplitTime, Params, GetInclusiveStartFrame(), FrameRate) : 0;
NewOffset += Params.StartOffset;

UMovieSceneSection* NewSection = Super::SplitSection(SplitTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "PaperFlipbook.h"
#include "MovieSceneFlipbookAnimationSection.generated.h"

USTRUCT()
USTRUCT(BlueprintType)
struct FMovieSceneFlipbookAnimationParams
{
GENERATED_BODY()
Expand All @@ -24,11 +24,11 @@ struct FMovieSceneFlipbookAnimationParams

/** The offset into the beginning of the animation clip */
UPROPERTY(EditAnywhere, Category = "Animation")
float StartOffset;
FFrameNumber StartOffset;

/** The offset into the end of the animation clip */
UPROPERTY(EditAnywhere, Category = "Animation")
float EndOffset;
FFrameNumber EndOffset;

/** The playback rate of the animation clip */
UPROPERTY(EditAnywhere, Category = "Animation")
Expand All @@ -53,7 +53,7 @@ struct FMovieSceneFlipbookAnimationParams
};

/**
* Movie scene section that control skeletal animation
* Movie scene section that control flipbook animation
*/
UCLASS( MinimalAPI )
class UMovieSceneFlipbookAnimationSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "MovieSceneTrackEditor.h"
#include "MovieSceneTools/Public/CommonMovieSceneTools.h"
#include "MovieSceneTools/Public/MatineeImportTools.h"
#include "MovieSceneTools/Public/MovieSceneToolHelpers.h"
#include "Fonts/FontMeasure.h"
#include "PaperFlipbook.h"
#include "PaperFlipbookComponent.h"
Expand Down Expand Up @@ -69,7 +70,7 @@ UPaperFlipbookComponent* AcquireFlipbookComponentFromObjectGuid(const FGuid& Gui
FFlipbookAnimationSection::FFlipbookAnimationSection(UMovieSceneSection& InSection, TWeakPtr<ISequencer> InSequencer)
: Section(*CastChecked<UMovieSceneFlipbookAnimationSection>(&InSection))
, Sequencer(InSequencer)
, InitialStartOffsetDuringResize(0.f)
, InitialStartOffsetDuringResize(0)
, InitialStartTimeDuringResize(0)
{ }

Expand Down Expand Up @@ -107,11 +108,12 @@ int32 FFlipbookAnimationSection::OnPaintSection( FSequencerSectionPainter& Paint
return LayerId;
}

FFrameRate TickResolution = TimeToPixelConverter.GetTickResolution();

// Add lines where the animation starts and ends/loops
float AnimPlayRate = FMath::IsNearlyZero(Section.Params.PlayRate) ? 1.0f : Section.Params.PlayRate;
float SeqLength = (Section.Params.GetSequenceLength() - (Section.Params.StartOffset + Section.Params.EndOffset)) / AnimPlayRate;
float SeqLength = Section.Params.GetSequenceLength() - (TickResolution.AsSeconds(Section.Params.StartOffset + Section.Params.EndOffset) / AnimPlayRate);

FFrameRate TickResolution = TimeToPixelConverter.GetTickResolution();
if (!FMath::IsNearlyZero(SeqLength, KINDA_SMALL_NUMBER) && SeqLength > 0)
{
float MaxOffset = Section.GetRange().Size<FFrameTime>() / TickResolution;
Expand Down Expand Up @@ -151,17 +153,17 @@ void FFlipbookAnimationSection::ResizeSection(ESequencerSectionResizeMode Resize
// Adjust the start offset when resizing from the beginning
if (ResizeMode == SSRM_LeadingEdge)
{
FFrameRate FrameRate = Section.GetTypedOuter<UMovieScene>()->GetTickResolution();
float StartOffset = (ResizeFrameNumber - InitialStartTimeDuringResize) / FrameRate * Section.Params.PlayRate;
FFrameRate FrameRate = Section.GetTypedOuter<UMovieScene>()->GetTickResolution();
FFrameNumber StartOffset = FrameRate.AsFrameNumber((ResizeFrameNumber - InitialStartTimeDuringResize) / FrameRate * Section.Params.PlayRate);

StartOffset += InitialStartOffsetDuringResize;

// Ensure start offset is not less than 0 and adjust ResizeTime
if (StartOffset < 0)
{
ResizeFrameNumber = ResizeFrameNumber - ((StartOffset * Section.Params.PlayRate) * FrameRate).RoundToFrame();
ResizeFrameNumber = ResizeFrameNumber - StartOffset;

StartOffset = 0.f;
StartOffset = FFrameNumber(0);
}

Section.Params.StartOffset = StartOffset;
Expand All @@ -175,15 +177,19 @@ void FFlipbookAnimationSection::BeginSlipSection()
BeginResizeSection();
}

void FFlipbookAnimationSection::SlipSection(double SlipTime)
void FFlipbookAnimationSection::SlipSection(FFrameNumber SlipTime)
{
float StartOffset = (SlipTime - InitialStartTimeDuringResize / Section.GetTypedOuter<UMovieScene>()->GetTickResolution()) * Section.Params.PlayRate;
FFrameRate FrameRate = Section.GetTypedOuter<UMovieScene>()->GetTickResolution();
FFrameNumber StartOffset = FrameRate.AsFrameNumber((SlipTime - InitialStartTimeDuringResize) / FrameRate * Section.Params.PlayRate);

StartOffset += InitialStartOffsetDuringResize;

// Ensure start offset is not less than 0
if (StartOffset < 0)
{
StartOffset = 0.f;
SlipTime = SlipTime - StartOffset;

StartOffset = FFrameNumber(0);
}

Section.Params.StartOffset = StartOffset;
Expand Down Expand Up @@ -422,7 +428,7 @@ TSharedPtr<SWidget> FFlipbookAnimationTrackEditor::BuildOutlinerEditWidget(const
.AutoWidth()
.VAlign(VAlign_Center)
[
FSequencerUtilities::MakeAddButton(LOCTEXT("AnimationText", "Animation"), FOnGetContent::CreateSP(this, &FFlipbookAnimationTrackEditor::BuildAnimationSubMenu, ObjectBinding, Track), Params.NodeIsHovered)
FSequencerUtilities::MakeAddButton(LOCTEXT("AnimationText", "Animation"), FOnGetContent::CreateSP(this, &FFlipbookAnimationTrackEditor::BuildAnimationSubMenu, ObjectBinding, Track), Params.NodeIsHovered, GetSequencer())
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "StateMachineBlueprint.h"
#include "KismetReinstanceUtilities.h"

FStateMachineBlueprintCompiler::FStateMachineBlueprintCompiler(UStateMachineBlueprint* SourceSketch, FCompilerResultsLog& InMessageLog, const FKismetCompilerOptions& InCompilerOptions, TArray<UObject*>* InObjLoaded)
: Super(SourceSketch, InMessageLog, InCompilerOptions, InObjLoaded)
FStateMachineBlueprintCompiler::FStateMachineBlueprintCompiler(UStateMachineBlueprint* SourceSketch, FCompilerResultsLog& InMessageLog, const FKismetCompilerOptions& InCompilerOptions)
: Super(SourceSketch, InMessageLog, InCompilerOptions)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

TSharedPtr<class SGraphNode> FStateMachineGraphFactory::CreateNode(class UEdGraphNode* InNode) const
{
if (UStateMachineGraphNode_Entry* Node = Cast<UStateMachineGraphNode_Entry>(InNode))
return SNew(SStateMachineGraphNode_Entry, Node);
else if (UStateMachineGraphNode_Transition* Node = Cast<UStateMachineGraphNode_Transition>(InNode))
return SNew(SStateMachineGraphNode_Transition, Node);
if (UStateMachineGraphNode_Entry* EntryNode = Cast<UStateMachineGraphNode_Entry>(InNode))
return SNew(SStateMachineGraphNode_Entry, EntryNode);
else if (UStateMachineGraphNode_Transition* TransitionNode = Cast<UStateMachineGraphNode_Transition>(InNode))
return SNew(SStateMachineGraphNode_Transition, TransitionNode);
else if (UStateMachineGraphNode* Node = Cast<UStateMachineGraphNode>(InNode))
return SNew(SStateMachineGraphNode, Node);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

UStateMachineGraphNode::UStateMachineGraphNode(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer),
State(nullptr),
IsRootNode(false),
InputPin(nullptr),
OutputPin(nullptr)
OutputPin(nullptr),
State(nullptr)
{
this->bCanRenameNode = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,30 @@ void UStateMachineGraph::ReconstructNodes()
// Reconstruct nodes
for (UEdGraphNode* EdGraphNode : this->StateMachineBlueprint->Nodes)
{
if (UStateMachineGraphNode_Transition* StateMachineNode = Cast<UStateMachineGraphNode_Transition>(EdGraphNode))
if (UStateMachineGraphNode_Transition* TransitionStateMachineNode = Cast<UStateMachineGraphNode_Transition>(EdGraphNode))
{
if (!StateMachineNode->Transition)
if (!TransitionStateMachineNode->Transition)
continue;

StateMachineNode->Transition->Modify();
TransitionStateMachineNode->Transition->Modify();

StateMachineNode->ReconstructNode();
StateMachineNode->Transition->GraphNode = StateMachineNode;
this->AddNode(StateMachineNode, false, false);
TransitionStateMachineNode->ReconstructNode();
TransitionStateMachineNode->Transition->GraphNode = TransitionStateMachineNode;
this->AddNode(TransitionStateMachineNode, false, false);

// Apply current blueprint object edited
this->SetCurrentStateMachineBlueprintToNode(StateMachineNode);
this->SetCurrentStateMachineBlueprintToNode(TransitionStateMachineNode);

StateMachineNode->Transition->PostEditChange();
StateMachineNode->Transition->MarkPackageDirty();
TransitionStateMachineNode->Transition->PostEditChange();
TransitionStateMachineNode->Transition->MarkPackageDirty();
}
else if (UStateMachineGraphNode_Entry* StateMachineNode = Cast<UStateMachineGraphNode_Entry>(EdGraphNode))
else if (UStateMachineGraphNode_Entry* EntryStateMachineNode = Cast<UStateMachineGraphNode_Entry>(EdGraphNode))
{
StateMachineNode->ReconstructNode();
this->AddNode(StateMachineNode, false, false);
EntryStateMachineNode->ReconstructNode();
this->AddNode(EntryStateMachineNode, false, false);

// Apply current blueprint object edited
this->SetCurrentStateMachineBlueprintToNode(StateMachineNode);
this->SetCurrentStateMachineBlueprintToNode(EntryStateMachineNode);
}
else if (UStateMachineGraphNode* StateMachineNode = Cast<UStateMachineGraphNode>(EdGraphNode))
{
Expand Down
6 changes: 3 additions & 3 deletions Source/UT_FrameworkEditor/Private/UT_FrameworkEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,19 @@ bool FUT_FrameworkEditorModule::CanCompile(const UBlueprint* Blueprint)
return Cast<UStateMachineBlueprint>(Blueprint) != nullptr;
}

void FUT_FrameworkEditorModule::Compile(UBlueprint* Blueprint, const FKismetCompilerOptions& CompileOptions, FCompilerResultsLog& Results, TArray<UObject *>* ObjLoaded)
void FUT_FrameworkEditorModule::Compile(UBlueprint* Blueprint, const FKismetCompilerOptions& CompileOptions, FCompilerResultsLog& Results)
{
if (UStateMachineBlueprint* StateMachineBlueprint = CastChecked<UStateMachineBlueprint>(Blueprint))
{
FStateMachineBlueprintCompiler Compiler(StateMachineBlueprint, Results, CompileOptions, ObjLoaded);
FStateMachineBlueprintCompiler Compiler(StateMachineBlueprint, Results, CompileOptions);
Compiler.Compile();
check(Compiler.NewClass);
}
}

TSharedPtr<FKismetCompilerContext> FUT_FrameworkEditorModule::GetCompilerForBlueprint(UBlueprint* BP, FCompilerResultsLog& InMessageLog, const FKismetCompilerOptions& InCompileOptions)
{
return TSharedPtr<FKismetCompilerContext>(new FStateMachineBlueprintCompiler(CastChecked<UStateMachineBlueprint>(BP), InMessageLog, InCompileOptions, nullptr));
return TSharedPtr<FKismetCompilerContext>(new FStateMachineBlueprintCompiler(CastChecked<UStateMachineBlueprint>(BP), InMessageLog, InCompileOptions));
}

#undef LOCTEXT_NAMESPACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class FFlipbookAnimationSection
virtual void BeginResizeSection() override;
virtual void ResizeSection(ESequencerSectionResizeMode ResizeMode, FFrameNumber ResizeFrameNumber) override;
virtual void BeginSlipSection() override;
virtual void SlipSection(double SlipTime) override;
virtual void SlipSection(FFrameNumber SlipTime) override;

private:

Expand All @@ -110,7 +110,7 @@ class FFlipbookAnimationSection
TWeakPtr<ISequencer> Sequencer;

/** Cached start offset value valid only during resize */
float InitialStartOffsetDuringResize;
FFrameNumber InitialStartOffsetDuringResize;

/** Cached start time valid only during resize */
FFrameNumber InitialStartTimeDuringResize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class UT_FRAMEWORKEDITOR_API FStateMachineBlueprintCompiler : public FKismetComp
/* FUNCTIONS */
/************************************************************************/

FStateMachineBlueprintCompiler(UStateMachineBlueprint* SourceSketch, FCompilerResultsLog& InMessageLog, const FKismetCompilerOptions& InCompilerOptions, TArray<UObject*>* InObjLoaded);
FStateMachineBlueprintCompiler(UStateMachineBlueprint* SourceSketch, FCompilerResultsLog& InMessageLog, const FKismetCompilerOptions& InCompilerOptions);
virtual ~FStateMachineBlueprintCompiler();

// FKismetCompilerContext
Expand Down
2 changes: 1 addition & 1 deletion Source/UT_FrameworkEditor/Public/UT_FrameworkEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class FUT_FrameworkEditorModule : public IModuleInterface, public IHasMenuExtens

/** IBlueprintCompiler implementation */
virtual bool CanCompile(const UBlueprint* Blueprint) override;
virtual void Compile(UBlueprint* Blueprint, const FKismetCompilerOptions& CompileOptions, FCompilerResultsLog& Results, TArray<UObject *>* ObjLoaded) override;
virtual void Compile(UBlueprint* Blueprint, const FKismetCompilerOptions& CompileOptions, FCompilerResultsLog& Results) override;
static TSharedPtr<FKismetCompilerContext> GetCompilerForBlueprint(UBlueprint* BP, FCompilerResultsLog& InMessageLog, const FKismetCompilerOptions& InCompileOptions);

static inline FUT_FrameworkEditorModule& Get()
Expand Down

0 comments on commit 6e468d6

Please sign in to comment.