//----------------------------------------------------------------------------------------------------------------------
        private static SISPlayableFrame CreatePlayableFrame(TimelineClipSISData owner, int index, double timePerFrame)
        {
            SISPlayableFrame playableFrame = new SISPlayableFrame(owner);

            playableFrame.SetIndexAndLocalTime(index, timePerFrame * index);
            return(playableFrame);
        }
//----------------------------------------------------------------------------------------------------------------------

        //Calculate the used image index for the passed localTime
        internal int LocalTimeToImageIndex(TimelineClip clip, double localTime)
        {
            TimelineClipSISData timelineSISData = GetBoundTimelineClipSISData();

            if (null != timelineSISData)
            {
                double scaledTimePerFrame = TimelineUtility.CalculateTimePerFrame(clip) * clip.timeScale;

                //Try to check if this frame is "dropped", so that we should use the image in the prev frame
                int playableFrameIndex         = Mathf.RoundToInt((float)localTime / (float)scaledTimePerFrame);
                SISPlayableFrame playableFrame = timelineSISData.GetPlayableFrame(playableFrameIndex);
                while (playableFrameIndex > 0 && !playableFrame.IsUsed())
                {
                    --playableFrameIndex;
                    playableFrame = timelineSISData.GetPlayableFrame(playableFrameIndex);
                    localTime     = playableFrameIndex * scaledTimePerFrame;
                }
            }


            double imageSequenceTime = LocalTimeToCurveTime(clip, localTime);
            int    count             = m_imageFileNames.Count;

            int index = Mathf.RoundToInt(count * (float)imageSequenceTime);

            index = Mathf.Clamp(index, 0, count - 1);
            return(index);
        }
        internal TimelineClipSISData(TimelineClip owner, TimelineClipSISData other) : this(owner){
            Assert.IsNotNull(m_playableFrames);

            foreach (SISPlayableFrame otherFrame in other.m_playableFrames)
            {
                SISPlayableFrame newFrame = new SISPlayableFrame(this, otherFrame);
                m_playableFrames.Add(newFrame);
            }

            m_frameMarkersRequested = other.m_frameMarkersRequested;
        }
Beispiel #4
0
        internal static T GetTimelineClipAsset <T>(this SISPlayableFrame playableFrame) where T : Object
        {
            TimelineClip timelineClip = playableFrame.GetOwner().GetOwner();

            if (null == timelineClip)
            {
                return(null);
            }

            T clipAsset = timelineClip.asset as T;

            return(clipAsset);
        }
//----------------------------------------------------------------------------------------------------------------------

        private void UpdatePlayableFramesSize(int reqPlayableFramesSize)
        {
            Assert.IsNotNull(m_clipOwner);

            double timePerFrame = TimelineUtility.CalculateTimePerFrame(m_clipOwner);

            //Resize m_playableFrames
            if (m_playableFrames.Count < reqPlayableFramesSize)
            {
                int numNewPlayableFrames = (reqPlayableFramesSize - m_playableFrames.Count);
                List <SISPlayableFrame> newPlayableFrames = new List <SISPlayableFrame>(numNewPlayableFrames);
                for (int i = m_playableFrames.Count; i < reqPlayableFramesSize; ++i)
                {
                    newPlayableFrames.Add(CreatePlayableFrame(this, i, timePerFrame));
                }
                m_playableFrames.AddRange(newPlayableFrames);
            }

            if (m_playableFrames.Count > reqPlayableFramesSize)
            {
                int numLastPlayableFrames = m_playableFrames.Count;
                for (int i = reqPlayableFramesSize; i < numLastPlayableFrames; ++i)
                {
                    SISPlayableFrame curFrame = m_playableFrames[i];
                    curFrame?.Destroy();
                }
                m_playableFrames.RemoveRange(reqPlayableFramesSize, numLastPlayableFrames - reqPlayableFramesSize);
            }

            Assert.IsTrue(m_playableFrames.Count == reqPlayableFramesSize);

            for (int i = 0; i < reqPlayableFramesSize; ++i)
            {
                SISPlayableFrame curPlayableFrame = m_playableFrames[i];
                Assert.IsNotNull(curPlayableFrame);
                m_playableFrames[i].SetIndexAndLocalTime(i, timePerFrame * i);
            }
        }
Beispiel #6
0
 internal void Init(SISPlayableFrame controller, double initialTime)
 {
     m_playableFrameOwner = controller;
     time = initialTime;
 }
Beispiel #7
0
//----------------------------------------------------------------------------------------------------------------------

        internal void SetOwner(SISPlayableFrame controller)
        {
            m_playableFrameOwner = controller;
        }
Beispiel #8
0
 internal static void SetUsed(this SISPlayableFrame playableFrame, bool used)
 {
     playableFrame.SetBoolProperty(PlayableFramePropertyID.USED, used);
 }
Beispiel #9
0
 internal static bool IsLocked(this SISPlayableFrame playableFrame)
 {
     return(null != playableFrame && playableFrame.GetBoolProperty(PlayableFramePropertyID.LOCKED));
 }
Beispiel #10
0
 internal SISPlayableFrame(TimelineClipSISData owner, SISPlayableFrame otherFrame)
 {
     m_timelineClipSISDataOwner = owner;
     m_boolProperties           = otherFrame.m_boolProperties;
     m_localTime = otherFrame.m_localTime;
 }