// Copyright Epic Games, Inc. All Rights Reserved. #include "MovieSceneGeometryCacheTrack.h" #include "GeometryCacheComponent.h" #include "MovieSceneGeometryCacheTemplate.h" #include "MovieSceneGeometryCacheTemplate.h" #include "MovieScene.h" #include UE_INLINE_GENERATED_CPP_BY_NAME(MovieSceneGeometryCacheTrack) #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(CreateNewSection()); { FFrameTime AnimationLength = GeomCacheComp->GetDuration()* GetTypedOuter()->GetTickResolution(); int32 IFrameNumber = AnimationLength.FrameNumber.Value + static_cast(AnimationLength.GetSubFrame() + 0.5f) + 1; NewSection->InitialPlacementOnRow(AnimationSections, KeyTime, IFrameNumber, INDEX_NONE); NewSection->Params.GeometryCacheAsset = (GeomCacheComp->GetGeometryCache()); } AddSection(*NewSection); return NewSection; } TArray UMovieSceneGeometryCacheTrack::GetAnimSectionsAtTime(FFrameNumber Time) { TArray Sections; for (auto Section : AnimationSections) { if (Section->IsTimeWithinSection(Time)) { Sections.Add(Section); } } return Sections; } FMovieSceneEvalTemplatePtr UMovieSceneGeometryCacheTrack::CreateTemplateForSection(const UMovieSceneSection& InSection) const { return FMovieSceneGeometryCacheSectionTemplate(*CastChecked(&InSection)); } /* UMovieSceneTrack interface *****************************************************************************/ const TArray& UMovieSceneGeometryCacheTrack::GetAllSections() const { return AnimationSections; } bool UMovieSceneGeometryCacheTrack::SupportsType(TSubclassOf SectionClass) const { return SectionClass == UMovieSceneGeometryCacheSection::StaticClass(); } UMovieSceneSection* UMovieSceneGeometryCacheTrack::CreateNewSection() { return NewObject(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