public void clearData()
 {
     observer  = null;
     posBuff   = null;
     scaleBuff = null;
     rotBuff   = null;
     isDirty   = true;
 }
        public void RegistToManager(FduTransformObserver_Ex observer)
        {
            if (FduSupportClass.isMaster)
            {
                return;
            }

            if (observer != null)
            {
                if (dataMap == null)
                {
                    dataMap = new List <BufferData>();
                    ThreadBoost();
                    isBoost = true;
                }
                waitForAddList.Add(observer);
            }
        }
        public static Quaternion getNextQuaternionValue_Ex(Quaternion now, FduTransformObserver_Ex observer)
        {
            var dts = observer.getDataTransmitStrategy();

            if (dts == null || !dts.GetType().Equals(typeof(FduDTS_EveryNFrame)))
            {
                return(Quaternion.identity);
            }
            FduDTS_EveryNFrame dtsN = (FduDTS_EveryNFrame)dts;

            try
            {
                FduDTS_EveryNFrame.InterpolationOption interOp = dtsN.getInterPolationOption();
                FduDTS_EveryNFrame.ExtrapolationOption extraOp = dtsN.getExtrapolationOption();

                int interval = dtsN.getInterval();
                int cur      = dtsN.getCurFrame();

                Vector3    offset     = Vector3.zero;
                Quaternion lastValue  = observer.getCachedRotation(observer.getCachedRotationCount() - 1);
                Vector3    eulerValue = lastValue.eulerAngles;
                if (extraOp != FduDTS_EveryNFrame.ExtrapolationOption.Disable)
                {
                    int count = observer.getCachedRotationCount();
                    if (count >= 2)
                    {
                        if (extraOp == FduDTS_EveryNFrame.ExtrapolationOption.CachedEarliest)
                        {
                            offset = (eulerValue - (observer.getCachedRotation(0).eulerAngles)) / (count - 1.0f);
                        }
                        else if (extraOp == FduDTS_EveryNFrame.ExtrapolationOption.CachedLatest)
                        {
                            offset = (eulerValue - (observer.getCachedRotation(count - 2)).eulerAngles);
                        }
                    }
                }
                eulerValue = eulerValue + offset;
                if (interOp == FduDTS_EveryNFrame.InterpolationOption.Disable)
                {
                    return(Quaternion.Euler(eulerValue));
                }
                else if (interOp == FduDTS_EveryNFrame.InterpolationOption.FixedStep || interOp == FduDTS_EveryNFrame.InterpolationOption.EstimateStep)
                {
                    if ((interval - cur + 1) > 0)
                    {
                        var res = Quaternion.Lerp(now, Quaternion.Euler(eulerValue), 1.0f / (interval - cur + 1));
                        return(res);
                    }
                    else
                    {
                        return(Quaternion.Euler(eulerValue));
                    }
                }
                else if (interOp == FduDTS_EveryNFrame.InterpolationOption.Lerp)
                {
                    return(Quaternion.Lerp(now, Quaternion.Euler(eulerValue), Time.deltaTime * dtsN.getLerpSpeed()));
                }
                return(Quaternion.Euler(eulerValue));
            }
            catch (System.Exception)
            {
                return(Quaternion.identity);
            }
        }
        public static Vector3 getNextScaleValue_Ex(Vector3 now, FduTransformObserver_Ex observer)
        {
            var dts = observer.getDataTransmitStrategy();

            if (dts == null || !dts.GetType().Equals(typeof(FduDTS_EveryNFrame)))
            {
                return(Vector3.zero);
            }
            FduDTS_EveryNFrame dtsN = (FduDTS_EveryNFrame)dts;

            try
            {
                FduDTS_EveryNFrame.InterpolationOption interOp = dtsN.getInterPolationOption();
                FduDTS_EveryNFrame.ExtrapolationOption extraOp = dtsN.getExtrapolationOption();

                int interval = dtsN.getInterval();
                int cur      = dtsN.getCurFrame();

                Vector3 offset    = Vector3.zero;
                Vector3 lastValue = observer.getCachedScale(observer.getCachedScaleCount() - 1);
                if (extraOp != FduDTS_EveryNFrame.ExtrapolationOption.Disable)
                {
                    int count = observer.getCachedScaleCount();
                    if (count >= 2)
                    {
                        if (extraOp == FduDTS_EveryNFrame.ExtrapolationOption.CachedEarliest)
                        {
                            offset = (lastValue - observer.getCachedScale(0)) / (count - 1.0f);
                        }
                        else if (extraOp == FduDTS_EveryNFrame.ExtrapolationOption.CachedLatest)
                        {
                            offset = (lastValue - observer.getCachedScale(count - 2));
                        }
                    }
                }
                lastValue = lastValue + offset;
                if (interOp == FduDTS_EveryNFrame.InterpolationOption.Disable)
                {
                    return(lastValue);
                }
                else if (interOp == FduDTS_EveryNFrame.InterpolationOption.EstimateStep)
                {
                    int count = observer.getCachedScaleCount();
                    if (count >= 2)
                    {
                        float step = Vector3.Distance(lastValue - offset, observer.getCachedScale(count - 2)) / interval;
                        return(Vector3.MoveTowards(now, lastValue, step));
                    }
                    return(lastValue);
                }
                else if (interOp == FduDTS_EveryNFrame.InterpolationOption.FixedStep)
                {
                    if ((interval - cur + 1) > 0)
                    {
                        var res = Vector3.Lerp(now, lastValue, 1.0f / (interval - cur + 1));
                        return(res);
                    }
                    else
                    {
                        return(lastValue);
                    }
                }
                else if (interOp == FduDTS_EveryNFrame.InterpolationOption.Lerp)
                {
                    return(Vector3.Lerp(now, lastValue, Time.deltaTime * dtsN.getLerpSpeed()));
                }
                return(lastValue);
            }
            catch (System.Exception)
            {
                return(Vector3.zero);
            }
        }