public OccludeeSphere(int id, OcclusionCulling.Sphere sphere)
    {
        OccludeeState stateById;

        this.id = id;
        if (id < 0)
        {
            stateById = null;
        }
        else
        {
            stateById = OcclusionCulling.GetStateById(id);
        }
        this.state  = stateById;
        this.sphere = sphere;
    }
    private void RegisterForCulling(OcclusionCulling.Sphere sphere, bool visible)
    {
        if (localOccludee.IsRegistered)
        {
            UnregisterFromCulling();
        }
        int num = OcclusionCulling.RegisterOccludee(sphere.position, sphere.radius, visible, 0.25f, false, base.gameObject.layer, OnVisibilityChanged);

        if (num >= 0)
        {
            localOccludee = new OccludeeSphere(num, localOccludee.sphere);
            return;
        }
        localOccludee.Invalidate();
        Debug.LogWarning("[OcclusionCulling] Occludee registration failed for " + base.name + ". Too many registered.");
    }
    public OccludeeSphere(int id)
    {
        OccludeeState stateById;

        this.id = id;
        if (id < 0)
        {
            stateById = null;
        }
        else
        {
            stateById = OcclusionCulling.GetStateById(id);
        }
        this.state  = stateById;
        this.sphere = new OcclusionCulling.Sphere(Vector3.zero, 0f);
    }
    private void RegisterForCulling(OcclusionCulling.Sphere sphere, bool visible)
    {
        if (this.localOccludee.IsRegistered)
        {
            this.UnregisterFromCulling();
        }
        ArticulatedOccludee articulatedOccludee = this;
        int num = OcclusionCulling.RegisterOccludee(sphere.position, sphere.radius, visible, 0.25f, false, base.gameObject.layer, new OcclusionCulling.OnVisibilityChanged(articulatedOccludee.OnVisibilityChanged));

        if (num >= 0)
        {
            this.localOccludee = new OccludeeSphere(num, this.localOccludee.sphere);
            return;
        }
        this.localOccludee.Invalidate();
        Debug.LogWarning(string.Concat("[OcclusionCulling] Occludee registration failed for ", base.name, ". Too many registered."));
    }
    private void RegisterForCulling(OcclusionCulling.Sphere sphere, bool visible)
    {
        if (this.localOccludee.IsRegistered)
        {
            this.UnregisterFromCulling();
        }
        int id = OcclusionCulling.RegisterOccludee(sphere.position, sphere.radius, visible, 0.25f, false, ((Component)this).get_gameObject().get_layer(), new OcclusionCulling.OnVisibilityChanged(this.OnVisibilityChanged));

        if (id >= 0)
        {
            this.localOccludee = new OccludeeSphere(id, this.localOccludee.sphere);
        }
        else
        {
            this.localOccludee.Invalidate();
            Debug.LogWarning((object)("[OcclusionCulling] Occludee registration failed for " + ((Object)this).get_name() + ". Too many registered."));
        }
    }
 public void Invalidate()
 {
     this.id     = -1;
     this.state  = null;
     this.sphere = new OcclusionCulling.Sphere();
 }
    public void UpdateCullingBounds()
    {
        Vector3 vector  = Vector3.zero;
        Vector3 vector2 = Vector3.zero;
        bool    flag    = false;
        int     num     = ((renderers != null) ? renderers.Count : 0);
        int     num2    = ((colliders != null) ? colliders.Count : 0);

        if (num > 0 && (num2 == 0 || num < num2))
        {
            for (int i = 0; i < renderers.Count; i++)
            {
                if (renderers[i].isVisible)
                {
                    Bounds  bounds = renderers[i].bounds;
                    Vector3 min    = bounds.min;
                    Vector3 max    = bounds.max;
                    if (!flag)
                    {
                        vector  = min;
                        vector2 = max;
                        flag    = true;
                        continue;
                    }
                    vector.x  = ((vector.x < min.x) ? vector.x : min.x);
                    vector.y  = ((vector.y < min.y) ? vector.y : min.y);
                    vector.z  = ((vector.z < min.z) ? vector.z : min.z);
                    vector2.x = ((vector2.x > max.x) ? vector2.x : max.x);
                    vector2.y = ((vector2.y > max.y) ? vector2.y : max.y);
                    vector2.z = ((vector2.z > max.z) ? vector2.z : max.z);
                }
            }
        }
        if (!flag && num2 > 0)
        {
            flag    = true;
            vector  = colliders[0].bounds.min;
            vector2 = colliders[0].bounds.max;
            for (int j = 1; j < colliders.Count; j++)
            {
                Bounds  bounds2 = colliders[j].bounds;
                Vector3 min2    = bounds2.min;
                Vector3 max2    = bounds2.max;
                vector.x  = ((vector.x < min2.x) ? vector.x : min2.x);
                vector.y  = ((vector.y < min2.y) ? vector.y : min2.y);
                vector.z  = ((vector.z < min2.z) ? vector.z : min2.z);
                vector2.x = ((vector2.x > max2.x) ? vector2.x : max2.x);
                vector2.y = ((vector2.y > max2.y) ? vector2.y : max2.y);
                vector2.z = ((vector2.z > max2.z) ? vector2.z : max2.z);
            }
        }
        if (!flag)
        {
            return;
        }
        Vector3 vector3  = vector2 - vector;
        Vector3 position = vector + vector3 * 0.5f;
        float   radius   = Mathf.Max(Mathf.Max(vector3.x, vector3.y), vector3.z) * 0.5f;

        OcclusionCulling.Sphere sphere = new OcclusionCulling.Sphere(position, radius);
        if (localOccludee.IsRegistered)
        {
            OcclusionCulling.UpdateDynamicOccludee(localOccludee.id, sphere.position, sphere.radius);
            localOccludee.sphere = sphere;
            return;
        }
        bool visible = true;

        if (lodGroup != null)
        {
            visible = lodGroup.enabled;
        }
        RegisterForCulling(sphere, visible);
    }
    public void UpdateCullingBounds()
    {
        Vector3 vector3  = Vector3.zero;
        Vector3 vector31 = Vector3.zero;
        bool    flag     = false;
        int     num      = (this.renderers != null ? this.renderers.Count : 0);
        int     num1     = (this.colliders != null ? this.colliders.Count : 0);

        if (num > 0 && (num1 == 0 || num < num1))
        {
            for (int i = 0; i < this.renderers.Count; i++)
            {
                if (this.renderers[i].isVisible)
                {
                    Bounds  item     = this.renderers[i].bounds;
                    Vector3 vector32 = item.min;
                    Vector3 vector33 = item.max;
                    if (flag)
                    {
                        vector3.x  = (vector3.x < vector32.x ? vector3.x : vector32.x);
                        vector3.y  = (vector3.y < vector32.y ? vector3.y : vector32.y);
                        vector3.z  = (vector3.z < vector32.z ? vector3.z : vector32.z);
                        vector31.x = (vector31.x > vector33.x ? vector31.x : vector33.x);
                        vector31.y = (vector31.y > vector33.y ? vector31.y : vector33.y);
                        vector31.z = (vector31.z > vector33.z ? vector31.z : vector33.z);
                    }
                    else
                    {
                        vector3  = vector32;
                        vector31 = vector33;
                        flag     = true;
                    }
                }
            }
        }
        if (!flag && num1 > 0)
        {
            flag = true;
            Bounds bound = this.colliders[0].bounds;
            vector3  = bound.min;
            bound    = this.colliders[0].bounds;
            vector31 = bound.max;
            for (int j = 1; j < this.colliders.Count; j++)
            {
                Bounds  item1    = this.colliders[j].bounds;
                Vector3 vector34 = item1.min;
                Vector3 vector35 = item1.max;
                vector3.x  = (vector3.x < vector34.x ? vector3.x : vector34.x);
                vector3.y  = (vector3.y < vector34.y ? vector3.y : vector34.y);
                vector3.z  = (vector3.z < vector34.z ? vector3.z : vector34.z);
                vector31.x = (vector31.x > vector35.x ? vector31.x : vector35.x);
                vector31.y = (vector31.y > vector35.y ? vector31.y : vector35.y);
                vector31.z = (vector31.z > vector35.z ? vector31.z : vector35.z);
            }
        }
        if (flag)
        {
            Vector3 vector36 = vector31 - vector3;
            Vector3 vector37 = vector3 + (vector36 * 0.5f);
            float   single   = Mathf.Max(Mathf.Max(vector36.x, vector36.y), vector36.z) * 0.5f;
            OcclusionCulling.Sphere sphere = new OcclusionCulling.Sphere(vector37, single);
            if (this.localOccludee.IsRegistered)
            {
                OcclusionCulling.UpdateDynamicOccludee(this.localOccludee.id, sphere.position, sphere.radius);
                this.localOccludee.sphere = sphere;
                return;
            }
            bool flag1 = true;
            if (this.lodGroup != null)
            {
                flag1 = this.lodGroup.enabled;
            }
            this.RegisterForCulling(sphere, flag1);
        }
    }
    public void UpdateCullingBounds()
    {
        Vector3 vector3_1 = Vector3.get_zero();
        Vector3 vector3_2 = Vector3.get_zero();
        bool    flag      = false;
        int     num1      = this.renderers != null ? this.renderers.Count : 0;
        int     num2      = this.colliders != null ? this.colliders.Count : 0;

        if (num1 > 0 && (num2 == 0 || num1 < num2))
        {
            for (int index = 0; index < this.renderers.Count; ++index)
            {
                if (this.renderers[index].get_isVisible())
                {
                    Bounds  bounds = this.renderers[index].get_bounds();
                    Vector3 min    = ((Bounds) ref bounds).get_min();
                    Vector3 max    = ((Bounds) ref bounds).get_max();
                    if (!flag)
                    {
                        vector3_1 = min;
                        vector3_2 = max;
                        flag      = true;
                    }
                    else
                    {
                        vector3_1.x = vector3_1.x < min.x ? vector3_1.x : min.x;
                        vector3_1.y = vector3_1.y < min.y ? vector3_1.y : min.y;
                        vector3_1.z = vector3_1.z < min.z ? vector3_1.z : min.z;
                        vector3_2.x = vector3_2.x > max.x ? vector3_2.x : max.x;
                        vector3_2.y = vector3_2.y > max.y ? vector3_2.y : max.y;
                        vector3_2.z = vector3_2.z > max.z ? vector3_2.z : max.z;
                    }
                }
            }
        }
        if (!flag && num2 > 0)
        {
            flag = true;
            Bounds bounds1 = this.colliders[0].get_bounds();
            vector3_1 = ((Bounds) ref bounds1).get_min();
            bounds1   = this.colliders[0].get_bounds();
            vector3_2 = ((Bounds) ref bounds1).get_max();
            for (int index = 1; index < this.colliders.Count; ++index)
            {
                Bounds  bounds2 = this.colliders[index].get_bounds();
                Vector3 min     = ((Bounds) ref bounds2).get_min();
                Vector3 max     = ((Bounds) ref bounds2).get_max();
                vector3_1.x = vector3_1.x < min.x ? vector3_1.x : min.x;
                vector3_1.y = vector3_1.y < min.y ? vector3_1.y : min.y;
                vector3_1.z = vector3_1.z < min.z ? vector3_1.z : min.z;
                vector3_2.x = vector3_2.x > max.x ? vector3_2.x : max.x;
                vector3_2.y = vector3_2.y > max.y ? vector3_2.y : max.y;
                vector3_2.z = vector3_2.z > max.z ? vector3_2.z : max.z;
            }
        }
        if (!flag)
        {
            return;
        }
        Vector3 vector3_3 = Vector3.op_Subtraction(vector3_2, vector3_1);

        OcclusionCulling.Sphere sphere = new OcclusionCulling.Sphere(Vector3.op_Addition(vector3_1, Vector3.op_Multiply(vector3_3, 0.5f)), Mathf.Max(Mathf.Max((float)vector3_3.x, (float)vector3_3.y), (float)vector3_3.z) * 0.5f);
        if (this.localOccludee.IsRegistered)
        {
            OcclusionCulling.UpdateDynamicOccludee(this.localOccludee.id, sphere.position, sphere.radius);
            this.localOccludee.sphere = sphere;
        }
        else
        {
            bool visible = true;
            if (Object.op_Inequality((Object)this.lodGroup, (Object)null))
            {
                visible = this.lodGroup.get_enabled();
            }
            this.RegisterForCulling(sphere, visible);
        }
    }
示例#10
0
 public OccludeeSphere(int id, OcclusionCulling.Sphere sphere)
 {
     this.id     = id;
     this.state  = id < 0 ? (OccludeeState)null : OcclusionCulling.GetStateById(id);
     this.sphere = sphere;
 }
示例#11
0
 public OccludeeSphere(int id)
 {
     this.id     = id;
     this.state  = id < 0 ? (OccludeeState)null : OcclusionCulling.GetStateById(id);
     this.sphere = new OcclusionCulling.Sphere(Vector3.get_zero(), 0.0f);
 }