Beispiel #1
0
 internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
 {
     float single;
     Vector2 vector2 = new Vector2();
     if (this.radius == 0f)
     {
         return false;
     }
     Plane plane = new Plane(UIHotSpot.forward, this.center);
     if (!plane.Raycast(ray, out single))
     {
         hit = new UIHotSpot.Hit();
         return false;
     }
     hit.point = ray.GetPoint(single);
     hit.normal = (!plane.GetSide(ray.origin) ? UIHotSpot.backward : UIHotSpot.forward);
     vector2.x = hit.point.x - this.center.x;
     vector2.y = hit.point.y - this.center.y;
     float single1 = vector2.x * vector2.x + vector2.y * vector2.y;
     if (single1 >= this.radius * this.radius)
     {
         return false;
     }
     hit.distance = Mathf.Sqrt(single1);
     return true;
 }
Beispiel #2
0
 internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
 {
     if (this.radius != 0f)
     {
         float   num;
         Vector2 vector;
         Plane   plane = new Plane(UIHotSpot.forward, this.center);
         if (!plane.Raycast(ray, out num))
         {
             hit = new UIHotSpot.Hit();
             return(false);
         }
         hit.point  = ray.GetPoint(num);
         hit.normal = !plane.GetSide(ray.origin) ? UIHotSpot.backward : UIHotSpot.forward;
         vector.x   = hit.point.x - this.center.x;
         vector.y   = hit.point.y - this.center.y;
         float f = (vector.x * vector.x) + (vector.y * vector.y);
         if (f < (this.radius * this.radius))
         {
             hit.distance = Mathf.Sqrt(f);
             return(true);
         }
     }
     return(false);
 }
Beispiel #3
0
    internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
    {
        float   single;
        Vector2 vector2 = new Vector2();

        if (this.size.x < 2.802597E-45f || this.size.y < 2.802597E-45f)
        {
            return(false);
        }
        hit.normal = UIHotSpot.forward;
        Plane plane = new Plane(UIHotSpot.forward, this.center);

        if (!plane.Raycast(ray, out single))
        {
            hit = new UIHotSpot.Hit();
            return(false);
        }
        hit.point = ray.GetPoint(single);
        vector2.x = (hit.point.x >= this.center.x ? hit.point.x - this.center.x : this.center.x - hit.point.x);
        vector2.y = (hit.point.y >= this.center.y ? hit.point.y - this.center.y : this.center.y - hit.point.y);
        if (vector2.x * 2f > this.size.x || vector2.y * 2f > this.size.y)
        {
            return(false);
        }
        hit.distance = Mathf.Sqrt(vector2.x * vector2.x + vector2.y * vector2.y);
        return(true);
    }
Beispiel #4
0
 internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
 {
     float single;
     Vector2 vector2 = new Vector2();
     if (this.size.x < 2.802597E-45f || this.size.y < 2.802597E-45f)
     {
         return false;
     }
     hit.normal = UIHotSpot.forward;
     Plane plane = new Plane(UIHotSpot.forward, this.center);
     if (!plane.Raycast(ray, out single))
     {
         hit = new UIHotSpot.Hit();
         return false;
     }
     hit.point = ray.GetPoint(single);
     vector2.x = (hit.point.x >= this.center.x ? hit.point.x - this.center.x : this.center.x - hit.point.x);
     vector2.y = (hit.point.y >= this.center.y ? hit.point.y - this.center.y : this.center.y - hit.point.y);
     if (vector2.x * 2f > this.size.x || vector2.y * 2f > this.size.y)
     {
         return false;
     }
     hit.distance = Mathf.Sqrt(vector2.x * vector2.x + vector2.y * vector2.y);
     return true;
 }
Beispiel #5
0
    internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
    {
        float   single;
        Vector2 vector2 = new Vector2();

        if (this.radius == 0f)
        {
            return(false);
        }
        Plane plane = new Plane(UIHotSpot.forward, this.center);

        if (!plane.Raycast(ray, out single))
        {
            hit = new UIHotSpot.Hit();
            return(false);
        }
        hit.point  = ray.GetPoint(single);
        hit.normal = (!plane.GetSide(ray.origin) ? UIHotSpot.backward : UIHotSpot.forward);
        vector2.x  = hit.point.x - this.center.x;
        vector2.y  = hit.point.y - this.center.y;
        float single1 = vector2.x * vector2.x + vector2.y * vector2.y;

        if (single1 >= this.radius * this.radius)
        {
            return(false);
        }
        hit.distance = Mathf.Sqrt(single1);
        return(true);
    }
Beispiel #6
0
    internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
    {
        float         single;
        float         single1;
        IntersectHint intersectHint = Intersect3D.RayCircleInfiniteForward(ray, this.center, this.radius, out single, out single1);

        switch (intersectHint)
        {
        case IntersectHint.Touching:
        case IntersectHint.Thru:
        case IntersectHint.Entry:
        {
            hit.distance = Mathf.Min(single, single1);
            if (hit.distance < 0f)
            {
                float single2 = Mathf.Max(single, single1);
                float single3 = single2;
                hit.distance = single2;
                if (single3 < 0f)
                {
                    return(false);
                }
            }
            hit.point  = ray.GetPoint(hit.distance);
            hit.normal = Vector3.Normalize(hit.point - this.center);
            return(true);
        }
        }
        Debug.Log(intersectHint, this);
        return(false);
    }
Beispiel #7
0
 static Hit()
 {
     UIHotSpot.Hit hit = new UIHotSpot.Hit {
         distance = float.PositiveInfinity,
         ray      = new Ray(),
         point    = new Vector3(),
         normal   = new Vector3()
     };
     invalid = hit;
 }
Beispiel #8
0
    internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
    {
        Bounds bound = new Bounds(this.center, this.size);

        if (!bound.IntersectRay(ray, out hit.distance))
        {
            return(false);
        }
        hit.point  = ray.GetPoint(hit.distance);
        hit.normal = -ray.direction;
        return(true);
    }
Beispiel #9
0
        public static bool Raycast(Ray ray, out UIHotSpot.Hit hit, float distance)
        {
            float num2;

            if (!allAny)
            {
                hit = UIHotSpot.Hit.invalid;
                return(false);
            }
            int frameCount = Time.frameCount;

            if (((lastStepFrame != frameCount) || anyRemovedRecently) || anyAddedRecently)
            {
                Step();
                anyRemovedRecently = anyAddedRecently = false;
            }
            lastStepFrame = frameCount;
            if (!validBounds)
            {
                hit = UIHotSpot.Hit.invalid;
                return(false);
            }
            if (allBounds.Contains(ray.origin))
            {
                num2 = 0f;
            }
            else
            {
                if (!allBounds.IntersectRay(ray, out num2) || (num2 > distance))
                {
                    hit = UIHotSpot.Hit.invalid;
                    return(false);
                }
                if (num2 != 0f)
                {
                    ray.origin = ray.GetPoint(num2 - 0.001f);
                    num2       = 0f;
                }
            }
            return(DoRaycast(ray, out hit, distance));
        }
Beispiel #10
0
    internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
    {
        float         num;
        float         num2;
        IntersectHint message = Intersect3D.RayCircleInfiniteForward(ray, this.center, this.radius, out num, out num2);

        switch (message)
        {
        case IntersectHint.Touching:
        case IntersectHint.Thru:
        case IntersectHint.Entry:
            hit.distance = Mathf.Min(num, num2);
            if ((hit.distance >= 0f) || ((hit.distance = Mathf.Max(num, num2)) >= 0f))
            {
                hit.point  = ray.GetPoint(hit.distance);
                hit.normal = Vector3.Normalize(hit.point - this.center);
                return(true);
            }
            return(false);
        }
        Debug.Log(message, this);
        return(false);
    }
Beispiel #11
0
 internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
 {
     if ((this.size.x >= 2.802597E-45f) && (this.size.y >= 2.802597E-45f))
     {
         float   num;
         Vector2 vector;
         hit.normal = UIHotSpot.forward;
         Plane plane = new Plane(UIHotSpot.forward, this.center);
         if (!plane.Raycast(ray, out num))
         {
             hit = new UIHotSpot.Hit();
             return(false);
         }
         hit.point = ray.GetPoint(num);
         vector.x  = (hit.point.x >= this.center.x) ? (hit.point.x - this.center.x) : (this.center.x - hit.point.x);
         vector.y  = (hit.point.y >= this.center.y) ? (hit.point.y - this.center.y) : (this.center.y - hit.point.y);
         if (((vector.x * 2f) <= this.size.x) && ((vector.y * 2f) <= this.size.y))
         {
             hit.distance = Mathf.Sqrt((vector.x * vector.x) + (vector.y * vector.y));
             return(true);
         }
     }
     return(false);
 }
Beispiel #12
0
 internal bool Internal_RaycastRef(Ray ray, ref UIHotSpot.Hit hit)
 {
     throw new NotImplementedException();
 }
Beispiel #13
0
        private static bool DoRaycast(Ray ray, out UIHotSpot.Hit hit, float dist)
        {
            float num;

            hit = UIHotSpot.Hit.invalid;
            UIHotSpot.Hit invalid  = UIHotSpot.Hit.invalid;
            bool          flag     = true;
            Vector3       origin   = ray.origin;
            int           allCount = UIHotSpot.Global.allCount;

            if (Circle.any)
            {
                for (int i = 0; i < Circle.count; i++)
                {
                    UICircleHotSpot spot = Circle.array[i];
                    if ((spot._bounds.Contains(origin) || (spot._bounds.IntersectRay(ray, out num) && (num < dist))) && ((spot.panel.InsideClippingRect(ray, lastStepFrame) && spot.RaycastRef(ray, ref invalid)) && (invalid.distance < dist)))
                    {
                        if (flag)
                        {
                            flag = false;
                        }
                        dist = invalid.distance;
                        hit  = invalid;
                        if (--allCount == 0)
                        {
                            return(true);
                        }
                    }
                    else if (--allCount == 0)
                    {
                        return(!flag);
                    }
                }
            }
            if (Rect.any)
            {
                for (int j = 0; j < Rect.count; j++)
                {
                    UIRectHotSpot spot2 = Rect.array[j];
                    if ((spot2._bounds.Contains(origin) || (spot2._bounds.IntersectRay(ray, out num) && (num < dist))) && ((spot2.panel.InsideClippingRect(ray, lastStepFrame) && spot2.RaycastRef(ray, ref invalid)) && (invalid.distance < dist)))
                    {
                        if (flag)
                        {
                            flag = false;
                        }
                        dist = invalid.distance;
                        hit  = invalid;
                        if (--allCount == 0)
                        {
                            return(true);
                        }
                    }
                    else if (--allCount == 0)
                    {
                        return(!flag);
                    }
                }
            }
            if (Convex.any)
            {
                for (int k = 0; k < Convex.count; k++)
                {
                    UIConvexHotSpot spot3 = Convex.array[k];
                    if ((spot3._bounds.Contains(origin) || (spot3._bounds.IntersectRay(ray, out num) && (num < dist))) && ((spot3.panel.InsideClippingRect(ray, lastStepFrame) && spot3.RaycastRef(ray, ref invalid)) && (invalid.distance < dist)))
                    {
                        if (flag)
                        {
                            flag = false;
                        }
                        dist = invalid.distance;
                        hit  = invalid;
                        if (--allCount == 0)
                        {
                            return(true);
                        }
                    }
                    else if (--allCount == 0)
                    {
                        return(!flag);
                    }
                }
            }
            if (Sphere.any)
            {
                for (int m = 0; m < Sphere.count; m++)
                {
                    UISphereHotSpot spot4 = Sphere.array[m];
                    if ((spot4._bounds.Contains(origin) || (spot4._bounds.IntersectRay(ray, out num) && (num < dist))) && ((spot4.panel.InsideClippingRect(ray, lastStepFrame) && spot4.RaycastRef(ray, ref invalid)) && (invalid.distance < dist)))
                    {
                        if (flag)
                        {
                            flag = false;
                        }
                        dist = invalid.distance;
                        hit  = invalid;
                        if (--allCount == 0)
                        {
                            return(true);
                        }
                    }
                    else if (--allCount == 0)
                    {
                        return(!flag);
                    }
                }
            }
            if (Box.any)
            {
                for (int n = 0; n < Box.count; n++)
                {
                    UIBoxHotSpot spot5 = Box.array[n];
                    if ((spot5._bounds.Contains(origin) || (spot5._bounds.IntersectRay(ray, out num) && (num < dist))) && ((spot5.panel.InsideClippingRect(ray, lastStepFrame) && spot5.RaycastRef(ray, ref invalid)) && (invalid.distance < dist)))
                    {
                        if (flag)
                        {
                            flag = false;
                        }
                        dist = invalid.distance;
                        hit  = invalid;
                        if (--allCount == 0)
                        {
                            return(true);
                        }
                    }
                    else if (--allCount == 0)
                    {
                        return(!flag);
                    }
                }
            }
            if (Brush.any)
            {
                for (int num8 = 0; num8 < Brush.count; num8++)
                {
                    UIBrushHotSpot spot6 = Brush.array[num8];
                    if ((spot6._bounds.Contains(origin) || (spot6._bounds.IntersectRay(ray, out num) && (num < dist))) && ((spot6.panel.InsideClippingRect(ray, lastStepFrame) && spot6.RaycastRef(ray, ref invalid)) && (invalid.distance < dist)))
                    {
                        if (flag)
                        {
                            flag = false;
                        }
                        dist = invalid.distance;
                        hit  = invalid;
                        if (--allCount == 0)
                        {
                            return(true);
                        }
                    }
                    else if (--allCount == 0)
                    {
                        return(!flag);
                    }
                }
            }
            throw new InvalidOperationException("Something is messed up. this line should never execute.");
        }