void UMovieSceneShotTrack::FixupSurroundingShots( UMovieSceneSection& Section, bool bDelete ) { // Find the previous section and extend it to take the place of the section being deleted int32 SectionIndex = INDEX_NONE; if( SubMovieSceneSections.Find( &Section, SectionIndex ) ) { int32 PrevSectionIndex = SectionIndex - 1; if( SubMovieSceneSections.IsValidIndex( PrevSectionIndex ) ) { // Extend the previous section SubMovieSceneSections[PrevSectionIndex]->SetEndTime( bDelete ? Section.GetEndTime() : Section.GetStartTime() ); } if( !bDelete ) { int32 NextSectionIndex = SectionIndex + 1; if(SubMovieSceneSections.IsValidIndex(NextSectionIndex)) { // Shift the next shot's start time so that it starts when the new shot ends SubMovieSceneSections[NextSectionIndex]->SetStartTime(Section.GetEndTime()); } } } SortShots(); }
void UMovieSceneShotTrack::RemoveSection( UMovieSceneSection* Section ) { FixupSurroundingShots( *Section, true ); Super::RemoveSection( Section ); SortShots(); // @todo Sequencer: The movie scene owned by the section is now abandoned. Should we offer to delete it? }
void UMovieSceneShotTrack::AddNewShot(FGuid CameraHandle, UMovieScene& ShotMovieScene, const TRange<float>& TimeRange, const FText& ShotName, int32 ShotNumber ) { Modify(); FName UniqueShotName = MakeUniqueObjectName( this, UMovieSceneShotSection::StaticClass(), *ShotName.ToString() ); UMovieSceneShotSection* NewSection = NewObject<UMovieSceneShotSection>( this, UniqueShotName, RF_Transactional ); NewSection->SetMovieScene( &ShotMovieScene ); NewSection->SetStartTime( TimeRange.GetLowerBoundValue() ); NewSection->SetEndTime( TimeRange.GetUpperBoundValue() ); NewSection->SetCameraGuid( CameraHandle ); NewSection->SetShotNameAndNumber( ShotName , ShotNumber ); SubMovieSceneSections.Add( NewSection ); // When a new shot is added, sort all shots to ensure they are in the correct order SortShots(); }
void UMovieSceneShotTrack::AddNewShot(FGuid CameraHandle, UMovieSceneSequence& ShotMovieSceneSequence, float StartTime, const FText& ShotName, int32 ShotNumber ) { Modify(); FName UniqueShotName = MakeUniqueObjectName( this, UMovieSceneShotSection::StaticClass(), *ShotName.ToString() ); UMovieSceneShotSection* NewSection = NewObject<UMovieSceneShotSection>( this, UniqueShotName, RF_Transactional ); NewSection->SetMovieSceneAnimation( &ShotMovieSceneSequence ); NewSection->SetStartTime( StartTime ); NewSection->SetEndTime( FindEndTimeForShot( StartTime ) ); NewSection->SetCameraGuid( CameraHandle ); NewSection->SetShotNameAndNumber( ShotName , ShotNumber ); SubMovieSceneSections.Add( NewSection ); // When a new shot is added, sort all shots to ensure they are in the correct order SortShots(); // Once shots are sorted fixup the surrounding shots to fix any gaps FixupSurroundingShots( *NewSection, false ); }
void UMovieSceneShotTrack::OnSectionMoved( UMovieSceneSection& Section ) { // Sort all shots when one moves. They should be in order of start time SortShots(); }