void UAnimCompress_BitwiseCompressOnly::DoReduction(UAnimSequence* AnimSeq, const TArray<FBoneData>& BoneData) { #if WITH_EDITORONLY_DATA // split the raw data into tracks TArray<FTranslationTrack> TranslationData; TArray<FRotationTrack> RotationData; TArray<FScaleTrack> ScaleData; SeparateRawDataIntoTracks( AnimSeq->RawAnimationData, AnimSeq->SequenceLength, TranslationData, RotationData, ScaleData ); // Remove Translation Keys from tracks marked bAnimRotationOnly FilterAnimRotationOnlyKeys(TranslationData, AnimSeq); // remove obviously redundant keys from the source data FilterTrivialKeys(TranslationData, RotationData, ScaleData, TRANSLATION_ZEROING_THRESHOLD, QUATERNION_ZEROING_THRESHOLD, SCALE_ZEROING_THRESHOLD); // bitwise compress the tracks into the anim sequence buffers BitwiseCompressAnimationTracks( AnimSeq, static_cast<AnimationCompressionFormat>(TranslationCompressionFormat), static_cast<AnimationCompressionFormat>(RotationCompressionFormat), static_cast<AnimationCompressionFormat>(ScaleCompressionFormat), TranslationData, RotationData, ScaleData); // record the proper runtime decompressor to use AnimSeq->KeyEncodingFormat = AKF_ConstantKeyLerp; AnimationFormat_SetInterfaceLinks(*AnimSeq); AnimSeq->CompressionScheme = static_cast<UAnimCompress*>( StaticDuplicateObject( this, AnimSeq, TEXT("None")) ); #endif // WITH_EDITORONLY_DATA }
void UAnimCompress_RemoveLinearKeys::DoReduction(UAnimSequence* AnimSeq, const TArray<FBoneData>& BoneData) { #if WITH_EDITORONLY_DATA // Only need to do the heavy lifting if it will have some impact // One of these will always be true for the base class, but derived classes may choose to turn both off (e.g., in PerTrackCompression) const bool bRunningProcessor = bRetarget || bActuallyFilterLinearKeys; if (GIsEditor && bRunningProcessor) { GWarn->BeginSlowTask( NSLOCTEXT("UAnimCompress_RemoveLinearKeys", "BeginReductionTaskMessage", "Compressing animation with a RemoveLinearKeys scheme."), false); } // If the processor is to be run, then additive animations need to be converted from relative to absolute const bool bNeedToConvertBackToAdditive = bRunningProcessor ? ConvertFromRelativeSpace(AnimSeq) : false; // Separate the raw data into tracks and remove trivial tracks (all the same value) TArray<FTranslationTrack> TranslationData; TArray<FRotationTrack> RotationData; TArray<FScaleTrack> ScaleData; SeparateRawDataIntoTracks(AnimSeq->RawAnimationData, AnimSeq->SequenceLength, TranslationData, RotationData, ScaleData); FilterBeforeMainKeyRemoval(AnimSeq, BoneData, TranslationData, RotationData, ScaleData); if (bRunningProcessor) { #if TIME_LINEAR_KEY_REMOVAL double TimeStart = FPlatformTime::Seconds(); #endif // compress this animation without any key-reduction to prime the codec CompressUsingUnderlyingCompressor( AnimSeq, BoneData, TranslationData, RotationData, ScaleData, false); // now remove the keys which can be approximated with linear interpolation ProcessAnimationTracks( AnimSeq, BoneData, TranslationData, RotationData, ScaleData); #if TIME_LINEAR_KEY_REMOVAL double ElapsedTime = FPlatformTime::Seconds() - TimeStart; UE_LOG(LogAnimationCompression, Log, TEXT("ProcessAnimationTracks time is (%f) seconds"),ElapsedTime); #endif // if previously additive, convert back to relative-space if( bNeedToConvertBackToAdditive ) { ConvertToRelativeSpace(AnimSeq, TranslationData, RotationData); } } // Remove Translation Keys from tracks marked bAnimRotationOnly FilterAnimRotationOnlyKeys(TranslationData, AnimSeq); // compress the final (possibly key-reduced) tracks into the anim sequence buffers CompressUsingUnderlyingCompressor( AnimSeq, BoneData, TranslationData, RotationData, ScaleData, true); if (GIsEditor && bRunningProcessor) { GWarn->EndSlowTask(); } AnimSeq->CompressionScheme = static_cast<UAnimCompress*>( StaticDuplicateObject( this, AnimSeq, TEXT("None")) ); #endif // WITH_EDITORONLY_DATA }