Ejemplo n.º 1
0
/*     */   public void collide(Dispatcher dispatcher)
/*     */   {
/*  96 */     this.sets[0].optimizeIncremental(1 + this.sets[0].leaves * this.dupdates / 100);
/*  97 */     this.sets[1].optimizeIncremental(1 + this.sets[1].leaves * this.fupdates / 100);
/*     */ 
/* 100 */     this.stageCurrent = ((this.stageCurrent + 1) % 2);
/* 101 */     DbvtProxy current = this.stageRoots[this.stageCurrent];
/* 102 */     if (current != null) {
/* 103 */       DbvtTreeCollider collider = new DbvtTreeCollider(this);
/*     */       do {
/* 105 */         DbvtProxy next = current.links[1];
/* 106 */         this.stageRoots[current.stage] = listremove(current, this.stageRoots[current.stage]);
/* 107 */         this.stageRoots[2] = listappend(current, this.stageRoots[2]);
/* 108 */         Dbvt.collideTT(this.sets[1].root, current.leaf, collider);
/* 109 */         this.sets[0].remove(current.leaf);
/* 110 */         current.leaf = this.sets[1].insert(current.aabb, current);
/* 111 */         current.stage = 2;
/* 112 */         current = next;
/* 113 */       }while (current != null);
/*     */     }
/*     */ 
/* 118 */     DbvtTreeCollider collider = new DbvtTreeCollider(this);
/*     */ 
/* 121 */     Dbvt.collideTT(this.sets[0].root, this.sets[1].root, collider);
/*     */ 
/* 125 */     Dbvt.collideTT(this.sets[0].root, this.sets[0].root, collider);
/*     */ 
/* 132 */     ObjectArrayList pairs = this.paircache.getOverlappingPairArray();
/* 133 */     if (pairs.size() > 0) {
/* 134 */       int i = 0; for (int ni = pairs.size(); i < ni; i++) {
/* 135 */         BroadphasePair p = (BroadphasePair)pairs.getQuick(i);
/* 136 */         DbvtProxy pa = (DbvtProxy)p.pProxy0;
/* 137 */         DbvtProxy pb = (DbvtProxy)p.pProxy1;
/* 138 */         if (!DbvtAabbMm.Intersect(pa.aabb, pb.aabb))
/*     */         {
/* 140 */           if (pa.hashCode() > pb.hashCode()) {
/* 141 */             DbvtProxy tmp = pa;
/* 142 */             pa = pb;
/* 143 */             pb = tmp;
/*     */           }
/* 145 */           this.paircache.removeOverlappingPair(pa, pb, dispatcher);
/* 146 */           ni--;
/* 147 */           i--;
/*     */         }
/*     */       }
/*     */     }
/*     */ 
/* 152 */     this.pid += 1;
/*     */   }