예제 #1
0
        public static bool IsAABBInsectCircle3(Vector3 min, Vector3 max, GeoPlane plane1, Vector3 center, float r, GeoPlane plane2, ref GeoInsectPointArrayInfo insect)
        {
            float dot = Vector3.Dot(plane1.mNormal, plane2.mNormal);

            if (1 - Mathf.Abs(dot) < 1e-5f)
            {
                if (GeoPlaneUtils.IsPointOnPlane(plane2.mNormal, plane2.mD, min))
                {
                    return(IsAABBInsectCirclePlane2(min, max, center, r, plane1, ref insect)); // should use plane1
                }
                return(false);
            }
            GeoInsectPointArrayInfo tmp = new GeoInsectPointArrayInfo();
            bool isInsect = GeoPlaneUtils.IsPlaneInsectCircle(plane1.mNormal, plane1.mD, center, r, plane2, ref tmp);

            if (isInsect)
            {
                if (tmp.mHitGlobalPoint.mPointArray.Count == 1)
                {
                    Vector3 line1 = tmp.mHitGlobalPoint.mPointArray[0];
                    if (GeoAABBUtils.IsPointInAABB2Plane(min, max, plane1, ref line1))
                    {
                        insect.mIsIntersect = true;
                        insect.mHitGlobalPoint.mPointArray.Add(line1);
                        return(true);
                    }
                }
                else
                {
                    Vector3 seg1 = tmp.mHitGlobalPoint.mPointArray[0];
                    Vector3 seg2 = seg1 + tmp.mHitGlobalPoint.mPointArray[1];
                    return(GeoSegmentUtils.IsSegmentInsectAABB2Plane(seg1, seg2, min, max, plane1, ref insect));
                }
            }
            return(false);
        }
 public static bool IsTriangleInsectAABB3(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 min, Vector2 max, ref GeoInsectPointArrayInfo insect)
 {
     return(GeoAABBUtils.IsAABBInsectTriangle3(min, max, p1, p2, p3, ref insect));
 }