Beispiel #1
0
        /// <summary>Called by CinemachineCore at designated update time
        /// so the vcam can position itself and track its targets.  This implementation
        /// computes and caches the weighted blend of the tracked cameras.</summary>
        /// <param name="worldUp">Default world Up, set by the CinemachineBrain</param>
        /// <param name="deltaTime">Delta time for time-based effects (ignore if less than or equal to 0)</param>
        public override void UpdateCameraState(Vector3 worldUp, float deltaTime)
        {
            CinemachineVirtualCameraBase[] children = ChildCameras;
            LiveChild = null;
            float highestWeight = 0;
            float totalWeight   = 0;

            for (int i = 0; i < MaxCameras && i < children.Length; ++i)
            {
                CinemachineVirtualCameraBase vcam = children[i];
                if (vcam.isActiveAndEnabled)
                {
                    CinemachineCore.Instance.UpdateVirtualCamera(vcam, worldUp, deltaTime);
                    float weight = Mathf.Max(0, GetWeight(i));
                    if (weight > UnityVectorExtensions.Epsilon)
                    {
                        totalWeight += weight;
                        if (totalWeight == weight)
                        {
                            m_State = vcam.State;
                        }
                        else
                        {
                            m_State = CameraState.Lerp(m_State, vcam.State, weight / totalWeight);
                        }

                        if (weight > highestWeight)
                        {
                            highestWeight = weight;
                            LiveChild     = vcam;
                        }
                    }
                }
            }
        }
        public override void UpdateCameraState(Vector3 worldUp, float deltaTime)
        {
            CinemachineVirtualCameraBase[] childCameras = this.ChildCameras;
            this.LiveChild = null;
            float num  = 0f;
            float num2 = 0f;
            int   num3 = 0;

            while (num3 < 8 && num3 < childCameras.Length)
            {
                CinemachineVirtualCameraBase cinemachineVirtualCameraBase = childCameras[num3];
                if (cinemachineVirtualCameraBase.isActiveAndEnabled)
                {
                    float num4 = Mathf.Max(0f, this.GetWeight(num3));
                    if (num4 > 0.0001f)
                    {
                        num2 += num4;
                        if (num2 == num4)
                        {
                            this.m_State = cinemachineVirtualCameraBase.State;
                        }
                        else
                        {
                            this.m_State = CameraState.Lerp(this.m_State, cinemachineVirtualCameraBase.State, num4 / num2);
                        }
                        if (num4 > num)
                        {
                            num            = num4;
                            this.LiveChild = cinemachineVirtualCameraBase;
                        }
                    }
                }
                num3++;
            }
        }
Beispiel #3
0
        /// <summary>
        ///     Called by CinemachineCore at designated update time
        ///     so the vcam can position itself and track its targets.  This implementation
        ///     computes and caches the weighted blend of the tracked cameras.
        /// </summary>
        /// <param name="worldUp">Default world Up, set by the CinemachineBrain</param>
        /// <param name="deltaTime">Delta time for time-based effects (ignore if less than 0)</param>
        public override void UpdateCameraState(Vector3 worldUp, float deltaTime)
        {
            //UnityEngine.Profiling.Profiler.BeginSample("CinemachineMixingCamera.UpdateCameraState");
            var children = ChildCameras;

            LiveChild = null;
            float highestWeight = 0;
            float totalWeight   = 0;

            for (var i = 0; i < MaxCameras && i < children.Length; ++i)
            {
                var vcam = children[i];
                if (vcam.isActiveAndEnabled)
                {
                    var weight = Mathf.Max(0, GetWeight(i));
                    if (weight > UnityVectorExtensions.Epsilon)
                    {
                        totalWeight += weight;
                        if (totalWeight == weight)
                        {
                            m_State = vcam.State;
                        }
                        else
                        {
                            m_State = CameraState.Lerp(m_State, vcam.State, weight / totalWeight);
                        }

                        if (weight > highestWeight)
                        {
                            highestWeight = weight;
                            LiveChild     = vcam;
                        }
                    }
                }
            }

            //UnityEngine.Profiling.Profiler.EndSample();
        }
Beispiel #4
0
        /// <summary>Internal use only.  Do not call this methid.
        /// Called by CinemachineCore at designated update time
        /// so the vcam can position itself and track its targets.  This implementation
        /// computes and caches the weighted blend of the tracked cameras.</summary>
        /// <param name="worldUp">Default world Up, set by the CinemachineBrain</param>
        /// <param name="deltaTime">Delta time for time-based effects (ignore if less than 0)</param>
        public override void InternalUpdateCameraState(Vector3 worldUp, float deltaTime)
        {
            //UnityEngine.Profiling.Profiler.BeginSample("CinemachineMixingCamera.InternalUpdateCameraState");
            CinemachineVirtualCameraBase[] children = ChildCameras;
            LiveChild = null;
            float highestWeight = 0;
            float totalWeight   = 0;

            for (int i = 0; i < MaxCameras && i < children.Length; ++i)
            {
                CinemachineVirtualCameraBase vcam = children[i];
                if (vcam.isActiveAndEnabled)
                {
                    float weight = Mathf.Max(0, GetWeight(i));
                    if (weight > UnityVectorExtensions.Epsilon)
                    {
                        totalWeight += weight;
                        if (totalWeight == weight)
                        {
                            m_State = vcam.State;
                        }
                        else
                        {
                            m_State = CameraState.Lerp(m_State, vcam.State, weight / totalWeight);
                        }

                        if (weight > highestWeight)
                        {
                            highestWeight = weight;
                            LiveChild     = vcam;
                        }
                    }
                }
            }
            InvokePostPipelineStageCallback(this, CinemachineCore.Stage.Finalize, ref m_State, deltaTime);
            //UnityEngine.Profiling.Profiler.EndSample();
        }