Opaque structure represent extra blendable stuff and its weight. The base system ignores this data - it is intended for extension modules
Example #1
0
        public void AddCustomBlendable(CameraState.CustomBlendable b)
        {
            int num = this.FindCustomBlendable(b.m_Custom);

            if (num >= 0)
            {
                b.m_Weight += this.GetCustomBlendable(num).m_Weight;
            }
            else
            {
                num = this.NumCustomBlendables;
                this.NumCustomBlendables = num + 1;
            }
            switch (num)
            {
            case 0:
                this.mCustom0 = b;
                break;

            case 1:
                this.mCustom1 = b;
                break;

            case 2:
                this.mCustom2 = b;
                break;

            case 3:
                this.mCustom3 = b;
                break;

            default:
                if (this.m_CustomOverflow == null)
                {
                    this.m_CustomOverflow = new List <CameraState.CustomBlendable>();
                }
                this.m_CustomOverflow.Add(b);
                break;
            }
        }
Example #2
0
        public static CameraState Lerp(CameraState stateA, CameraState stateB, float t)
        {
            t = Mathf.Clamp01(t);
            float       t2     = t;
            CameraState result = default(CameraState);

            result.Lens                  = LensSettings.Lerp(stateA.Lens, stateB.Lens, t);
            result.ReferenceUp           = Vector3.Slerp(stateA.ReferenceUp, stateB.ReferenceUp, t);
            result.RawPosition           = Vector3.Lerp(stateA.RawPosition, stateB.RawPosition, t);
            result.ShotQuality           = Mathf.Lerp(stateA.ShotQuality, stateB.ShotQuality, t);
            result.PositionCorrection    = Vector3.Lerp(stateA.PositionCorrection, stateB.PositionCorrection, t);
            result.OrientationCorrection = Quaternion.Slerp(stateA.OrientationCorrection, stateB.OrientationCorrection, t);
            Vector3 vector = Vector3.zero;

            if (!stateA.HasLookAt || !stateB.HasLookAt)
            {
                result.ReferenceLookAt = CameraState.kNoPoint;
            }
            else
            {
                float fieldOfView  = stateA.Lens.FieldOfView;
                float fieldOfView2 = stateB.Lens.FieldOfView;
                if (!result.Lens.Orthographic && !Mathf.Approximately(fieldOfView, fieldOfView2))
                {
                    LensSettings lens = result.Lens;
                    lens.FieldOfView = result.InterpolateFOV(fieldOfView, fieldOfView2, Mathf.Max((stateA.ReferenceLookAt - stateA.CorrectedPosition).magnitude, stateA.Lens.NearClipPlane), Mathf.Max((stateB.ReferenceLookAt - stateB.CorrectedPosition).magnitude, stateB.Lens.NearClipPlane), t);
                    result.Lens      = lens;
                    t2 = Mathf.Abs((lens.FieldOfView - fieldOfView) / (fieldOfView2 - fieldOfView));
                }
                result.ReferenceLookAt = Vector3.Lerp(stateA.ReferenceLookAt, stateB.ReferenceLookAt, t2);
                float num = Quaternion.Angle(stateA.RawOrientation, stateB.RawOrientation);
                if (num > 0.0001f)
                {
                    vector = result.ReferenceLookAt - result.CorrectedPosition;
                }
            }
            if (vector.AlmostZero())
            {
                result.RawOrientation = UnityQuaternionExtensions.SlerpWithReferenceUp(stateA.RawOrientation, stateB.RawOrientation, t, result.ReferenceUp);
            }
            else
            {
                vector = vector.normalized;
                if ((vector - result.ReferenceUp).AlmostZero() || (vector + result.ReferenceUp).AlmostZero())
                {
                    result.RawOrientation = UnityQuaternionExtensions.SlerpWithReferenceUp(stateA.RawOrientation, stateB.RawOrientation, t, result.ReferenceUp);
                }
                else
                {
                    result.RawOrientation = Quaternion.LookRotation(vector, result.ReferenceUp);
                    Vector2 a = -stateA.RawOrientation.GetCameraRotationToTarget(stateA.ReferenceLookAt - stateA.CorrectedPosition, stateA.ReferenceUp);
                    Vector2 b = -stateB.RawOrientation.GetCameraRotationToTarget(stateB.ReferenceLookAt - stateB.CorrectedPosition, stateB.ReferenceUp);
                    result.RawOrientation = result.RawOrientation.ApplyCameraRotation(Vector2.Lerp(a, b, t2), result.ReferenceUp);
                }
            }
            for (int i = 0; i < stateA.NumCustomBlendables; i++)
            {
                CameraState.CustomBlendable customBlendable = stateA.GetCustomBlendable(i);
                customBlendable.m_Weight *= 1f - t;
                if (customBlendable.m_Weight > 0.0001f)
                {
                    result.AddCustomBlendable(customBlendable);
                }
            }
            for (int j = 0; j < stateB.NumCustomBlendables; j++)
            {
                CameraState.CustomBlendable customBlendable2 = stateB.GetCustomBlendable(j);
                customBlendable2.m_Weight *= t;
                if (customBlendable2.m_Weight > 0.0001f)
                {
                    result.AddCustomBlendable(customBlendable2);
                }
            }
            return(result);
        }