2020-08-11 01:36:57 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "Systems/MovieScenePropertySystem.h"
|
|
|
|
|
#include "Systems/MovieScenePropertyInstantiator.h"
|
|
|
|
|
|
|
|
|
|
#include "EntitySystem/MovieSceneEntitySystemLinker.h"
|
2021-05-12 18:10:03 -04:00
|
|
|
#include "Evaluation/PreAnimatedState/MovieScenePreAnimatedEntityCaptureSource.h"
|
2020-08-11 01:36:57 -04:00
|
|
|
|
|
|
|
|
UMovieScenePropertySystem::UMovieScenePropertySystem(const FObjectInitializer& ObjInit)
|
|
|
|
|
: Super(ObjInit)
|
2020-09-01 14:07:48 -04:00
|
|
|
{
|
|
|
|
|
SystemExclusionContext |= UE::MovieScene::EEntitySystemContext::Interrogation;
|
|
|
|
|
}
|
2020-08-11 01:36:57 -04:00
|
|
|
|
|
|
|
|
void UMovieScenePropertySystem::OnLink()
|
|
|
|
|
{
|
2020-09-01 14:07:48 -04:00
|
|
|
using namespace UE::MovieScene;
|
|
|
|
|
|
|
|
|
|
// Never apply properties during evaluation. This code is necessary if derived types do support interrogation.
|
|
|
|
|
if (!EnumHasAnyFlags(Linker->GetSystemContext(), EEntitySystemContext::Interrogation))
|
|
|
|
|
{
|
|
|
|
|
InstantiatorSystem = Linker->LinkSystem<UMovieScenePropertyInstantiatorSystem>();
|
|
|
|
|
Linker->SystemGraph.AddReference(this, InstantiatorSystem);
|
|
|
|
|
}
|
2020-08-11 01:36:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UMovieScenePropertySystem::OnRun(FSystemTaskPrerequisites& InPrerequisites, FSystemSubsequentTasks& Subsequents)
|
|
|
|
|
{
|
|
|
|
|
using namespace UE::MovieScene;
|
|
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
// Never apply properties during evaluation. This code is necessary if derived types do support interrogation.
|
|
|
|
|
if (EnumHasAnyFlags(Linker->GetSystemContext(), EEntitySystemContext::Interrogation))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-11 01:36:57 -04:00
|
|
|
FPropertyStats Stats = InstantiatorSystem->GetStatsForProperty(CompositePropertyID);
|
|
|
|
|
if (Stats.NumProperties > 0)
|
|
|
|
|
{
|
2021-05-12 18:10:03 -04:00
|
|
|
const FPropertyRegistry& PropertyRegistry = FBuiltInComponentTypes::Get()->PropertyRegistry;
|
|
|
|
|
const FPropertyDefinition& Definition = PropertyRegistry.GetDefinition(CompositePropertyID);
|
2020-08-11 01:36:57 -04:00
|
|
|
|
2021-05-12 18:10:03 -04:00
|
|
|
Definition.Handler->DispatchSetterTasks(Definition, PropertyRegistry.GetComposites(Definition), Stats, InPrerequisites, Subsequents, Linker);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UMovieScenePropertySystem::SavePreAnimatedState(const FPreAnimationParameters& InParameters)
|
|
|
|
|
{
|
|
|
|
|
using namespace UE::MovieScene;
|
|
|
|
|
|
|
|
|
|
using FThreeWayAccessor = TMultiReadOptional<FCustomPropertyIndex, uint16, TSharedPtr<FTrackInstancePropertyBindings>>;
|
|
|
|
|
|
|
|
|
|
FBuiltInComponentTypes* BuiltInComponents = FBuiltInComponentTypes::Get();
|
|
|
|
|
|
|
|
|
|
const FPropertyDefinition& Definition = BuiltInComponents->PropertyRegistry.GetDefinition(CompositePropertyID);
|
|
|
|
|
|
|
|
|
|
TSharedPtr<IPreAnimatedStorage> PreAnimatedStorage = Definition.Handler->GetPreAnimatedStateStorage(Definition, InParameters.CacheExtension);
|
|
|
|
|
if (!PreAnimatedStorage)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PreAnimatedStorageID = PreAnimatedStorage->GetStorageType();
|
|
|
|
|
|
|
|
|
|
FComponentMask ComponentMask({ Definition.PropertyType });
|
|
|
|
|
if (!InParameters.CacheExtension->AreEntriesInvalidated())
|
|
|
|
|
{
|
|
|
|
|
ComponentMask.Set(BuiltInComponents->Tags.NeedsLink);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IPreAnimatedObjectEntityStorage* ObjectStorage = PreAnimatedStorage->AsObjectStorage())
|
|
|
|
|
{
|
|
|
|
|
FEntityTaskBuilder()
|
|
|
|
|
.ReadEntityIDs()
|
|
|
|
|
.Read(BuiltInComponents->RootInstanceHandle)
|
|
|
|
|
.Read(BuiltInComponents->BoundObject)
|
|
|
|
|
.FilterAll(ComponentMask)
|
|
|
|
|
.Iterate_PerAllocation(&Linker->EntityManager,
|
2022-03-04 15:09:42 -05:00
|
|
|
[ObjectStorage](FEntityAllocationIteratorItem Item, TRead<FMovieSceneEntityID> EntityIDs, TRead<FRootInstanceHandle> RootInstanceHandles, TRead<UObject*> BoundObjects)
|
2021-05-12 18:10:03 -04:00
|
|
|
{
|
|
|
|
|
ObjectStorage->BeginTrackingEntities(Item, EntityIDs, RootInstanceHandles, BoundObjects);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
FEntityTaskBuilder()
|
|
|
|
|
.Read(BuiltInComponents->BoundObject)
|
|
|
|
|
.FilterAll(ComponentMask)
|
|
|
|
|
.Iterate_PerAllocation(&Linker->EntityManager,
|
|
|
|
|
[ObjectStorage](FEntityAllocationIteratorItem Item, TRead<UObject*> Objects)
|
|
|
|
|
{
|
|
|
|
|
FCachePreAnimatedValueParams Params;
|
|
|
|
|
ObjectStorage->CachePreAnimatedValues(Params, Objects.AsArray(Item.GetAllocation()->Num()));
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
else if (IPreAnimatedObjectPropertyStorage* PropertyStorage = PreAnimatedStorage->AsPropertyStorage())
|
|
|
|
|
{
|
|
|
|
|
FEntityTaskBuilder()
|
|
|
|
|
.ReadEntityIDs()
|
|
|
|
|
.Read(BuiltInComponents->RootInstanceHandle)
|
|
|
|
|
.Read(BuiltInComponents->BoundObject)
|
|
|
|
|
.Read(BuiltInComponents->PropertyBinding)
|
|
|
|
|
.FilterAll(ComponentMask)
|
|
|
|
|
.Iterate_PerAllocation(&Linker->EntityManager,
|
2022-03-04 15:09:42 -05:00
|
|
|
[PropertyStorage](FEntityAllocationIteratorItem Item, TRead<FMovieSceneEntityID> EntityIDs, TRead<FRootInstanceHandle> RootInstanceHandles, TRead<UObject*> BoundObjects, TRead<FMovieScenePropertyBinding> PropertyBindings)
|
2021-05-12 18:10:03 -04:00
|
|
|
{
|
|
|
|
|
PropertyStorage->BeginTrackingEntities(Item, EntityIDs, RootInstanceHandles, BoundObjects, PropertyBindings);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
FEntityTaskBuilder()
|
|
|
|
|
.Read(BuiltInComponents->BoundObject)
|
|
|
|
|
.Read(BuiltInComponents->PropertyBinding)
|
|
|
|
|
.ReadOneOf(BuiltInComponents->CustomPropertyIndex, BuiltInComponents->FastPropertyOffset, BuiltInComponents->SlowProperty)
|
|
|
|
|
.FilterAll(ComponentMask)
|
|
|
|
|
.Iterate_PerAllocation(&Linker->EntityManager,
|
|
|
|
|
[PropertyStorage](FEntityAllocationIteratorItem Item, TRead<UObject*> Objects, TRead<FMovieScenePropertyBinding> PropertyBindings, FThreeWayAccessor ResolvedProperties)
|
|
|
|
|
{
|
|
|
|
|
FCachePreAnimatedValueParams Params;
|
|
|
|
|
PropertyStorage->CachePreAnimatedValues(Params, Item, Objects, PropertyBindings, ResolvedProperties);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UMovieScenePropertySystem::RestorePreAnimatedState(const FPreAnimationParameters& InParameters)
|
|
|
|
|
{
|
|
|
|
|
|
2020-08-11 01:36:57 -04:00
|
|
|
}
|