Пример #1
0
        public bool IsEntityVisibleInCustomOffset(BaseMonoEntity entity, float fovOffset, float nearOffset, float farOffset)
        {
            bool   flag            = false;
            float  fieldOfView     = this.cameraComponent.fieldOfView;
            float  nearClipPlane   = this.cameraComponent.nearClipPlane;
            float  farClipPlane    = this.cameraComponent.farClipPlane;
            Camera cameraComponent = this.cameraComponent;

            cameraComponent.fieldOfView += fovOffset;
            Camera camera2 = this.cameraComponent;

            camera2.nearClipPlane += nearOffset;
            Camera camera3 = this.cameraComponent;

            camera3.farClipPlane += farOffset;
            Matrix4x4 projectionMatrix = this.cameraComponent.projectionMatrix;
            Collider  component        = entity.GetComponent <Collider>();

            if ((component != null) && component.enabled)
            {
                flag = GeometryUtility.TestPlanesAABB(GeometryUtility.CalculateFrustumPlanes(projectionMatrix), component.bounds);
            }
            Vector3 vector = this.cameraComponent.WorldToViewportPoint(entity.XZPosition);

            flag = ((vector.z > 0f) && Miscs.IsFloatInRange(vector.x, 0f, 1f)) && Miscs.IsFloatInRange(vector.y, 0f, 1f);
            this.cameraComponent.fieldOfView   = fieldOfView;
            this.cameraComponent.nearClipPlane = nearClipPlane;
            this.cameraComponent.farClipPlane  = farClipPlane;
            return(flag);
        }
Пример #2
0
        public bool IsEntityVisible(BaseMonoEntity entity)
        {
            Collider component = entity.GetComponent <Collider>();

            if ((component != null) && component.enabled)
            {
                return(GeometryUtility.TestPlanesAABB(this._frustumPlanes, component.bounds));
            }
            Vector3 vector = this.cameraComponent.WorldToViewportPoint(entity.XZPosition);

            return(((vector.z > 0f) && Miscs.IsFloatInRange(vector.x, 0f, 1f)) && Miscs.IsFloatInRange(vector.y, 0f, 1f));
        }