// Token: 0x0600490B RID: 18699 RVA: 0x00116868 File Offset: 0x00114A68
    internal bool Internal_RaycastRef(Ray ray, ref global::UIHotSpot.Hit hit)
    {
        float         num;
        float         num2;
        IntersectHint intersectHint = Intersect3D.RayCircleInfiniteForward(ray, this.center, this.radius, ref num, ref num2);

        switch (intersectHint)
        {
        case 1:
        case 2:
        case 3:
            hit.distance = Mathf.Min(num, num2);
            if (hit.distance < 0f && (hit.distance = Mathf.Max(num, num2)) < 0f)
            {
                return(false);
            }
            hit.point  = ray.GetPoint(hit.distance);
            hit.normal = Vector3.Normalize(hit.point - this.center);
            return(true);

        default:
            Debug.Log(intersectHint, this);
            return(false);
        }
    }
예제 #2
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);
    }
예제 #3
0
        /// <summary>
        ///     Computes a geodesic on a mesh given a starting point and an initial direction.
        ///     Returns true if successfull and false if something went wrong.
        /// </summary>
        /// <param name="meshPoint">Point.</param>
        /// <param name="vector">Direction.</param>
        /// <param name="mesh">Mesh.</param>
        /// <param name="maxIter">Maximum iterations.</param>
        /// <param name="geodesic">Geodesic curves.</param>
        /// <returns>True if successful.</returns>
        public static bool StartDir(
            MeshPoint meshPoint,
            Vector3d vector,
            Mesh mesh,
            int maxIter,
            out List <Point3d> geodesic)
        {
            // Get initial face on the mesh
            var initialFace = mesh.Faces[meshPoint.FaceIndex];

            // Start iteration
            // Create variables for current iteration step
            var thisFace      = initialFace;
            var thisPoint     = new Point3d();
            var thisDirection = vector;

            var iter       = 0;
            var geodPoints = new List <Point3d>();

            do
            {
                var ray = new Ray(thisPoint, thisDirection);

                // Find intersection between ray and boundary
                Intersect3D.RayFacePerimeter(ray, thisFace, out var nextPoint, out var halfEdge);

                // Intersection method should check for correct direction using sign of dot product

                // Add point to pointlist
                geodPoints.Add(nextPoint);

                // Walk to next face
                var nextFace = halfEdge.Twin.Face;

                // Flip vector to next face
                var perpVector = Vector3d.CrossProduct(
                    thisDirection,
                    MeshGeometry.FaceNormal(thisFace));
                var nextVector = Vector3d.CrossProduct(
                    MeshGeometry.FaceNormal(nextFace),
                    perpVector);

                // Assign iteration variables to current
                thisPoint     = nextPoint;
                thisFace      = nextFace;
                thisDirection = nextVector;

                // Increase counter
                iter++;
            } while (iter < maxIter);

            // Assign outputs
            geodesic = geodPoints;
            return(true);
        }
예제 #4
0
        public void CannotIntersect_Line_Plane_Parallel()
        {
            var a     = new Point3d(.6, .6, 0);
            var b     = new Point3d(.4, .2, 0);
            var lineA = new Line(a, b);
            var plane = Plane.WorldXY;

            var status = Intersect3D.LinePlane(lineA, plane, out var actual);

            Assert.Equal(Intersect3D.LinePlaneIntersectionStatus.OnPlane, status);
            Assert.Null(actual);
        }
예제 #5
0
        public void CannotIntersect_Line_Plane_DoNotTouchAndAreParallel()
        {
            var a     = new Point3d(.4, .23, 1);
            var b     = new Point3d(.9, .23, 1);
            var lineA = new Line(a, b);
            var plane = Plane.WorldXY;

            var status = Intersect3D.LinePlane(lineA, plane, out var actual);

            Assert.Equal(Intersect3D.LinePlaneIntersectionStatus.NoIntersection, status);
            Assert.Null(actual);
        }
예제 #6
0
        public void CanIntersect_Line_Line()
        {
            var lineA = new Line(Point3d.WorldOrigin, new Point3d(1, 1, 1));
            var lineB = new Line(new Point3d(1, 0, 0), new Point3d(0, 1, 1));

            var status = Intersect3D.LineLine(lineA, lineB, out var result);

            Assert.Equal(Intersect3D.LineLineIntersectionStatus.Point, status);
            Assert.Equal(new Point3d(0.5, 0.5, 0.5), result.PointA);
            Assert.Equal(new Point3d(0.5, 0.5, 0.5), result.PointB);
            Assert.Equal(0.5, result.ParamA);
            Assert.Equal(0.5, result.ParamB);
        }
예제 #7
0
        public void CanIntersect_Line_Plane()
        {
            var expected = new Point3d(.4, .23, 0);
            var a        = new Point3d(.4, .23, 1);
            var b        = new Point3d(.4, .23, -1);
            var lineA    = new Line(a, b);
            var plane    = Plane.WorldXY;

            var status = Intersect3D.LinePlane(lineA, plane, out var actual);

            Assert.Equal(Intersect3D.LinePlaneIntersectionStatus.Point, status);
            Assert.Equal(expected, actual);
        }
예제 #8
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);
    }