Esempio n. 1
0
        /// <summary>
        /// Forces the recalculation of static shadows.
        /// </summary>
        public void UpdateStaticShadows()
        {
            ShadowMeshManagerMapEnumerator meshManagersEnumerator = new ShadowMeshManagerMapEnumerator(_meshManagers);

            while (meshManagersEnumerator.MoveNext())
            {
                ShadowMeshManager meshManager = meshManagersEnumerator.CurrentValue;
                if (meshManager.IsStatic)
                {
                    meshManager.ForceStaticRecalculate();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Renders the shadows to a camera
        /// </summary>
        /// <param name="camera">
        /// The camera to render shadows on.
        /// </param>
        private void Render(Camera camera)
        {
            // Calculate the camera frustum planes
            int cameraCullingMask;

            if (camera != null)
            {
#if SUPPORTS_REFLECTION
                GeometryUtilityInternal.CalculateFrustumPlanes(_cameraFrustumPlanes, camera);
#else
                _cameraFrustumPlanes = GeometryUtility.CalculateFrustumPlanes(camera);
#endif
                cameraCullingMask = camera.cullingMask;
            }
            else
            {
                cameraCullingMask = unchecked (~0);
            }

            _isRecalculatingMesh = true;

            // Clearing list of managers added on previous recalculations
            _meshManagersNew.Clear();

            // Loop known mesh managers, we don't care if new items will be added inside the loop
            ShadowMeshManagerMapEnumerator meshManagersEnumerator = new ShadowMeshManagerMapEnumerator(_meshManagers);
            while (meshManagersEnumerator.MoveNext())
            {
                ShadowMeshManager meshManager = meshManagersEnumerator.CurrentValue;
                UpdateAndDrawMeshManager(meshManager, camera, cameraCullingMask);
            }

            _isRecalculatingMesh = false;

            // Calculate & draw the newly added managers (if AutoStatic is used)
            // and add them to the actual list
            ShadowMeshManagerMapEnumerator meshManagersNewEnumerator = new ShadowMeshManagerMapEnumerator(_meshManagersNew);
            while (meshManagersNewEnumerator.MoveNext())
            {
                ShadowMeshManager meshManager = meshManagersNewEnumerator.CurrentValue;
                UpdateAndDrawMeshManager(meshManager, camera, cameraCullingMask);

                _meshManagers.Add(meshManager.GetInstanceHashCode(), meshManager);
            }
        }
Esempio n. 3
0
        private void OnLevelWasLoaded(int level)
        {
            UpdateCameraEvents();

            // Remove empty mesh managers
            ExposedList <ShadowMeshManager> emptyShadowMeshManagers = new ExposedList <ShadowMeshManager>();
            ShadowMeshManagerMapEnumerator  meshManagersEnumerator  = new ShadowMeshManagerMapEnumerator(_meshManagers);

            while (meshManagersEnumerator.MoveNext())
            {
                ShadowMeshManager meshManager = meshManagersEnumerator.CurrentValue;
                if (meshManager.ShadowsCount == 0)
                {
                    emptyShadowMeshManagers.Add(meshManager);
                }
            }

            for (int i = 0; i < emptyShadowMeshManagers.Count; i++)
            {
                _meshManagers.Remove(emptyShadowMeshManagers.Items[i].GetInstanceHashCode());
            }
        }