public void Start() { OnCorection?.Invoke(); OnDetect?.Invoke(); OnResize?.Invoke(); OnCompare?.Invoke(); pi.Save(procededImagesSavePath); }
/** * Find elements that might contact with given element * under this node. * * * Param includeSelf is true given element might be in the result, default is false * * Param upwardSearch true query will find the node that query shape complete fit in in first * place then start search downward from that node. It is recommend to leave value as true for * more accurate result. * * Param compare a function you can provide and do addition check base on result it found **/ public List<IQuadtreeAgent> FindElements(IQuadtreeAgent element, bool upwardSearch = true, bool includeSelf = false, OnCompare compare = null){ if (element == null) { #if DEBUG Debug.LogError("Can't find elements, given element is null"); #endif return null; } /** * Upward search from this node * * This will go up until the node wihch element shape complete fit in **/ if (upwardSearch) { //If this is the node element shape complete fit in CollisionResult cResult = element.GetShape().IntersectWithShape(boundary); //we found the node then start from this node if (cResult == CollisionResult.Fit) { //downward search from parent if there is parent node //the reason from parent node is that parent node's overlap element //might be contact this shape if (parentNode != null) { //from parent node we start downward search return parentNode.FindElements (element, false, includeSelf, compare); } } else {//continue search upward //If there is a parent node otherwsie this is root node and start from //here downward search if (parentNode != null) { //Continue finding upward until the node element shape can totally fit in return parentNode.FindElements (element, true, includeSelf, compare); } } } /** * Downward search from this node * * Downward search only search elements in child node include this node **/ List<IQuadtreeAgent> result = new List<IQuadtreeAgent> (); CollisionResult r = element.GetShape ().IntersectWithShape (boundary); //if not contact with element shape if (r == CollisionResult.None) return result; //search child nodes IEnumerator er = nodes.GetEnumerator(); while (er.MoveNext ()) { //downward search child result.AddRange ((er.Current as QuadtreeNode).FindElements (element, false, includeSelf, compare)); } //add this node's elements result.AddRange (elements); result.AddRange (overlapElements); if (!includeSelf) { result.Remove (element); } if (compare != null) { List<IQuadtreeAgent> filterResult = new List<IQuadtreeAgent>(); List<IQuadtreeAgent>.Enumerator qer = result.GetEnumerator (); while (qer.MoveNext ()) { if (compare (qer.Current)) filterResult.Add (qer.Current); } return filterResult; } return result; }