Ejemplo n.º 1
0
        void UpdateControlPoints()
        {
            int numPoints = (m_Waypoints == null) ? 0 : m_Waypoints.Length;

            if (numPoints > 1 &&
                (Looped != m_IsLoopedCache ||
                 m_ControlPoints1 == null || m_ControlPoints1.Length != numPoints ||
                 m_ControlPoints2 == null || m_ControlPoints2.Length != numPoints))
            {
                Vector4[] p1 = new Vector4[numPoints];
                Vector4[] p2 = new Vector4[numPoints];
                Vector4[] K  = new Vector4[numPoints];
                for (int i = 0; i < numPoints; ++i)
                {
                    K[i] = m_Waypoints[i].AsVector4;
                }
                if (Looped)
                {
                    SplineHelpers.ComputeSmoothControlPointsLooped(ref K, ref p1, ref p2);
                }
                else
                {
                    SplineHelpers.ComputeSmoothControlPoints(ref K, ref p1, ref p2);
                }

                m_ControlPoints1 = new Waypoint[numPoints];
                m_ControlPoints2 = new Waypoint[numPoints];
                for (int i = 0; i < numPoints; ++i)
                {
                    m_ControlPoints1[i] = Waypoint.FromVector4(p1[i]);
                    m_ControlPoints2[i] = Waypoint.FromVector4(p2[i]);
                }
                m_IsLoopedCache = Looped;
            }
        }
        void UpdateCachedSpline()
        {
            bool cacheIsValid = (m_CachedOrbits != null && m_CachedTension == m_SplineCurvature);

            for (int i = 0; i < 3 && cacheIsValid; ++i)
            {
                cacheIsValid = (m_CachedOrbits[i].y == m_Orbits[i].m_Height &&
                                m_CachedOrbits[i].x == m_Orbits[i].m_Radius);
            }
            if (!cacheIsValid)
            {
                float t = m_SplineCurvature;
                m_CachedKnots    = new Vector4[5];
                m_CachedCtrl1    = new Vector4[5];
                m_CachedCtrl2    = new Vector4[5];
                m_CachedKnots[1] = new Vector4(0, m_Orbits[2].m_Height, -m_Orbits[2].m_Radius, 0);
                m_CachedKnots[2] = new Vector4(0, m_Orbits[1].m_Height, -m_Orbits[1].m_Radius, 0);
                m_CachedKnots[3] = new Vector4(0, m_Orbits[0].m_Height, -m_Orbits[0].m_Radius, 0);
                m_CachedKnots[0] = Vector4.Lerp(m_CachedKnots[0], Vector4.zero, t);
                m_CachedKnots[4] = Vector4.Lerp(m_CachedKnots[3], Vector4.zero, t);
                SplineHelpers.ComputeSmoothControlPoints(
                    ref m_CachedKnots, ref m_CachedCtrl1, ref m_CachedCtrl2);
                m_CachedOrbits = new Vector2[3];
                for (int i = 0; i < 3; ++i)
                {
                    m_CachedOrbits[i] = new Vector2(m_Orbits[i].m_Radius, m_Orbits[i].m_Height);
                }
                m_CachedTension = m_SplineCurvature;
            }
        }
Ejemplo n.º 3
0
        private void UpdateCachedSpline()
        {
            bool flag = this.m_CachedOrbits != null && this.m_CachedTension == this.m_SplineCurvature;
            int  num  = 0;

            while (num < 3 && flag)
            {
                flag = (this.m_CachedOrbits[num].m_Height == this.m_Orbits[num].m_Height && this.m_CachedOrbits[num].m_Radius == this.m_Orbits[num].m_Radius);
                num++;
            }
            if (!flag)
            {
                float splineCurvature = this.m_SplineCurvature;
                this.m_CachedKnots    = new Vector4[5];
                this.m_CachedCtrl1    = new Vector4[5];
                this.m_CachedCtrl2    = new Vector4[5];
                this.m_CachedKnots[1] = new Vector4(0f, this.m_Orbits[2].m_Height, -this.m_Orbits[2].m_Radius, 0f);
                this.m_CachedKnots[2] = new Vector4(0f, this.m_Orbits[1].m_Height, -this.m_Orbits[1].m_Radius, 0f);
                this.m_CachedKnots[3] = new Vector4(0f, this.m_Orbits[0].m_Height, -this.m_Orbits[0].m_Radius, 0f);
                this.m_CachedKnots[0] = Vector4.Lerp(this.m_CachedKnots[1], Vector4.zero, splineCurvature);
                this.m_CachedKnots[4] = Vector4.Lerp(this.m_CachedKnots[3], Vector4.zero, splineCurvature);
                SplineHelpers.ComputeSmoothControlPoints(ref this.m_CachedKnots, ref this.m_CachedCtrl1, ref this.m_CachedCtrl2);
                this.m_CachedOrbits = new CinemachineFreeLook.Orbit[3];
                for (int i = 0; i < 3; i++)
                {
                    this.m_CachedOrbits[i] = this.m_Orbits[i];
                }
                this.m_CachedTension = this.m_SplineCurvature;
            }
        }
Ejemplo n.º 4
0
        void UpdateCachedSpline()
        {
            //UnityEngine.Profiling.Profiler.BeginSample("CinemachineFreeLook.UpdateCachedSpline");
            bool cacheIsValid = (m_CachedOrbits != null && m_CachedTension == m_SplineCurvature);

            for (int i = 0; i < 3 && cacheIsValid; ++i)
            {
                cacheIsValid = (m_CachedOrbits[i].m_Height == m_Orbits[i].m_Height &&
                                m_CachedOrbits[i].m_Radius == m_Orbits[i].m_Radius);
            }
            if (!cacheIsValid)
            {
                float t = m_SplineCurvature;
                m_CachedKnots    = new Vector4[5];
                m_CachedCtrl1    = new Vector4[5];
                m_CachedCtrl2    = new Vector4[5];
                m_CachedKnots[1] = new Vector4(0, m_Orbits[2].m_Height, -m_Orbits[2].m_Radius, 0);
                m_CachedKnots[2] = new Vector4(0, m_Orbits[1].m_Height, -m_Orbits[1].m_Radius, 0);
                m_CachedKnots[3] = new Vector4(0, m_Orbits[0].m_Height, -m_Orbits[0].m_Radius, 0);
                m_CachedKnots[0] = Vector4.Lerp(m_CachedKnots[1], Vector4.zero, t);
                m_CachedKnots[4] = Vector4.Lerp(m_CachedKnots[3], Vector4.zero, t);
                SplineHelpers.ComputeSmoothControlPoints(
                    ref m_CachedKnots, ref m_CachedCtrl1, ref m_CachedCtrl2);
                m_CachedOrbits = new Orbit[3];
                for (int i = 0; i < 3; ++i)
                {
                    m_CachedOrbits[i] = m_Orbits[i];
                }
                m_CachedTension = m_SplineCurvature;
            }
            //UnityEngine.Profiling.Profiler.EndSample();
        }
Ejemplo n.º 5
0
        private void UpdateControlPoints()
        {
            int num = (this.m_Waypoints == null) ? 0 : this.m_Waypoints.Length;

            if (num > 1 && (this.Looped != this.m_IsLoopedCache || this.m_ControlPoints1 == null || this.m_ControlPoints1.Length != num || this.m_ControlPoints2 == null || this.m_ControlPoints2.Length != num))
            {
                Vector4[] array  = new Vector4[num];
                Vector4[] array2 = new Vector4[num];
                Vector4[] array3 = new Vector4[num];
                for (int i = 0; i < num; i++)
                {
                    array3[i] = this.m_Waypoints[i].AsVector4;
                }
                if (this.Looped)
                {
                    SplineHelpers.ComputeSmoothControlPointsLooped(ref array3, ref array, ref array2);
                }
                else
                {
                    SplineHelpers.ComputeSmoothControlPoints(ref array3, ref array, ref array2);
                }
                this.m_ControlPoints1 = new CinemachineSmoothPath.Waypoint[num];
                this.m_ControlPoints2 = new CinemachineSmoothPath.Waypoint[num];
                for (int j = 0; j < num; j++)
                {
                    this.m_ControlPoints1[j] = CinemachineSmoothPath.Waypoint.FromVector4(array[j]);
                    this.m_ControlPoints2[j] = CinemachineSmoothPath.Waypoint.FromVector4(array2[j]);
                }
                this.m_IsLoopedCache = this.Looped;
            }
        }