public void Add(aabb2 bound, object value) { if (root == null) { root = new BVHTreeNode2(bound, value); } }
protected BVHTreeNode2 FindNode(aabb2 bound) { Stack <BVHTreeNode2> stack = new Stack <BVHTreeNode2>(); stack.Push(root); BVHTreeNode2 lastNode = null; while (stack.Count > 0) { var node = stack.Pop(); var res = node.bound.intersect(bound); if (res == IntersectResult.None) { continue; } if (res == IntersectResult.Contain1) { lastNode = node; stack.Push(node.a); stack.Push(node.b); } } return(lastNode); }
public static Vector4 CalcST(this Vector2 v, aabb2 rect) { return(new Vector4( rect.size.x / v.x, rect.size.y / v.y, rect.a.x / v.x, rect.a.y / v.y )); }
public static aabb3 xzy(this aabb2 aabb, vec2 z) => new aabb3(aabb.a.xzy(z.x), aabb.b.xzy(z.y));
public BVHTreeNode2(aabb2 bound, object value) { this.bound = bound; this.value = value; }
public static Rect ToRect(this aabb2 r) => new Rect(r.a.x, r.a.y, r.x, r.y);