FReply SAnimationSegmentScrubPanel::OnClick_Forward() { UAnimSingleNodeInstance* PreviewInst = GetPreviewInstance(); if (PreviewInst) { bool bIsReverse = PreviewInst->IsReverse(); bool bIsPlaying = PreviewInst->IsPlaying(); // if current bIsReverse and bIsPlaying, we'd like to just turn off reverse if (bIsReverse && bIsPlaying) { PreviewInst->SetReverse(false); } // already playing, simply pause else if (bIsPlaying) { PreviewInst->SetPlaying(false); } // if not playing, play forward else { PreviewInst->SetReverse(false); PreviewInst->SetPlaying(true); } } return FReply::Handled(); }
void FMovieSceneSkeletalAnimationTrackInstance::PreviewSetAnimPosition(USkeletalMeshComponent* SkeletalMeshComponent, FName SlotName, int32 ChannelIndex, UAnimSequenceBase* InAnimSequence, float InPosition, bool bLooping, bool bFireNotifies, float DeltaTime, bool bPlaying, bool bResetDynamics) { if(CanPlayAnimation(SkeletalMeshComponent, InAnimSequence)) { UAnimMontage* Montage = FAnimMontageInstance::PreviewMatineeSetAnimPositionInner(SlotName, SkeletalMeshComponent, InAnimSequence, InPosition, bLooping, bFireNotifies, DeltaTime); // if we are not playing, make sure we dont continue (as skeletal meshes can still tick us onwards) UAnimInstance* AnimInst = SkeletalMeshComponent->GetAnimInstance(); UAnimSingleNodeInstance * SingleNodeInst = SkeletalMeshComponent->GetSingleNodeInstance(); if(SingleNodeInst) { SingleNodeInst->SetPlaying(bPlaying); } else if (AnimInst) { if(Montage) { if(bPlaying) { AnimInst->Montage_Resume(Montage); } else { AnimInst->Montage_Pause(Montage); } } if(bResetDynamics) { // make sure we reset any simulations AnimInst->ResetDynamics(); } } } }
void FMovieSceneSkeletalAnimationTrackInstance::RefreshInstance( const TArray<TWeakObjectPtr<UObject>>& RuntimeObjects, IMovieScenePlayer& Player, FMovieSceneSequenceInstance& SequenceInstance ) { UpdateRefreshBones(RuntimeObjects); // When not in preview playback we need to stop any running animations to prevent the animations from being advanced a frame when // they are ticked by the engine. for ( TWeakObjectPtr<UObject> RuntimeObjectPtr : RuntimeObjects ) { if ( ShouldUsePreviewPlayback( Player, RuntimeObjectPtr.Get() ) == false ) { USkeletalMeshComponent* SkeletalMeshComponent = GetSkeletalMeshComponentFromRuntimeObjectPtr( RuntimeObjectPtr ); if ( SkeletalMeshComponent != nullptr ) { UAnimInstance* AnimInstance = SkeletalMeshComponent->GetAnimInstance(); if ( AnimInstance ) { UAnimSingleNodeInstance * SingleNodeInstance = SkeletalMeshComponent->GetSingleNodeInstance(); if ( SingleNodeInstance ) { SingleNodeInstance->SetPlaying( false ); } // TODO: Anim montage? } } } } }
void FMovieSceneSkeletalAnimationTrackInstance::SetAnimPosition(USkeletalMeshComponent* SkeletalMeshComponent, FName SlotName, int32 ChannelIndex, UAnimSequenceBase* InAnimSequence, float InPosition, bool bLooping, bool bFireNotifies) { if (CanPlayAnimation(SkeletalMeshComponent, InAnimSequence)) { UAnimMontage* Montage = FAnimMontageInstance::SetMatineeAnimPositionInner(SlotName, SkeletalMeshComponent, InAnimSequence, InPosition, bLooping); // Ensure the sequence is not stopped UAnimInstance* AnimInst = SkeletalMeshComponent->GetAnimInstance(); UAnimSingleNodeInstance* SingleNodeInst = SkeletalMeshComponent->GetSingleNodeInstance(); if(SingleNodeInst) { SingleNodeInst->SetPlaying(true); } else if (AnimInst && Montage) { AnimInst->Montage_Resume(Montage); } } }