Files
UnrealEngineUWP/Engine/Source/Runtime/LiveLinkInterface/Private/ILiveLinkSubject.cpp

103 lines
3.4 KiB
C++
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
#include "ILiveLinkSubject.h"
#include "ILiveLinkClient.h"
#include "LiveLinkFrameTranslator.h"
#include "LiveLinkLog.h"
bool ILiveLinkSubject::EvaluateFrame(TSubclassOf<ULiveLinkRole> InDesiredRole, FLiveLinkSubjectFrameData& OutFrame)
{
TSubclassOf<ULiveLinkRole> Role = GetRole();
if (Role == nullptr)
{
static const FName NAME_InvalidRole = "ILiveLinkSubject_InvalidRole";
FLiveLinkLog::WarningOnce(NAME_InvalidRole, GetSubjectKey(), TEXT("Can't evaluate frame for '%s'. No role has been set."), *GetSubjectKey().SubjectName.ToString());
return false;
}
if (InDesiredRole == nullptr)
{
static const FName NAME_InvalidRequestedRole = "ILiveLinkSubject_InvalidRequestedRole";
FLiveLinkLog::WarningOnce(NAME_InvalidRequestedRole, GetSubjectKey(), TEXT("Can't evaluate frame for '%s'. The requested role is invalid."), *GetSubjectKey().SubjectName.ToString());
return false;
}
if (!HasValidFrameSnapshot())
{
static const FName NAME_HasValidFrameSnapshot = "ILiveLinkSubject_HasValidFrameSnapshot";
FLiveLinkLog::InfoOnce(NAME_HasValidFrameSnapshot, GetSubjectKey(), TEXT("Can't evaluate frame for '%s'. No data was available."), *GetSubjectKey().SubjectName.ToString());
return false;
}
if (Role == InDesiredRole || Role->IsChildOf(InDesiredRole))
{
//Copy the current snapshot over
OutFrame.StaticData.InitializeWith(GetFrameSnapshot().StaticData);
OutFrame.FrameData.InitializeWith(GetFrameSnapshot().FrameData);
return true;
}
Shutdown LiveLink sources when the engine close. #rb simon.therriault #jira UE-76445 fix CIS missing include introduce with CL 6907128 #jra UE-75946 #rb none Fix when converting old live link sequence data. Was always creating an animation role data but sequence with no bones should be made with the basic role only. #rb mike.zyracki #jira UE-76037 Added AxisSwitch PreProcessor for LiveLink #jira UE-75519 #rb patrick.boutot, simon.therriault Fix for empty curves in old live link sequence data #rb patrick.boutot #jira UE-76037 Fix LiveLink style path for one image. #rb simon.therriault, jamie.dale #jira UE-75287 Fix for crash when opening Mobu. TargetPlatformManager must be initialized early on in game thread when using UDPMessaging #rb patrick.boutot #jira UE-75680 Add deprecation path for LiveLinkBlueprintStructs. #jira UE-76057 #rb simon.therriault Update EvaluateLiveLink blueprint node. Fix output and use the role as a separate output. Remove LiveLink evaluate by world time and use World Time Offset, since we are using double for time and float is not precise enough. Add evaluate LiveLink at sene and world time to Blueprint. Expose LiveLink "enabled" functions #rb simon.therriault #jira UE-75794 Missing include introduce with last integration CL 6939912 #rb none #jira UE-76120, UE-76121 - Fix for crash when evaluating a basic object from mobu with the skeleton hierarchy (property names were not matching property values) #rb patrick.boutot #jira UE-75057, UE-75579 Add default value for LiveLinkFrameInterpolator #rb simon.therriault #jira UE-76443 - Changed behavior when static data received with different role. Previous subject is removed and a new one is created - Fix for crash when pushing subject frame without static data received. #rb patrick.boutot #jira UE-75195 Fix for LiveLinkComponent posteditchange not listening for inner struct member changed #rb patrick.boutot, daniel.rahier #jira UE-75793 Add comments and deprecation path to LiveLinkSourceFactor #rb simon.therriault [FYI] david.hibbitts - Updating LiveLink AnimPose and PreviewController to use new picker #rb patrick.boutot #jira UE-75600 Fixing CIS : Missing include and deprecation warning disable #rb patrick.boutot #jira UE-76424, UE-76420 #ROBOMERGE-SOURCE: CL 7065660 in //UE4/Release-4.23/... #ROBOMERGE-BOT: RELEASE (Release-4.23 -> Main) (v367-6836689) [CL 7065663 by patrick boutot in Main branch]
2019-06-18 14:32:41 -04:00
const bool bSuccess = Translate(this, InDesiredRole, GetFrameSnapshot().StaticData, GetFrameSnapshot().FrameData, OutFrame);
if (!bSuccess)
{
static FName NAME_CantTranslate = "ILiveLinkSubject_CantTranslate";
NAME_CantTranslate.SetNumber(GetTypeHash(InDesiredRole->GetFName())); // Create a unique FName with the role as number. ie. ILiveLinkSubject_CantTranslate_8465
FLiveLinkLog::WarningOnce(NAME_CantTranslate, GetSubjectKey(), TEXT("Can't evaluate frame for '%s'. The requested role is '%s' and no translators was able to translate it."), *GetSubjectKey().SubjectName.ToString(), *InDesiredRole->GetName());
Shutdown LiveLink sources when the engine close. #rb simon.therriault #jira UE-76445 fix CIS missing include introduce with CL 6907128 #jra UE-75946 #rb none Fix when converting old live link sequence data. Was always creating an animation role data but sequence with no bones should be made with the basic role only. #rb mike.zyracki #jira UE-76037 Added AxisSwitch PreProcessor for LiveLink #jira UE-75519 #rb patrick.boutot, simon.therriault Fix for empty curves in old live link sequence data #rb patrick.boutot #jira UE-76037 Fix LiveLink style path for one image. #rb simon.therriault, jamie.dale #jira UE-75287 Fix for crash when opening Mobu. TargetPlatformManager must be initialized early on in game thread when using UDPMessaging #rb patrick.boutot #jira UE-75680 Add deprecation path for LiveLinkBlueprintStructs. #jira UE-76057 #rb simon.therriault Update EvaluateLiveLink blueprint node. Fix output and use the role as a separate output. Remove LiveLink evaluate by world time and use World Time Offset, since we are using double for time and float is not precise enough. Add evaluate LiveLink at sene and world time to Blueprint. Expose LiveLink "enabled" functions #rb simon.therriault #jira UE-75794 Missing include introduce with last integration CL 6939912 #rb none #jira UE-76120, UE-76121 - Fix for crash when evaluating a basic object from mobu with the skeleton hierarchy (property names were not matching property values) #rb patrick.boutot #jira UE-75057, UE-75579 Add default value for LiveLinkFrameInterpolator #rb simon.therriault #jira UE-76443 - Changed behavior when static data received with different role. Previous subject is removed and a new one is created - Fix for crash when pushing subject frame without static data received. #rb patrick.boutot #jira UE-75195 Fix for LiveLinkComponent posteditchange not listening for inner struct member changed #rb patrick.boutot, daniel.rahier #jira UE-75793 Add comments and deprecation path to LiveLinkSourceFactor #rb simon.therriault [FYI] david.hibbitts - Updating LiveLink AnimPose and PreviewController to use new picker #rb patrick.boutot #jira UE-75600 Fixing CIS : Missing include and deprecation warning disable #rb patrick.boutot #jira UE-76424, UE-76420 #ROBOMERGE-SOURCE: CL 7065660 in //UE4/Release-4.23/... #ROBOMERGE-BOT: RELEASE (Release-4.23 -> Main) (v367-6836689) [CL 7065663 by patrick boutot in Main branch]
2019-06-18 14:32:41 -04:00
}
return bSuccess;
}
bool ILiveLinkSubject::SupportsRole(TSubclassOf<ULiveLinkRole> InDesiredRole) const
{
if (GetRole() == InDesiredRole || GetRole()->IsChildOf(InDesiredRole))
{
return true;
}
for (ULiveLinkFrameTranslator::FWorkerSharedPtr Translator : GetFrameTranslators())
{
check(Translator.IsValid());
if (Translator->CanTranslate(InDesiredRole))
{
return true;
}
}
return false;
}
bool ILiveLinkSubject::Translate(const ILiveLinkSubject* InLinkSubject, TSubclassOf<ULiveLinkRole> InDesiredRole, const FLiveLinkStaticDataStruct& InStaticData, const FLiveLinkFrameDataStruct& InFrameData, FLiveLinkSubjectFrameData& OutFrame)
{
// Find one that matches exactly
bool bFound = false;
for (ULiveLinkFrameTranslator::FWorkerSharedPtr Translator : InLinkSubject->GetFrameTranslators())
{
check(Translator.IsValid());
if (Translator->GetToRole() == InDesiredRole)
{
Translator->Translate(InStaticData, InFrameData, OutFrame);
bFound = true;
break;
}
}
if (!bFound)
{
for (ULiveLinkFrameTranslator::FWorkerSharedPtr Translator : InLinkSubject->GetFrameTranslators())
{
if (Translator->CanTranslate(InDesiredRole))
{
Translator->Translate(InStaticData, InFrameData, OutFrame);
bFound = true;
break;
}
}
}
return bFound;
}