void UAnimComposite::GetAnimationPose(FCompactPose& OutPose, FBlendedCurve& OutCurve, const FAnimExtractContext& ExtractionContext) const { AnimationTrack.GetAnimationPose(OutPose, OutCurve, ExtractionContext); FBlendedCurve CompositeCurve; CompositeCurve.InitFrom(OutCurve); EvaluateCurveData(CompositeCurve, ExtractionContext.CurrentTime); // combine both curve OutCurve.Combine(CompositeCurve); }
void UAnimSingleNodeInstance::InternalBlendSpaceEvaluatePose(class UBlendSpaceBase* BlendSpace, TArray<FBlendSampleData>& BlendSampleDataCache, FPoseContext& OutContext) { USkeletalMeshComponent* Component = GetSkelMeshComponent(); if (BlendSpace->IsValidAdditive()) { FCompactPose& OutPose = OutContext.Pose; FBlendedCurve& OutCurve = OutContext.Curve; FCompactPose AdditivePose; FBlendedCurve AdditiveCurve; AdditivePose.SetBoneContainer(&OutPose.GetBoneContainer()); AdditiveCurve.InitFrom(OutCurve); #if WITH_EDITORONLY_DATA if (BlendSpace->PreviewBasePose) { BlendSpace->PreviewBasePose->GetBonePose(/*out*/ OutPose, /*out*/OutCurve, FAnimExtractContext(PreviewPoseCurrentTime)); } else #endif // WITH_EDITORONLY_DATA { // otherwise, get ref pose OutPose.ResetToRefPose(); } BlendSpace->GetAnimationPose(BlendSampleDataCache, AdditivePose, AdditiveCurve); enum EAdditiveAnimationType AdditiveType = BlendSpace->bRotationBlendInMeshSpace? AAT_RotationOffsetMeshSpace : AAT_LocalSpaceBase; FAnimationRuntime::AccumulateAdditivePose(OutPose, AdditivePose, OutCurve, AdditiveCurve, 1.f, AdditiveType); } else { BlendSpace->GetAnimationPose(BlendSampleDataCache, OutContext.Pose, OutContext.Curve); } }
bool UAnimSingleNodeInstance::NativeEvaluateAnimation(FPoseContext& Output) { if (CurrentAsset != NULL) { //@TODO: animrefactor: Seems like more code duplication than we need if (UBlendSpaceBase* BlendSpace = Cast<UBlendSpaceBase>(CurrentAsset)) { InternalBlendSpaceEvaluatePose(BlendSpace, BlendSampleData, Output); } else if (UAnimSequence* Sequence = Cast<UAnimSequence>(CurrentAsset)) { if (Sequence->IsValidAdditive()) { FAnimExtractContext ExtractionContext(CurrentTime, Sequence->bEnableRootMotion); Sequence->GetAdditiveBasePose(Output.Pose, Output.Curve, ExtractionContext); FCompactPose AdditivePose; FBlendedCurve AdditiveCurve; AdditivePose.SetBoneContainer(&Output.Pose.GetBoneContainer()); AdditiveCurve.InitFrom(Output.Curve); Sequence->GetAnimationPose(AdditivePose, AdditiveCurve, ExtractionContext); FAnimationRuntime::AccumulateAdditivePose(Output.Pose, AdditivePose, Output.Curve, AdditiveCurve, 1.f, Sequence->AdditiveAnimType); Output.Pose.NormalizeRotations(); } else { // if SkeletalMesh isn't there, we'll need to use skeleton Sequence->GetAnimationPose(Output.Pose, Output.Curve, FAnimExtractContext(CurrentTime, Sequence->bEnableRootMotion)); } } else if (UAnimComposite* Composite = Cast<UAnimComposite>(CurrentAsset)) { FAnimExtractContext ExtractionContext(CurrentTime, ShouldExtractRootMotion()); const FAnimTrack& AnimTrack = Composite->AnimationTrack; // find out if this is additive animation if (AnimTrack.IsAdditive()) { #if WITH_EDITORONLY_DATA if (Composite->PreviewBasePose) { Composite->PreviewBasePose->GetAdditiveBasePose(Output.Pose, Output.Curve, ExtractionContext); } else #endif { // get base pose - for now we only support ref pose as base Output.Pose.ResetToRefPose(); } EAdditiveAnimationType AdditiveAnimType = AnimTrack.IsRotationOffsetAdditive()? AAT_RotationOffsetMeshSpace : AAT_LocalSpaceBase; FCompactPose AdditivePose; FBlendedCurve AdditiveCurve; AdditivePose.SetBoneContainer(&Output.Pose.GetBoneContainer()); AdditiveCurve.InitFrom(Output.Curve); Composite->GetAnimationPose(AdditivePose, AdditiveCurve, ExtractionContext); FAnimationRuntime::AccumulateAdditivePose(Output.Pose, AdditivePose, Output.Curve, AdditiveCurve, 1.f, AdditiveAnimType); } else { //doesn't handle additive yet Composite->GetAnimationPose(Output.Pose, Output.Curve, ExtractionContext); } } else if (UAnimMontage* Montage = Cast<UAnimMontage>(CurrentAsset)) { // for now only update first slot // in the future, add option to see which slot to see if (Montage->SlotAnimTracks.Num() > 0) { FCompactPose SourcePose; FBlendedCurve SourceCurve; SourcePose.SetBoneContainer(&Output.Pose.GetBoneContainer()); SourceCurve.InitFrom(Output.Curve); if (Montage->IsValidAdditive()) { #if WITH_EDITORONLY_DATA // if montage is additive, we need to have base pose for the slot pose evaluate if (Montage->PreviewBasePose && Montage->SequenceLength > 0.f) { Montage->PreviewBasePose->GetBonePose(SourcePose, SourceCurve, FAnimExtractContext(CurrentTime)); } else #endif // WITH_EDITORONLY_DATA { SourcePose.ResetToRefPose(); } } else { SourcePose.ResetToRefPose(); } SlotEvaluatePose(Montage->SlotAnimTracks[0].SlotName, SourcePose, SourceCurve, Output.Pose, Output.Curve, 1.f); } } } if(CurrentVertexAnim != NULL) { VertexAnims.Add(FActiveVertexAnim(CurrentVertexAnim, 1.f, CurrentTime)); } return true; }