コード例 #1
0
        public Node insert(DbvtAabbMm box, DbvtProxy data)
        {
            Node leaf = createnode(this, null, box, data);

            insertleaf(this, leaf);
            leaves++;
            return(leaf);
        }
コード例 #2
0
        public override void destroyProxy(BroadphaseProxy absproxy, Dispatcher dispatcher)
        {
            DbvtProxy proxy = (DbvtProxy)absproxy;

            sets[proxy.stage].remove(proxy.leaf);

            stageRoots[proxy.stage] = listremove(proxy, stageRoots[proxy.stage]);
            paircache.removeOverlappingPairsContainingProxy(proxy);
        }
コード例 #3
0
 private static DbvtProxy listappend(DbvtProxy item, DbvtProxy list)
 {
     item.last = null;
     item.next = list;
     if (list != null)
     {
         list.last = item;
     }
     return(item);
 }
コード例 #4
0
        private static Node createnode(Dbvt pdbvt, Node parent, DbvtAabbMm volume, DbvtProxy data)
        {
            Node node = new Node();

            node.parent = parent;
            node.volume = volume;
            node.data   = data;
            node.height = 0;
            return(node);
        }
コード例 #5
0
        public override BroadphaseProxy createProxy(VInt3 aabbMin, VInt3 aabbMax, BroadphaseNativeType shapeType, CollisionObject collisionObject, short collisionFilterGroup, short collisionFilterMask, Dispatcher dispatcher)
        {
            DbvtProxy  proxy  = new DbvtProxy(collisionObject, collisionFilterGroup, collisionFilterMask);
            DbvtAabbMm volume = DbvtAabbMm.FromMM(aabbMin, aabbMax, new DbvtAabbMm());

            proxy.leaf              = sets[DYNAMIC_SET].insert(volume, proxy);
            proxy.stage             = DYNAMIC_SET;
            proxy.uniqueId          = UUID.GetNextUUID();
            stageRoots[DYNAMIC_SET] = listappend(proxy, stageRoots[DYNAMIC_SET]);
            return(proxy);
        }
コード例 #6
0
        public void collide(Dispatcher dispatcher)
        {
            DbvtTreeCollider collider = new DbvtTreeCollider(this);

            //collide dynamics:
            {
                Dbvt.collideTT(sets[DYNAMIC_SET].root, sets[FIXED_SET].root, dispatcher, collider);
                Dbvt.collideTT(sets[DYNAMIC_SET].root, sets[DYNAMIC_SET].root, dispatcher, collider);
            }

            //dynamic -> fixed set:
            DbvtProxy current = stageRoots[DYNAMIC_SET];

            while (current != null)
            {
                stageRoots[DYNAMIC_SET] = listremove(current, stageRoots[DYNAMIC_SET]);
                stageRoots[FIXED_SET]   = listappend(current, stageRoots[FIXED_SET]);
                DbvtAabbMm volume = current.leaf.volume;
                sets[DYNAMIC_SET].remove(current.leaf);
                current.leaf  = sets[FIXED_SET].insert(volume, current);
                current.stage = FIXED_SET;
                current       = stageRoots[DYNAMIC_SET];
            }


            // clean up:
            {
                List <BroadphasePair> pairs = paircache.getOverlappingPairArray();
                if (pairs.Count > 0)
                {
                    for (int i = 0, ni = pairs.Count; i < ni; i++)
                    {
                        BroadphasePair p  = pairs[i];
                        DbvtProxy      pa = (DbvtProxy)p.pProxy0;
                        DbvtProxy      pb = (DbvtProxy)p.pProxy1;
                        if (!DbvtAabbMm.Intersect(pa.leaf.volume, pb.leaf.volume))
                        {
                            if (pa.getUid() > pb.getUid())
                            {
                                DbvtProxy tmp = pa;
                                pa = pb;
                                pb = tmp;
                            }
                            paircache.removeOverlappingPair(pa, pb);
                            ni--;
                            i--;
                        }
                    }
                }
            }
        }
コード例 #7
0
        private static DbvtProxy listremove(DbvtProxy item, DbvtProxy list)
        {
            if (item.last != null)
            {
                item.last.next = item.next;
            }
            else
            {
                list = item.next;
            }

            if (item.next != null)
            {
                item.next.last = item.last;
            }

            item.last = item.next = null;
            return(list);
        }
コード例 #8
0
        public override void setAabb(BroadphaseProxy absproxy, VInt3 aabbMin, VInt3 aabbMax, Dispatcher dispatcher)
        {
            DbvtProxy  proxy = (DbvtProxy)absproxy;
            DbvtAabbMm aabb  = DbvtAabbMm.FromMM(aabbMin, aabbMax, new DbvtAabbMm());

            if (aabb != proxy.leaf.volume)
            {
                proxy.leaf.volume = aabb;
                if (proxy.stage == FIXED_SET)
                {
                    sets[FIXED_SET].remove(proxy.leaf);
                    stageRoots[FIXED_SET]   = listremove(proxy, stageRoots[FIXED_SET]);
                    proxy.leaf              = sets[DYNAMIC_SET].insert(aabb, proxy);
                    proxy.stage             = DYNAMIC_SET;
                    stageRoots[DYNAMIC_SET] = listappend(proxy, stageRoots[DYNAMIC_SET]);
                }
                else
                {
                    // teleporting:
                    sets[DYNAMIC_SET].update(proxy.leaf, aabb);
                }
            }
        }
コード例 #9
0
            public override void Process(Dbvt.Node n)
            {
                DbvtProxy proxy = n.data;

                rayCallback.process(proxy);
            }