Exemple #1
0
 private void Evaluate(Playable playable, FrameData frameData)
 {
     if (this.m_IntervalTree != null)
     {
         double time = PlayableExtensions.GetTime <Playable>(playable);
         this.m_ActiveBit = ((this.m_ActiveBit != 0) ? 0 : 1);
         this.m_CurrentListOfActiveClips.Clear();
         this.m_IntervalTree.IntersectsWith(DiscreteTime.GetNearestTick(time), this.m_ActiveBit, ref this.m_CurrentListOfActiveClips);
         for (int i = 0; i < this.m_ActiveClips.Count; i++)
         {
             RuntimeElement runtimeElement = this.m_ActiveClips[i];
             if (runtimeElement.intervalBit != this.m_ActiveBit)
             {
                 runtimeElement.enable = false;
             }
         }
         for (int j = 0; j < this.m_CurrentListOfActiveClips.Count; j++)
         {
             this.m_CurrentListOfActiveClips[j].EvaluateAt(time, frameData);
         }
         this.m_ActiveClips.Clear();
         this.m_ActiveClips.AddRange(this.m_CurrentListOfActiveClips);
         int count = this.m_EvaluateCallbacks.Count;
         for (int k = 0; k < count; k++)
         {
             this.m_EvaluateCallbacks[k].Evaluate();
         }
     }
 }
Exemple #2
0
        private void Evaluate(Playable playable, FrameData frameData)
        {
            if (m_IntervalTree == null)
            {
                return;
            }

            double localTime = playable.GetTime();

            m_ActiveBit = m_ActiveBit == 0 ? 1 : 0;

            m_CurrentListOfActiveClips.Clear();
            m_IntervalTree.IntersectsWith(DiscreteTime.GetNearestTick(localTime), m_CurrentListOfActiveClips);

            foreach (var c in m_CurrentListOfActiveClips)
            {
                c.intervalBit = m_ActiveBit;
                if (frameData.timeLooped)
                {
                    c.Reset();
                }
            }

            // all previously active clips having a different intervalBit flag are not
            // in the current intersection, therefore are considered becoming disabled at this frame
            var timelineEnd = playable.GetDuration();

            foreach (var c in m_ActiveClips)
            {
                if (c.intervalBit != m_ActiveBit)
                {
                    var clipEnd = (double)DiscreteTime.FromTicks(c.intervalEnd);
                    var time    = frameData.timeLooped ? Math.Min(clipEnd, timelineEnd) : Math.Min(localTime, clipEnd);
                    c.EvaluateAt(time, frameData);
                    c.enable = false;
                }
            }

            m_ActiveClips.Clear();
            // case 998642 - don't use m_ActiveClips.AddRange, as in 4.6 .Net scripting it causes GC allocs
            for (var a = 0; a < m_CurrentListOfActiveClips.Count; a++)
            {
                m_CurrentListOfActiveClips[a].EvaluateAt(localTime, frameData);
                m_ActiveClips.Add(m_CurrentListOfActiveClips[a]);
            }

            int count = m_EvaluateCallbacks.Count;

            for (int i = 0; i < count; i++)
            {
                m_EvaluateCallbacks[i].Evaluate();
            }
        }
        private void Evaluate(Playable playable, FrameData frameData)
        {
            if (m_IntervalTree == null)
            {
                return;
            }

            double localTime = playable.GetTime();

            m_ActiveBit = m_ActiveBit == 0 ? 1 : 0;

            m_CurrentListOfActiveClips.Clear();
            m_IntervalTree.IntersectsWith(DiscreteTime.GetNearestTick(localTime), m_CurrentListOfActiveClips);

            foreach (var c in m_CurrentListOfActiveClips)
            {
                c.intervalBit = m_ActiveBit;
            }


            // all previously active clips having a different intervalBit flag are not
            // in the current intersection, therefore are considered becoming disabled at this frame
            for (int a = 0; a < m_ActiveClips.Count; a++)
            {
                var c = m_ActiveClips[a];
                if (c.intervalBit != m_ActiveBit)
                {
                    // Set time to the latest timeline time before disabling the clip.
                    c.EvaluateAt(localTime, frameData);
                    c.enable = false;
                }
            }

            m_ActiveClips.Clear();
            // case 998642 - don't use m_ActiveClips.AddRange, as in 4.6 .Net scripting it causes GC allocs
            for (int a = 0; a < m_CurrentListOfActiveClips.Count; a++)
            {
                m_CurrentListOfActiveClips[a].EvaluateAt(localTime, frameData);
                m_ActiveClips.Add(m_CurrentListOfActiveClips[a]);
            }

            int count = m_EvaluateCallbacks.Count;

            for (int i = 0; i < count; i++)
            {
                m_EvaluateCallbacks[i].Evaluate();
            }
        }
Exemple #4
0
        protected internal virtual void UpdateDuration()
        {
            int h   = (!(this.m_AnimClip != null)) ? 0 : ((int)(this.m_AnimClip.frameRate * this.m_AnimClip.length));
            int num = HashUtility.CombineHash(this.GetClipsHash(), this.GetMarkerHash(), h);

            if (num != this.m_ItemsHash)
            {
                this.m_ItemsHash = num;
                double num2;
                double num3;
                this.GetSequenceTime(out num2, out num3);
                this.m_Start = (DiscreteTime)num2;
                this.m_End   = (DiscreteTime)(num2 + num3);
                this.CalculateExtrapolationTimes();
            }
        }
        private bool CanTriggerEvent(double playableTime, FrameData info)
        {
            bool flag = DiscreteTime.GetNearestTick(playableTime) >= DiscreteTime.GetNearestTick(this.triggerTime);
            bool result;

            if (flag)
            {
                result = true;
            }
            else
            {
                bool flag2 = this.HasLooped(playableTime, info) && this.triggerTime >= this.m_PreviousTime && this.triggerTime <= this.m_PreviousTime + (double)info.get_deltaTime();
                result = flag2;
            }
            return(result);
        }
        public override void DisableAt(double localTime, double rootDuration, FrameData frameData)
        {
            var time = Math.Min(localTime, (double)DiscreteTime.FromTicks(intervalEnd));

            if (frameData.timeLooped)
            {
                time = Math.Min(time, rootDuration);
            }

            var clipTime = clip.ToLocalTime(time);

            if (clipTime > -DiscreteTime.tickValue / 2)
            {
                SetTime(clipTime);
            }
            enable = false;
        }
Exemple #7
0
        void UpdateDuration()
        {
            // check if something changed in the clips that require a re-calculation of the evaluation times.
            var itemsHash = CalculateItemsHash();
            if (itemsHash == m_ItemsHash)
                return;
            m_ItemsHash = itemsHash;

            double trackStart, trackDuration;
            GetSequenceTime(out trackStart, out trackDuration);

            m_Start = (DiscreteTime)trackStart;
            m_End = (DiscreteTime)(trackStart + trackDuration);

            // calculate the extrapolations time.
            // TODO Extrapolation time should probably be extracted from the SequenceClip so only a track is aware of it.
            this.CalculateExtrapolationTimes();
        }
Exemple #8
0
        double CalculateDuration()
        {
            var discreteDuration = new DiscreteTime(0);

            foreach (var track in flattenedTracks)
            {
                if (track.muted)
                {
                    continue;
                }

                discreteDuration = DiscreteTime.Max(discreteDuration, (DiscreteTime)track.end);
            }

            if (discreteDuration <= 0)
            {
                return(0.0);
            }

            //avoid having no clip evaluated at the end by removing a tick from the total duration
            return((double)discreteDuration.OneTickBefore());
        }
        private double CalculateDuration()
        {
            IEnumerable <TrackAsset> flattenedTracks = this.flattenedTracks;
            DiscreteTime             lhs             = new DiscreteTime(0);

            foreach (TrackAsset trackAsset in flattenedTracks)
            {
                if (!trackAsset.muted)
                {
                    lhs = DiscreteTime.Max(lhs, (DiscreteTime)trackAsset.end);
                }
            }
            double result;

            if (lhs <= 0)
            {
                result = 0.0;
            }
            else
            {
                result = (double)lhs.OneTickBefore();
            }
            return(result);
        }
Exemple #10
0
 public bool Equals(DiscreteTime other)
 {
     return(m_DiscreteTime == other.m_DiscreteTime);
 }
 public static long GetNearestTick(double time)
 {
     return(DiscreteTime.DoubleToDiscreteTime(time));
 }
Exemple #12
0
 public DiscreteTime(DiscreteTime time)
 {
     m_DiscreteTime = time.m_DiscreteTime;
 }
Exemple #13
0
 public static DiscreteTime Max(DiscreteTime lhs, DiscreteTime rhs)
 {
     return(new DiscreteTime(Math.Max(lhs.m_DiscreteTime, rhs.m_DiscreteTime)));
 }
 public DiscreteTime(int frame, double fps)
 {
     this.m_DiscreteTime = DiscreteTime.DoubleToDiscreteTime((double)frame * fps);
 }
 private static long IntToDiscreteTime(int time)
 {
     return(DiscreteTime.DoubleToDiscreteTime((double)time));
 }
 public DiscreteTime(int time)
 {
     this.m_DiscreteTime = DiscreteTime.IntToDiscreteTime(time);
 }
 public DiscreteTime(float time)
 {
     this.m_DiscreteTime = DiscreteTime.FloatToDiscreteTime(time);
 }
 private static float ToFloat(long time)
 {
     return((float)DiscreteTime.ToDouble(time));
 }
        public static double SnapToNearestTick(double time)
        {
            long time2 = DiscreteTime.DoubleToDiscreteTime(time);

            return(DiscreteTime.ToDouble(time2));
        }
        public static float SnapToNearestTick(float time)
        {
            long time2 = DiscreteTime.FloatToDiscreteTime(time);

            return(DiscreteTime.ToFloat(time2));
        }
 private bool CanRestoreEvent(double playableTime, FrameData info)
 {
     return(DiscreteTime.GetNearestTick(playableTime) < DiscreteTime.GetNearestTick(this.triggerTime));
 }
 public DiscreteTime(double time)
 {
     this.m_DiscreteTime = DiscreteTime.DoubleToDiscreteTime(time);
 }