void InitRuntime(PFQuadTree root, PFQuadTree parent, PFRect rect, int depath) { this.root = root == null ? this : root; this.parent = parent; this.rect = rect; this.depath = depath; quadLinkedList.Clear(); }
public PFQuadTree(PFQuadTree root, PFQuadTree parent, PFRect rect, int depath) { this.rect = rect; this.root = root == null ? this : root; this.parent = parent; children = null; this.depath = depath; quadLinkedList = new LinkedList <PFQuadCircle>(); }
/// <summary> /// AABB于圆相交 /// </summary> /// <param name="rect">AABB</param> /// <param name="point">圆心</param> /// <param name="radius">半径</param> /// <returns></returns> public static bool RectCircleIntersect(PFRect rect, PFPoint point, int radius) { long cx = (rect.x + rect.x1) / 2; long cy = (rect.y + rect.y1) / 2; long vx = Math.Abs(point.x - cx); long vy = Math.Abs(point.y - cy); long hx = rect.x1 - cx; long hy = rect.y1 - cy; long ux = Math.Max(vx - hx, 0); long uy = Math.Max(vy - hy, 0); return(ux * ux + uy * uy <= (long)radius * (long)radius); }