bool UMovieScene3DTransformSection::NewKeyIsNewData(const FTransformKey& TransformKey) const { bool bHasEmptyKeys = false; for (int32 i = 0; i < 3; ++i) { bHasEmptyKeys = bHasEmptyKeys || Translation[i].GetNumKeys() == 0 || Rotation[i].GetNumKeys() == 0 || Scale[i].GetNumKeys() == 0; } if ( bHasEmptyKeys || (TransformKey.KeyParams.bAutoKeying && TransformKey.ShouldKeyAny() ) ) { return true; } return false; }
void UMovieScene3DTransformSection::AddScaleKeys( const FTransformKey& TransformKey ) { const float Time = TransformKey.GetKeyTime(); if( TransformKey.KeyParams.bAddKeyEvenIfUnchanged || TransformKey.ShouldKeyScale( EAxis::X ) || Scale[0].GetNumKeys() == 0 ) { AddKeyToCurve( Scale[0], Time, TransformKey.GetScaleValue().X, TransformKey.KeyParams ); } if( TransformKey.KeyParams.bAddKeyEvenIfUnchanged || TransformKey.ShouldKeyScale( EAxis::Y ) || Scale[1].GetNumKeys() == 0 ) { AddKeyToCurve( Scale[1], Time, TransformKey.GetScaleValue().Y, TransformKey.KeyParams ); } if( TransformKey.KeyParams.bAddKeyEvenIfUnchanged || TransformKey.ShouldKeyScale( EAxis::Z ) || Scale[2].GetNumKeys() == 0 ) { AddKeyToCurve( Scale[2], Time, TransformKey.GetScaleValue().Z, TransformKey.KeyParams ); } }
void UMovieScene3DTransformSection::AddRotationKeys( const FTransformKey& TransformKey, const bool bUnwindRotation ) { const float Time = TransformKey.GetKeyTime(); if( TransformKey.KeyParams.bAddKeyEvenIfUnchanged || TransformKey.ShouldKeyRotation( EAxis::X ) || Rotation[0].GetNumKeys() == 0 ) { AddKeyToCurve( Rotation[0], Time, TransformKey.GetRotationValue().Roll, TransformKey.KeyParams, bUnwindRotation ); } if( TransformKey.KeyParams.bAddKeyEvenIfUnchanged || TransformKey.ShouldKeyRotation( EAxis::Y ) || Rotation[1].GetNumKeys() == 0 ) { AddKeyToCurve( Rotation[1], Time, TransformKey.GetRotationValue().Pitch, TransformKey.KeyParams, bUnwindRotation ); } if( TransformKey.KeyParams.bAddKeyEvenIfUnchanged || TransformKey.ShouldKeyRotation( EAxis::Z ) || Rotation[2].GetNumKeys() == 0 ) { AddKeyToCurve( Rotation[2], Time, TransformKey.GetRotationValue().Yaw, TransformKey.KeyParams, bUnwindRotation ); } }
bool UMovieSceneTransformTrack::AddKeyToSection( const FGuid& ObjectHandle, const FTransformKey& InKey, const bool bUnwindRotation ) { const UMovieSceneSection* NearestSection = MovieSceneHelpers::FindSectionAtTime(Sections, InKey.GetKeyTime()); if (!NearestSection || CastChecked<UMovieSceneTransformSection>(NearestSection)->NewKeyIsNewData(InKey)) { UMovieSceneTransformSection* NewSection = Cast<UMovieSceneTransformSection>( FindOrAddSection( InKey.GetKeyTime() ) ); // key each component of the transform NewSection->AddTranslationKeys( InKey ); NewSection->AddRotationKeys( InKey, bUnwindRotation ); NewSection->AddScaleKeys( InKey ); return true; } return false; }