// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "Containers/Array.h" #include "Containers/ArrayView.h" #include "Containers/ContainerAllocationPolicies.h" #include "CoreMinimal.h" #include "Evaluation/MovieSceneSegment.h" #include "HAL/Platform.h" #include "MovieSceneSection.h" #include "MovieSceneTrackEvaluationField.h" #include "Templates/Function.h" struct FMovieSceneTrackEvaluationData; template struct TMovieSceneEvaluationTree; namespace UE { namespace MovieScene { struct FEvaluationTreePopulationRules { /** * Structure used by population rules for sorting sections before adding them to the evaluation tree. */ struct FSortedSection { const UMovieSceneSection& Section; int32 Index; FSortedSection(const UMovieSceneSection& InSection, int32 InSectionIndex) : Section(InSection), Index(InSectionIndex) {} int32 Row() const { return Section.GetRowIndex(); } int32 OverlapPriority() const { return Section.GetOverlapPriority(); } //bool operator<(const FSortedSection& Other) const { return SortByOverlapPriorityAndRow(*this, Other); } static bool SortByOverlapPriorityAndRow(const FSortedSection& A, const FSortedSection& B) { if (A.Row() == B.Row()) { return A.OverlapPriority() > B.OverlapPriority(); } return A.Row() < B.Row(); } }; using FSectionSortPredicate = TFunctionRef; /** * Adds all active and non-empty sections to the evaluation tree. */ MOVIESCENE_API static void Blended(TArrayView Sections, TMovieSceneEvaluationTree& OutTree); /** * As above, but with custom sorting for the sections before they're added to the evaluation tree. */ MOVIESCENE_API static void Blended(TArrayView Sections, TMovieSceneEvaluationTree& OutTree, FSectionSortPredicate Predicate); /** * Adds active and non-empty sections to the evaluation tree based on priority: top rows have priority over bottom rows, * and overlapping sections have priority over underlapped sections. * Sections that have a valid blend type are always added to the tree. */ MOVIESCENE_API static void HighPass(TArrayView Sections, TMovieSceneEvaluationTree& OutTree); /** * Adds active and non-empty sections to the evaluation tree based on priority: overlapping sections have priority over * underlapped sections. * Sections that have a valid blend type are always added to the tree. */ MOVIESCENE_API static void HighPassPerRow(TArrayView Sections, TMovieSceneEvaluationTree& OutTree); /** * Adds active and non-empty sections to the evaluation tree based on the priority defined in the given predicate. * For any time range, only the first section (based on the given predicate's sorting) will be added to the evaluation tree, and others will be discarded. * Sections that have a valid blend type are always added to the tree. */ MOVIESCENE_API static void HighPassCustom(TArrayView Sections, TMovieSceneEvaluationTree& OutTree, FSectionSortPredicate Predicate); /** * Adds active and non-empty sections to the evaluation tree based on the priority defined in the given predicate. * For any time range, only the first section of each row (based on the given predicate's sorting) will be added to the evaluation tree, and others will be discarded. * Sections that have a valid blend type are always added to the tree. */ MOVIESCENE_API static void HighPassCustomPerRow(TArrayView Sections, TMovieSceneEvaluationTree& OutTree, FSectionSortPredicate Predicate); /** * Runs the logic to populate empty ranges in the field with the nearest section */ MOVIESCENE_API static void PopulateNearestSection(TArrayView Sections, TMovieSceneEvaluationTree& OutTree); private: static void SortSections(TArrayView Sections, TArray>& SortedSections, FSectionSortPredicate Predicate); }; } // namespace MovieScene } // namespace UE