// Copyright Epic Games, Inc. All Rights Reserved. #include "LiveLinkVirtualSubject.h" #include "ILiveLinkClient.h" #include "LiveLinkFrameTranslator.h" void ULiveLinkVirtualSubject::Initialize(FLiveLinkSubjectKey InSubjectKey, TSubclassOf InRole, ILiveLinkClient* InLiveLinkClient) { // The role for Virtual Subject should already be defined in the constructor of the default object. //It it used by the FLiveLinkRoleTrait to found the available Virtual Subject check(Role == InRole); SubjectKey = InSubjectKey; LiveLinkClient = InLiveLinkClient; } void ULiveLinkVirtualSubject::Update() { // Invalid the snapshot FrameSnapshot.StaticData.Reset(); FrameSnapshot.FrameData.Reset(); UpdateTranslatorsForThisFrame(); } void ULiveLinkVirtualSubject::ClearFrames() { FrameSnapshot.StaticData.Reset(); } bool ULiveLinkVirtualSubject::HasValidFrameSnapshot() const { return FrameSnapshot.StaticData.IsValid() && FrameSnapshot.FrameData.IsValid(); } TArray ULiveLinkVirtualSubject::GetFrameTimes() const { if (!HasValidFrameSnapshot()) { return TArray(); } TArray Result; Result.Emplace(FrameSnapshot.FrameData.GetBaseData()->WorldTime.GetOffsettedTime(), FrameSnapshot.FrameData.GetBaseData()->MetaData.SceneTime); return Result; } bool ULiveLinkVirtualSubject::DependsOnSubject(FName SubjectName) const { return Subjects.Contains(SubjectName); } void ULiveLinkVirtualSubject::UpdateTranslatorsForThisFrame() { // Create the new translator for this frame CurrentFrameTranslators.Reset(); for (ULiveLinkFrameTranslator* Translator : FrameTranslators) { if (Translator) { ULiveLinkFrameTranslator::FWorkerSharedPtr NewTranslator = Translator->FetchWorker(); if (NewTranslator.IsValid()) { CurrentFrameTranslators.Add(NewTranslator); } } } }