2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2015-09-04 05:34:10 -04:00
|
|
|
#include "ActorAnimationPrivatePCH.h"
|
2015-07-22 10:59:40 -04:00
|
|
|
#include "ActorAnimationPlayer.h"
|
|
|
|
|
#include "MovieScene.h"
|
2015-07-27 12:12:59 -04:00
|
|
|
#include "MovieSceneSequence.h"
|
|
|
|
|
#include "MovieSceneSequenceInstance.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2015-07-06 17:04:30 -04:00
|
|
|
|
2015-09-18 04:56:12 -04:00
|
|
|
struct FTickAnimationPlayers : public FTickableGameObject
|
|
|
|
|
{
|
|
|
|
|
TArray<TWeakObjectPtr<UActorAnimationPlayer>> ActiveInstances;
|
|
|
|
|
|
|
|
|
|
virtual bool IsTickable() const override
|
|
|
|
|
{
|
|
|
|
|
return ActiveInstances.Num() != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual TStatId GetStatId() const override
|
|
|
|
|
{
|
|
|
|
|
RETURN_QUICK_DECLARE_CYCLE_STAT(FTickAnimationPlayers, STATGROUP_Tickables);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void Tick(float DeltaSeconds) override
|
|
|
|
|
{
|
|
|
|
|
for (int32 Index = 0; Index < ActiveInstances.Num();)
|
|
|
|
|
{
|
|
|
|
|
if (auto* Player = ActiveInstances[Index].Get())
|
|
|
|
|
{
|
|
|
|
|
Player->Update(DeltaSeconds);
|
|
|
|
|
++Index;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ActiveInstances.RemoveAt(Index, 1, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct FAutoDestroyAnimationTicker
|
|
|
|
|
{
|
|
|
|
|
FAutoDestroyAnimationTicker()
|
|
|
|
|
{
|
|
|
|
|
FCoreDelegates::OnPreExit.AddLambda([&]{
|
|
|
|
|
Impl.Reset();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Add(UActorAnimationPlayer* Player)
|
|
|
|
|
{
|
|
|
|
|
if (!Impl.IsValid())
|
|
|
|
|
{
|
|
|
|
|
Impl.Reset(new FTickAnimationPlayers);
|
|
|
|
|
}
|
|
|
|
|
Impl->ActiveInstances.Add(Player);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TUniquePtr<FTickAnimationPlayers> Impl;
|
|
|
|
|
} GAnimationPlayerTicker;
|
|
|
|
|
|
2015-07-22 10:59:40 -04:00
|
|
|
/* UActorAnimationPlayer structors
|
2015-07-14 14:13:08 -04:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
2015-07-22 10:59:40 -04:00
|
|
|
UActorAnimationPlayer::UActorAnimationPlayer(const FObjectInitializer& ObjectInitializer)
|
2015-07-14 14:13:08 -04:00
|
|
|
: Super(ObjectInitializer)
|
2015-09-18 04:56:12 -04:00
|
|
|
, ActorAnimationInstance(nullptr)
|
2015-07-14 14:13:08 -04:00
|
|
|
, bIsPlaying(false)
|
|
|
|
|
, TimeCursorPosition(0.0f)
|
2015-09-18 04:56:12 -04:00
|
|
|
, CurrentNumLoops(0)
|
2015-07-14 14:13:08 -04:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
2015-07-22 10:59:40 -04:00
|
|
|
/* UActorAnimationPlayer interface
|
2015-07-14 14:13:08 -04:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
2015-09-21 06:00:58 -04:00
|
|
|
UActorAnimationPlayer* UActorAnimationPlayer::CreateActorAnimationPlayer(UObject* WorldContextObject, UActorAnimation* ActorAnimation, FActorAnimationPlaybackSettings Settings)
|
2015-07-22 10:59:40 -04:00
|
|
|
{
|
|
|
|
|
if (ActorAnimation == nullptr)
|
|
|
|
|
{
|
2015-09-04 05:34:10 -04:00
|
|
|
return nullptr;
|
2015-07-22 10:59:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject);
|
|
|
|
|
check(World != nullptr);
|
|
|
|
|
|
2015-09-18 04:56:12 -04:00
|
|
|
UActorAnimationPlayer* NewPlayer = NewObject<UActorAnimationPlayer>(GetTransientPackage(), NAME_None, RF_Transient);
|
2015-07-22 10:59:40 -04:00
|
|
|
check(NewPlayer != nullptr);
|
|
|
|
|
|
2015-09-18 04:56:12 -04:00
|
|
|
// Set up a new instance of the actor animation for the player
|
|
|
|
|
UActorAnimationInstance* Instance = NewObject<UActorAnimationInstance>(NewPlayer);
|
|
|
|
|
Instance->Initialize(ActorAnimation, World, false);
|
|
|
|
|
|
|
|
|
|
NewPlayer->Initialize(Instance, World, Settings);
|
|
|
|
|
|
|
|
|
|
// Automatically tick this player
|
|
|
|
|
GAnimationPlayerTicker.Add(NewPlayer);
|
2015-09-04 05:34:10 -04:00
|
|
|
|
|
|
|
|
return NewPlayer;
|
2015-07-22 10:59:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool UActorAnimationPlayer::IsPlaying() const
|
2015-07-14 14:13:08 -04:00
|
|
|
{
|
|
|
|
|
return bIsPlaying;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-07-22 10:59:40 -04:00
|
|
|
void UActorAnimationPlayer::Pause()
|
2015-07-14 14:13:08 -04:00
|
|
|
{
|
2014-03-14 14:13:41 -04:00
|
|
|
bIsPlaying = false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-18 04:56:12 -04:00
|
|
|
void UActorAnimationPlayer::Stop()
|
|
|
|
|
{
|
|
|
|
|
bIsPlaying = false;
|
2015-09-21 06:00:58 -04:00
|
|
|
TimeCursorPosition = PlaybackSettings.PlayRate < 0.f ? GetLength() : 0.f;
|
2015-09-18 04:56:12 -04:00
|
|
|
CurrentNumLoops = 0;
|
|
|
|
|
|
|
|
|
|
// todo: Trigger an event?
|
|
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2015-07-22 10:59:40 -04:00
|
|
|
void UActorAnimationPlayer::Play()
|
2015-07-14 14:13:08 -04:00
|
|
|
{
|
2015-09-18 04:56:12 -04:00
|
|
|
if ((ActorAnimationInstance == nullptr) || !World.IsValid())
|
2015-07-14 14:13:08 -04:00
|
|
|
{
|
2015-07-22 10:59:40 -04:00
|
|
|
return;
|
2015-07-14 14:13:08 -04:00
|
|
|
}
|
2015-07-22 10:59:40 -04:00
|
|
|
|
|
|
|
|
// @todo Sequencer playback: Should we recreate the instance every time?
|
2015-09-18 04:56:12 -04:00
|
|
|
RootMovieSceneInstance = MakeShareable(new FMovieSceneSequenceInstance(*ActorAnimationInstance));
|
2015-07-22 10:59:40 -04:00
|
|
|
|
|
|
|
|
// @odo Sequencer Should we spawn actors here?
|
|
|
|
|
SpawnActorsForMovie(RootMovieSceneInstance.ToSharedRef());
|
|
|
|
|
RootMovieSceneInstance->RefreshInstance(*this);
|
2015-09-21 06:00:58 -04:00
|
|
|
|
2015-07-14 14:13:08 -04:00
|
|
|
bIsPlaying = true;
|
2015-09-21 06:00:58 -04:00
|
|
|
|
|
|
|
|
if (RootMovieSceneInstance.IsValid())
|
|
|
|
|
{
|
|
|
|
|
RootMovieSceneInstance->Update(TimeCursorPosition, TimeCursorPosition, *this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UActorAnimationPlayer::PlayLooping(int32 NumLoops)
|
|
|
|
|
{
|
|
|
|
|
PlaybackSettings.LoopCount = NumLoops;
|
|
|
|
|
Play();
|
2015-07-14 14:13:08 -04:00
|
|
|
}
|
|
|
|
|
|
2015-09-18 04:56:12 -04:00
|
|
|
float UActorAnimationPlayer::GetPlaybackPosition() const
|
|
|
|
|
{
|
|
|
|
|
return TimeCursorPosition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UActorAnimationPlayer::SetPlaybackPosition(float NewPlaybackPosition)
|
|
|
|
|
{
|
|
|
|
|
float LastTimePosition = TimeCursorPosition;
|
|
|
|
|
|
|
|
|
|
TimeCursorPosition = NewPlaybackPosition;
|
|
|
|
|
OnCursorPositionChanged();
|
|
|
|
|
|
|
|
|
|
if (RootMovieSceneInstance.IsValid())
|
|
|
|
|
{
|
|
|
|
|
RootMovieSceneInstance->Update(TimeCursorPosition, LastTimePosition, *this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float UActorAnimationPlayer::GetLength() const
|
|
|
|
|
{
|
|
|
|
|
if (!ActorAnimationInstance)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UMovieScene* MovieScene = ActorAnimationInstance->GetMovieScene();
|
|
|
|
|
return MovieScene ? MovieScene->GetTimeRange().Size<float>() : 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-21 06:00:58 -04:00
|
|
|
float UActorAnimationPlayer::GetPlayRate() const
|
|
|
|
|
{
|
|
|
|
|
return PlaybackSettings.PlayRate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UActorAnimationPlayer::SetPlayRate(float PlayRate)
|
|
|
|
|
{
|
|
|
|
|
PlaybackSettings.PlayRate = PlayRate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-09-18 04:56:12 -04:00
|
|
|
void UActorAnimationPlayer::OnCursorPositionChanged()
|
|
|
|
|
{
|
|
|
|
|
float Length = GetLength();
|
|
|
|
|
|
|
|
|
|
// Handle looping or stopping
|
|
|
|
|
if (TimeCursorPosition > Length || TimeCursorPosition < 0)
|
|
|
|
|
{
|
|
|
|
|
if (PlaybackSettings.LoopCount < 0 || CurrentNumLoops < PlaybackSettings.LoopCount)
|
|
|
|
|
{
|
|
|
|
|
++CurrentNumLoops;
|
|
|
|
|
const float Overplay = FMath::Fmod(TimeCursorPosition, Length);
|
|
|
|
|
TimeCursorPosition = Overplay < 0 ? Length + Overplay : Overplay;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-09-21 06:00:58 -04:00
|
|
|
// Stop playing without modifying the playback position
|
|
|
|
|
// @todo: trigger an event?
|
|
|
|
|
bIsPlaying = false;
|
|
|
|
|
CurrentNumLoops = 0;
|
2015-09-18 04:56:12 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-14 14:13:08 -04:00
|
|
|
|
2015-07-22 10:59:40 -04:00
|
|
|
/* UActorAnimationPlayer implementation
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
2015-09-18 04:56:12 -04:00
|
|
|
void UActorAnimationPlayer::Initialize(UActorAnimationInstance* InActorAnimationInstance, UWorld* InWorld, const FActorAnimationPlaybackSettings& Settings)
|
2015-07-22 10:59:40 -04:00
|
|
|
{
|
2015-09-18 04:56:12 -04:00
|
|
|
ActorAnimationInstance = InActorAnimationInstance;
|
|
|
|
|
|
2015-07-22 10:59:40 -04:00
|
|
|
World = InWorld;
|
2015-09-18 04:56:12 -04:00
|
|
|
PlaybackSettings = Settings;
|
|
|
|
|
|
|
|
|
|
// Ensure everything is set up, ready for playback
|
|
|
|
|
Stop();
|
2015-07-22 10:59:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-07-14 14:13:08 -04:00
|
|
|
/* IMovieScenePlayer interface
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
2015-07-27 12:12:59 -04:00
|
|
|
void UActorAnimationPlayer::SpawnActorsForMovie(TSharedRef<FMovieSceneSequenceInstance> MovieSceneInstance)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-07-18 13:58:52 -04:00
|
|
|
UWorld* WorldPtr = World.Get();
|
|
|
|
|
|
|
|
|
|
if (WorldPtr == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-27 12:12:59 -04:00
|
|
|
UMovieScene* MovieScene = MovieSceneInstance->GetSequence()->GetMovieScene();
|
2015-07-18 13:58:52 -04:00
|
|
|
|
|
|
|
|
if (MovieScene == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArray<FSpawnedActorInfo>* FoundSpawnedActors = InstanceToSpawnedActorMap.Find(MovieSceneInstance);
|
|
|
|
|
|
|
|
|
|
if (FoundSpawnedActors != nullptr)
|
|
|
|
|
{
|
|
|
|
|
// Remove existing spawned actors for this movie
|
|
|
|
|
DestroyActorsForMovie( MovieSceneInstance );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArray<FSpawnedActorInfo>& SpawnedActorList = InstanceToSpawnedActorMap.Add(MovieSceneInstance, TArray<FSpawnedActorInfo>());
|
|
|
|
|
|
|
|
|
|
for (auto SpawnableIndex = 0; SpawnableIndex < MovieScene->GetSpawnableCount(); ++SpawnableIndex)
|
|
|
|
|
{
|
|
|
|
|
auto& Spawnable = MovieScene->GetSpawnable(SpawnableIndex);
|
|
|
|
|
UClass* GeneratedClass = Spawnable.GetClass();
|
|
|
|
|
|
|
|
|
|
if ((GeneratedClass == nullptr) || !GeneratedClass->IsChildOf(AActor::StaticClass()))
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-07-18 13:58:52 -04:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AActor* ActorCDO = CastChecked<AActor>(GeneratedClass->ClassDefaultObject);
|
|
|
|
|
const FVector SpawnLocation = ActorCDO->GetRootComponent()->RelativeLocation;
|
|
|
|
|
const FRotator SpawnRotation = ActorCDO->GetRootComponent()->RelativeRotation;
|
|
|
|
|
|
|
|
|
|
FActorSpawnParameters SpawnInfo;
|
|
|
|
|
{
|
|
|
|
|
SpawnInfo.ObjectFlags = RF_NoFlags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AActor* NewActor = WorldPtr->SpawnActor(GeneratedClass, &SpawnLocation, &SpawnRotation, SpawnInfo);
|
|
|
|
|
|
|
|
|
|
if (NewActor)
|
|
|
|
|
{
|
|
|
|
|
// Actor was spawned OK!
|
|
|
|
|
FSpawnedActorInfo NewInfo;
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-07-18 13:58:52 -04:00
|
|
|
NewInfo.RuntimeGuid = Spawnable.GetGuid();
|
|
|
|
|
NewInfo.SpawnedActor = NewActor;
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2015-07-18 13:58:52 -04:00
|
|
|
SpawnedActorList.Add(NewInfo);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-06 17:04:30 -04:00
|
|
|
|
2015-07-27 12:12:59 -04:00
|
|
|
void UActorAnimationPlayer::DestroyActorsForMovie(TSharedRef<FMovieSceneSequenceInstance> MovieSceneInstance)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-07-18 13:58:52 -04:00
|
|
|
UWorld* WorldPtr = World.Get();
|
|
|
|
|
|
|
|
|
|
if (WorldPtr == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArray<FSpawnedActorInfo>* SpawnedActors = InstanceToSpawnedActorMap.Find(MovieSceneInstance);
|
|
|
|
|
|
|
|
|
|
if (SpawnedActors == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArray<FSpawnedActorInfo>& SpawnedActorsRef = *SpawnedActors;
|
|
|
|
|
|
|
|
|
|
for(int32 ActorIndex = 0; ActorIndex < SpawnedActors->Num(); ++ActorIndex)
|
|
|
|
|
{
|
|
|
|
|
AActor* Actor = SpawnedActorsRef[ActorIndex].SpawnedActor.Get();
|
|
|
|
|
|
|
|
|
|
if (Actor != nullptr)
|
|
|
|
|
{
|
|
|
|
|
// @todo Sequencer figure this out. Defaults to false.
|
|
|
|
|
const bool bNetForce = false;
|
|
|
|
|
|
|
|
|
|
// At runtime, level modification is not needed
|
|
|
|
|
const bool bShouldModifyLevel = false;
|
|
|
|
|
Actor->GetWorld()->DestroyActor(Actor, bNetForce, bShouldModifyLevel);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
}
|
2015-07-18 13:58:52 -04:00
|
|
|
|
|
|
|
|
InstanceToSpawnedActorMap.Remove(MovieSceneInstance);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
2015-07-06 17:04:30 -04:00
|
|
|
|
2015-07-27 12:12:59 -04:00
|
|
|
void UActorAnimationPlayer::GetRuntimeObjects(TSharedRef<FMovieSceneSequenceInstance> MovieSceneInstance, const FGuid& ObjectId, TArray<UObject*>& OutObjects) const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
// @todo sequencer runtime: Add support for individually spawning actors on demand when first requested?
|
|
|
|
|
// This may be important to reduce the up-front hitch when spawning actors for the entire movie, but
|
|
|
|
|
// may introduce smaller hitches during playback. Needs experimentation.
|
|
|
|
|
|
2015-07-18 13:58:52 -04:00
|
|
|
const TArray<FSpawnedActorInfo>* SpawnedActors = InstanceToSpawnedActorMap.Find(MovieSceneInstance);
|
|
|
|
|
|
|
|
|
|
if ((SpawnedActors != nullptr) && (SpawnedActors->Num() > 0))
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-07-18 13:58:52 -04:00
|
|
|
// we have a spawned actor for this handle
|
2014-03-14 14:13:41 -04:00
|
|
|
const TArray<FSpawnedActorInfo>& SpawnedActorInfoRef = *SpawnedActors;
|
|
|
|
|
|
2015-07-18 13:58:52 -04:00
|
|
|
for (int32 SpawnedActorIndex = 0; SpawnedActorIndex < SpawnedActorInfoRef.Num(); ++SpawnedActorIndex)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
const FSpawnedActorInfo ActorInfo = SpawnedActorInfoRef[SpawnedActorIndex];
|
|
|
|
|
|
2015-07-22 10:59:40 -04:00
|
|
|
if ((ActorInfo.RuntimeGuid == ObjectId) && ActorInfo.SpawnedActor.IsValid())
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-07-18 13:58:52 -04:00
|
|
|
OutObjects.Add(ActorInfo.SpawnedActor.Get());
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-22 10:59:40 -04:00
|
|
|
else
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-07-18 13:58:52 -04:00
|
|
|
// otherwise, check whether we have one or more possessed actors that are mapped to this handle
|
2015-09-18 04:56:12 -04:00
|
|
|
UObject* FoundObject = ActorAnimationInstance->FindObject(ObjectId);
|
2015-07-22 10:59:40 -04:00
|
|
|
|
|
|
|
|
if (FoundObject != nullptr)
|
2015-06-30 14:49:26 -04:00
|
|
|
{
|
2015-07-22 10:59:40 -04:00
|
|
|
OutObjects.Add(FoundObject);
|
2015-06-30 14:49:26 -04:00
|
|
|
}
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-06 17:04:30 -04:00
|
|
|
|
2015-07-22 10:59:40 -04:00
|
|
|
void UActorAnimationPlayer::UpdateCameraCut(UObject* ObjectToViewThrough, bool bNewCameraCut) const
|
2015-06-29 11:07:33 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-28 10:23:45 -04:00
|
|
|
void UActorAnimationPlayer::SetViewportSettings(const TMap<FViewportClient*, EMovieSceneViewportParams>& ViewportParamsMap)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UActorAnimationPlayer::GetViewportSettings(TMap<FViewportClient*, EMovieSceneViewportParams>& ViewportParamsMap) const
|
|
|
|
|
{
|
|
|
|
|
}
|
2015-07-06 17:04:30 -04:00
|
|
|
|
2015-07-22 10:59:40 -04:00
|
|
|
EMovieScenePlayerStatus::Type UActorAnimationPlayer::GetPlaybackStatus() const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
return bIsPlaying ? EMovieScenePlayerStatus::Playing : EMovieScenePlayerStatus::Stopped;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-06 17:04:30 -04:00
|
|
|
|
2015-07-27 12:12:59 -04:00
|
|
|
void UActorAnimationPlayer::AddOrUpdateMovieSceneInstance(UMovieSceneSection& MovieSceneSection, TSharedRef<FMovieSceneSequenceInstance> InstanceToAdd)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
SpawnActorsForMovie( InstanceToAdd );
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-06 17:04:30 -04:00
|
|
|
|
2015-07-27 12:12:59 -04:00
|
|
|
void UActorAnimationPlayer::RemoveMovieSceneInstance(UMovieSceneSection& MovieSceneSection, TSharedRef<FMovieSceneSequenceInstance> InstanceToRemove)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
const bool bDestroyAll = true;
|
|
|
|
|
DestroyActorsForMovie( InstanceToRemove );
|
2015-07-06 17:04:30 -04:00
|
|
|
}
|
2015-07-14 14:13:08 -04:00
|
|
|
|
2015-07-27 12:12:59 -04:00
|
|
|
TSharedRef<FMovieSceneSequenceInstance> UActorAnimationPlayer::GetRootMovieSceneSequenceInstance() const
|
2015-07-14 14:13:08 -04:00
|
|
|
{
|
|
|
|
|
return RootMovieSceneInstance.ToSharedRef();
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-18 04:56:12 -04:00
|
|
|
void UActorAnimationPlayer::Update(const float DeltaSeconds)
|
2015-07-14 14:13:08 -04:00
|
|
|
{
|
|
|
|
|
float LastTimePosition = TimeCursorPosition;
|
|
|
|
|
|
|
|
|
|
if (bIsPlaying)
|
|
|
|
|
{
|
2015-09-21 06:00:58 -04:00
|
|
|
TimeCursorPosition += DeltaSeconds * PlaybackSettings.PlayRate;
|
2015-09-18 04:56:12 -04:00
|
|
|
OnCursorPositionChanged();
|
2015-07-14 14:13:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(RootMovieSceneInstance.IsValid())
|
|
|
|
|
{
|
|
|
|
|
RootMovieSceneInstance->Update(TimeCursorPosition, LastTimePosition, *this);
|
|
|
|
|
}
|
|
|
|
|
}
|