// Copyright Epic Games, Inc. All Rights Reserved. #include "Systems/MovieScenePiecewiseBoolBlenderSystem.h" #include "EntitySystem/BuiltInComponentTypes.h" #include "EntitySystem/MovieSceneEntitySystemTask.h" #include "EntitySystem/MovieSceneEntitySystemLinker.h" #include UE_INLINE_GENERATED_CPP_BY_NAME(MovieScenePiecewiseBoolBlenderSystem) namespace UE { namespace MovieScene { /** * Custom blend result traits for booleans: * * - We don't blend booleans, we just OR them. * - Number of contributors doesn't matter. If there's at least one true value, the result is true. */ template<> struct TSimpleBlendResultTraits { static void ZeroAccumulationBuffer(TArrayView> Buffer) { FMemory::Memzero(Buffer.GetData(), sizeof(TSimpleBlendResult) * Buffer.Num()); } static void AccumulateResult(TSimpleBlendResult& InOutValue, bool Contributor) { InOutValue.Value |= Contributor; ++InOutValue.NumContributors; } static bool BlendResult(const TSimpleBlendResult& InResult) { return InResult.Value; } }; } // namespace MovieScene } // namespace UE UMovieScenePiecewiseBoolBlenderSystem::UMovieScenePiecewiseBoolBlenderSystem(const FObjectInitializer& ObjInit) : Super(ObjInit) { using namespace UE::MovieScene; Phase = ESystemPhase::Scheduling; Impl.Setup( this, UE::MovieScene::FBuiltInComponentTypes::Get()->BoolResult, nullptr); } void UMovieScenePiecewiseBoolBlenderSystem::OnSchedulePersistentTasks(UE::MovieScene::IEntitySystemScheduler* TaskScheduler) { using namespace UE::MovieScene; CompactBlendChannels(); Impl.Schedule(Linker, AllocatedBlendChannels, TaskScheduler); } void UMovieScenePiecewiseBoolBlenderSystem::OnRun(FSystemTaskPrerequisites& InPrerequisites, FSystemSubsequentTasks& Subsequents) { using namespace UE::MovieScene; CompactBlendChannels(); Impl.Run(Linker, AllocatedBlendChannels, InPrerequisites, Subsequents); }