Files
UnrealEngineUWP/Engine/Plugins/Runtime/GeometryCache/Source/GeometryCacheTracks/Private/MovieSceneGeometryCacheTrack.cpp
anousack kitisa 1d22901981 * Moved AlembicImporter and GeometryCache plugins out of experimental.
#jira UETOOL-4055
#rb none
#preflight 61f17bd8be0f0e0a6234afb2

#ROBOMERGE-AUTHOR: anousack.kitisa
#ROBOMERGE-SOURCE: CL 18737179 in //UE5/Release-5.0/... via CL 18737385 via CL 18738249
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)

[CL 18738699 by anousack kitisa in ue5-main branch]
2022-01-26 13:05:26 -05:00

138 lines
3.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "MovieSceneGeometryCacheTrack.h"
#include "GeometryCacheComponent.h"
#include "MovieSceneGeometryCacheSection.h"
#include "Compilation/MovieSceneCompilerRules.h"
#include "Evaluation/MovieSceneEvaluationTrack.h"
#include "MovieSceneGeometryCacheTemplate.h"
#include "Compilation/IMovieSceneTemplateGenerator.h"
#include "MovieSceneGeometryCacheTemplate.h"
#include "MovieScene.h"
#define LOCTEXT_NAMESPACE "MovieSceneGeometryCacheTrack"
/* UMovieSceneGeometryCacheTrack structors
*****************************************************************************/
UMovieSceneGeometryCacheTrack::UMovieSceneGeometryCacheTrack(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
#if WITH_EDITORONLY_DATA
TrackTint = FColor(124, 15, 124, 65);
#endif
SupportedBlendTypes.Add(EMovieSceneBlendType::Absolute);
EvalOptions.bCanEvaluateNearestSection = true;
EvalOptions.bEvaluateInPreroll = true;
}
/* UMovieSceneGeometryCacheTrack interface
*****************************************************************************/
UMovieSceneSection* UMovieSceneGeometryCacheTrack::AddNewAnimation(FFrameNumber KeyTime, UGeometryCacheComponent* GeomCacheComp)
{
UMovieSceneGeometryCacheSection* NewSection = Cast<UMovieSceneGeometryCacheSection>(CreateNewSection());
{
FFrameTime AnimationLength = GeomCacheComp->GetDuration()* GetTypedOuter<UMovieScene>()->GetTickResolution();
int32 IFrameNumber = AnimationLength.FrameNumber.Value + (int)(AnimationLength.GetSubFrame() + 0.5f) + 1;
NewSection->InitialPlacementOnRow(AnimationSections, KeyTime, IFrameNumber, INDEX_NONE);
NewSection->Params.GeometryCacheAsset = (GeomCacheComp->GetGeometryCache());
}
AddSection(*NewSection);
return NewSection;
}
TArray<UMovieSceneSection*> UMovieSceneGeometryCacheTrack::GetAnimSectionsAtTime(FFrameNumber Time)
{
TArray<UMovieSceneSection*> Sections;
for (auto Section : AnimationSections)
{
if (Section->IsTimeWithinSection(Time))
{
Sections.Add(Section);
}
}
return Sections;
}
FMovieSceneEvalTemplatePtr UMovieSceneGeometryCacheTrack::CreateTemplateForSection(const UMovieSceneSection& InSection) const
{
return FMovieSceneGeometryCacheSectionTemplate(*CastChecked<UMovieSceneGeometryCacheSection>(&InSection));
}
/* UMovieSceneTrack interface
*****************************************************************************/
const TArray<UMovieSceneSection*>& UMovieSceneGeometryCacheTrack::GetAllSections() const
{
return AnimationSections;
}
bool UMovieSceneGeometryCacheTrack::SupportsType(TSubclassOf<UMovieSceneSection> SectionClass) const
{
return SectionClass == UMovieSceneGeometryCacheSection::StaticClass();
}
UMovieSceneSection* UMovieSceneGeometryCacheTrack::CreateNewSection()
{
return NewObject<UMovieSceneGeometryCacheSection>(this, NAME_None, RF_Transactional);
}
void UMovieSceneGeometryCacheTrack::RemoveAllAnimationData()
{
AnimationSections.Empty();
}
bool UMovieSceneGeometryCacheTrack::HasSection(const UMovieSceneSection& Section) const
{
return AnimationSections.Contains(&Section);
}
void UMovieSceneGeometryCacheTrack::AddSection(UMovieSceneSection& Section)
{
AnimationSections.Add(&Section);
}
void UMovieSceneGeometryCacheTrack::RemoveSection(UMovieSceneSection& Section)
{
AnimationSections.Remove(&Section);
}
void UMovieSceneGeometryCacheTrack::RemoveSectionAt(int32 SectionIndex)
{
AnimationSections.RemoveAt(SectionIndex);
}
bool UMovieSceneGeometryCacheTrack::IsEmpty() const
{
return AnimationSections.Num() == 0;
}
#if WITH_EDITORONLY_DATA
FText UMovieSceneGeometryCacheTrack::GetDefaultDisplayName() const
{
return LOCTEXT("TrackName", "Geometry Cache");
}
#endif
#undef LOCTEXT_NAMESPACE