Exemplo n.º 1
0
    // Token: 0x060001BB RID: 443 RVA: 0x0001A6D8 File Offset: 0x000188D8
    private bool IsProjectionVolumeVisible(Plane[] planes, ShadowProjector projector)
    {
        float   num             = 1000000f;
        Vector3 center          = projector.GetShadowPos() + GlobalProjectorManager.GlobalProjectionDir.normalized * (num * 0.5f);
        Vector3 size            = new Vector3(Mathf.Abs(GlobalProjectorManager.GlobalProjectionDir.normalized.x), Mathf.Abs(GlobalProjectorManager.GlobalProjectionDir.normalized.y), Mathf.Abs(GlobalProjectorManager.GlobalProjectionDir.normalized.z)) * num;
        Bounds  bounds          = new Bounds(center, size);
        float   shadowWorldSize = projector.GetShadowWorldSize();

        bounds.Encapsulate(new Bounds(projector.GetShadowPos(), new Vector3(shadowWorldSize, shadowWorldSize, shadowWorldSize)));
        return(GeometryUtility.TestPlanesAABB(planes, bounds));
    }
Exemplo n.º 2
0
    // Token: 0x060001BA RID: 442 RVA: 0x0001A460 File Offset: 0x00018660
    private void CalculateShadowBounds()
    {
        Plane[] planes  = GeometryUtility.CalculateFrustumPlanes(Camera.main);
        Vector2 vector  = new Vector2(float.MaxValue, float.MinValue);
        Vector2 vector2 = new Vector2(float.MaxValue, float.MinValue);
        float   num     = 10f;
        bool    flag    = true;
        int     num2    = 0;
        int     num3    = 0;
        Bounds  bounds  = default(Bounds);
        int     i       = 0;

        while (i < this._ShadowProjectors.Count)
        {
            ShadowProjector shadowProjector = this._ShadowProjectors[i];
            GlobalProjectorManager.ProjectionCulling globalShadowCullingMode = this._GlobalShadowCullingMode;
            if (globalShadowCullingMode != GlobalProjectorManager.ProjectionCulling.ProjectorBounds)
            {
                if (globalShadowCullingMode != GlobalProjectorManager.ProjectionCulling.ProjectionVolumeBounds)
                {
                    goto IL_D1;
                }
                if (this.IsProjectionVolumeVisible(planes, shadowProjector))
                {
                    goto IL_D1;
                }
                num3++;
                shadowProjector.SetVisible(false);
            }
            else
            {
                if (GeometryUtility.TestPlanesAABB(planes, shadowProjector.GetBounds()))
                {
                    goto IL_D1;
                }
                num3++;
                shadowProjector.SetVisible(false);
            }
IL_1C1:
            i++;
            continue;
IL_D1:
            flag = false;
            shadowProjector.SetVisible(true);
            Vector2 vector3 = base.camera.WorldToViewportPoint(shadowProjector.GetShadowPos());
            if (num2 == 0)
            {
                bounds = new Bounds(shadowProjector.GetShadowPos(), Vector3.zero);
            }
            else
            {
                bounds.Encapsulate(shadowProjector.GetShadowPos());
            }
            if (vector3.x < vector.x)
            {
                vector.x = vector3.x;
            }
            if (vector3.x > vector.y)
            {
                vector.y = vector3.x;
            }
            if (vector3.y < vector2.x)
            {
                vector2.x = vector3.y;
            }
            if (vector3.y > vector2.y)
            {
                vector2.y = vector3.y;
            }
            float shadowWorldSize = shadowProjector.GetShadowWorldSize();
            if (shadowWorldSize > num)
            {
                num = shadowWorldSize;
            }
            num2++;
            goto IL_1C1;
        }
        if (flag)
        {
            return;
        }
        float   num4   = base.camera.orthographicSize * 2f;
        float   num5   = num / num4;
        Vector3 center = bounds.center;

        base.camera.transform.position = center;
        float num6 = Mathf.Max(vector[1] - vector[0] + num5 * 2f, vector2[1] - vector2[0] + num5 * 2f);

        base.camera.orthographicSize = base.camera.orthographicSize * num6;
    }