public static bool IsRayInsectAABB3(Vector3 rayOrigin, Vector3 rayDirection, Vector3 min, Vector3 max, ref GeoInsectPointArrayInfo insect) { bool isInsect = GeoLineUtils.IsLineInsectAABB3(rayOrigin, rayDirection + rayOrigin, min, max, ref insect); if (isInsect) { List <Vector3> tmp = new List <Vector3>(); List <Vector3> tmp1 = insect.mHitGlobalPoint.mPointArray; for (int i = 0; i < tmp1.Count; ++i) { Vector3 v = tmp1[i]; if (GeoRayUtils.IsPointInRay3(rayOrigin, rayDirection, ref v)) { tmp.Add(v); } } if (tmp.Count > 0) { insect.mHitGlobalPoint.mPointArray = tmp; insect.mHitGlobalPoint.mPointArray.Sort((v1, v2) => { return((v1 - rayOrigin).sqrMagnitude.CompareTo((v2 - rayOrigin).sqrMagnitude)); }); } else { insect.mIsIntersect = false; } } return(insect.mIsIntersect); }
public static bool IsSegmentInsectAABB3(Vector3 seg1, Vector3 seg2, Vector3 min, Vector2 max, ref GeoInsectPointArrayInfo insect) { bool isInsect = GeoLineUtils.IsLineInsectAABB3(seg1, seg2, min, max, ref insect); if (isInsect) { List <Vector3> tmp = new List <Vector3>(); foreach (Vector3 v in insect.mHitGlobalPoint.mPointArray) { Vector3 v2 = v; if (GeoSegmentUtils.IsPointInSegment3(seg1, seg2, ref v2)) { tmp.Add(v); } } insect.mIsIntersect = false; if (tmp.Count > 0) { insect.mIsIntersect = true; insect.mHitGlobalPoint.mPointArray = tmp; } } return(insect.mIsIntersect); }
public static bool IsAABBInsectLine3(Vector3 min, Vector3 max, Vector3 line1, Vector3 line2, ref GeoInsectPointArrayInfo insect) { return(GeoLineUtils.IsLineInsectAABB3(line1, line2, min, max, ref insect)); }