示例#1
0
 public void Add(aabb2 bound, object value)
 {
     if (root == null)
     {
         root = new BVHTreeNode2(bound, value);
     }
 }
示例#2
0
        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);
        }
示例#3
0
 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
                ));
 }
示例#4
0
 public static aabb3 xzy(this aabb2 aabb, vec2 z) => new aabb3(aabb.a.xzy(z.x), aabb.b.xzy(z.y));
示例#5
0
 public BVHTreeNode2(aabb2 bound, object value)
 {
     this.bound = bound;
     this.value = value;
 }
示例#6
0
 public static Rect ToRect(this aabb2 r) => new Rect(r.a.x, r.a.y, r.x, r.y);