void FMovieSceneActorReferenceTrackInstance::Update(EMovieSceneUpdateData& UpdateData, const TArray<TWeakObjectPtr<UObject>>& RuntimeObjects, class IMovieScenePlayer& Player, FMovieSceneSequenceInstance& SequenceInstance ) { // TODO: Support default values. FGuid ActorReferenceGuid; if( ActorReferenceTrack->Eval( UpdateData.Position, UpdateData.LastPosition, ActorReferenceGuid ) ) { AActor* CurrentActor = nullptr; if (GuidToActorCache.Contains(ActorReferenceGuid)) { TWeakObjectPtr<AActor> CachedActor = *GuidToActorCache.Find(ActorReferenceGuid); if (CachedActor.IsValid()) { CurrentActor = CachedActor.Get(); } } if (CurrentActor == nullptr) { TArray<TWeakObjectPtr<UObject>> RuntimeObjectsForGuid; Player.GetRuntimeObjects(SequenceInstance.AsShared(), ActorReferenceGuid, RuntimeObjectsForGuid); if (RuntimeObjectsForGuid.Num() == 1) { AActor* ActorForGuid = Cast<AActor>(RuntimeObjectsForGuid[0].Get()); if (ActorForGuid != nullptr) { CurrentActor = ActorForGuid; if (CurrentActor != nullptr) { GuidToActorCache.Add(ActorReferenceGuid, CurrentActor); } } } } if (CurrentActor != nullptr) { for (auto ObjectPtr : RuntimeObjects) { UObject* Object = ObjectPtr.Get(); PropertyBindings->CallFunction<AActor*>(Object, &CurrentActor); } } } }
void FMovieSceneActorReferenceTrackInstance::Update(EMovieSceneUpdateData& UpdateData, const TArray<TWeakObjectPtr<UObject>>& RuntimeObjects, class IMovieScenePlayer& Player, FMovieSceneSequenceInstance& SequenceInstance ) { FGuid ActorReferenceGuid; if( ActorReferenceTrack->Eval( UpdateData.Position, UpdateData.LastPosition, ActorReferenceGuid ) ) { AActor* CurrentActor; AActor** CachedActorPtr = GuidToActorCache.Find( ActorReferenceGuid ); if (CachedActorPtr != nullptr) { CurrentActor = *CachedActorPtr; } else { TArray<TWeakObjectPtr<UObject>> RuntimeObjectsForGuid; Player.GetRuntimeObjects(SequenceInstance.AsShared(), ActorReferenceGuid, RuntimeObjectsForGuid); if (RuntimeObjectsForGuid.Num() == 1) { AActor* ActorForGuid = Cast<AActor>(RuntimeObjectsForGuid[0].Get()); if (ActorForGuid != nullptr) { CurrentActor = ActorForGuid; GuidToActorCache.Add(ActorReferenceGuid, CurrentActor); } } } for (auto ObjectPtr : RuntimeObjects) { UObject* Object = ObjectPtr.Get(); PropertyBindings->CallFunction<AActor*>(Object, &CurrentActor); } } }