public void Query(object context, cpBB bb, cpSpatialIndexQueryFunc func, object node) { if (root != null) { SubtreeQuery(root, context, bb, func, ref node); } }
public MarkContext(cpBBTree tree, Node staticRoot, cpSpatialIndexQueryFunc func, object data) { this.tree = tree; this.staticRoot = staticRoot; this.func = func; this.data = data; }
public void ReindexQuery(cpSpatialIndexQueryFunc func, object data) { if (this.root == null) { return; } foreach (var item in leaves) { item.Value.Update(this); } var staticIndex = this.staticIndex; Node staticRoot = staticIndex != null ? staticIndex.root : null; MarkContext context = new MarkContext(this, staticRoot, func, data); this.root.MarkSubtree(this, staticRoot, func); // ref context); if (staticIndex != null && staticRoot == null) { CollideStatic(staticIndex, func, data); } IncrementStamp(); }
public virtual void MarkLeafQuery(Leaf leaf, bool left, cpBBTree tree, cpSpatialIndexQueryFunc func) { if (cp.bbTreeIntersectsNode(leaf, this)) { this.A.MarkLeafQuery(leaf, left, tree, func); this.B.MarkLeafQuery(leaf, left, tree, func); } }
// Collide the objects in an index against the objects in a staticIndex using the query callback function. public void CollideStatic(cpBBTree staticIndex, cpSpatialIndexQueryFunc func, object data) { if (staticIndex != null && staticIndex.Count > 0) { Each((obj) => { // dynamicToStaticContext context = new dynamicToStaticContext(dynamicIndex->bbfunc, staticIndex, func, data); staticIndex.Query(staticIndex, new cpBB(obj.bb.l, obj.bb.b, obj.bb.r, obj.bb.t), func, data); }); } }
public void SubtreeQuery(Node subtree, object obj, cpBB bb, cpSpatialIndexQueryFunc func, ref object data) { //if(bbIntersectsBB(subtree.bb, bb)){ if (subtree.bb.Intersects(bb)) { if (subtree.isLeaf) { func(obj, subtree.obj, 0, data); } else { SubtreeQuery(subtree.A, obj, bb, func, ref data); SubtreeQuery(subtree.B, obj, bb, func, ref data); } } }
public override void MarkSubtree(cpBBTree tree, Node staticRoot, cpSpatialIndexQueryFunc func) { if (this.stamp == tree.GetStamp()) { if (staticRoot != null) { staticRoot.MarkLeafQuery(this, false, tree, func); } for (Node node = this; node.parent != null; node = node.parent) { if (node == node.parent.A) { node.parent.B.MarkLeafQuery(this, true, tree, func); } else { node.parent.A.MarkLeafQuery(this, false, tree, func); } } } else { var pair = this.pairs; while (pair != null) { if (this == pair.b.leaf) { if (func != null) { func(pair.a.leaf.obj, this.obj, pair.id, null); } pair = pair.b.next; } else { pair = pair.a.next; } } } }
public override void MarkLeafQuery(Leaf leaf, bool left, cpBBTree tree, cpSpatialIndexQueryFunc func) { if (cp.bbTreeIntersectsNode(leaf, this)) { if (left) { tree.PairInsert(leaf, this); } else { if (this.stamp < leaf.stamp) { tree.PairInsert(this, leaf); } if (func != null) { func(leaf.obj, this.obj, (ulong)leaf.stamp, null); } } } }
public virtual void MarkSubtree(cpBBTree tree, Node staticRoot, cpSpatialIndexQueryFunc func) { this.a.MarkSubtree(tree, staticRoot, func); this.b.MarkSubtree(tree, staticRoot, func); }