void dxQuadTreeSpace::collide2(void* UserData, dxGeom* g1, dNearCallback* Callback){ dAASSERT(g1 && Callback); lock_count++; cleanGeoms(); g1->recomputeAABB(); if (g1->parent_space == this){ // The block the geom is in Block* CurrentBlock = (Block*)g1->tome; // Collide against block and its children CurrentBlock->Collide(g1, CurrentBlock->First, UserData, Callback); // Collide against parents while (true){ CurrentBlock = CurrentBlock->Parent; if (!CurrentBlock){ break; } CurrentBlock->CollideLocal(g1, UserData, Callback); } } else Blocks[0].Collide(g1, Blocks[0].First, UserData, Callback); lock_count--; }
void dxQuadTreeSpace::collide2(void* UserData, dxGeom* g2, dNearCallback* Callback){ dAASSERT(g2 && Callback); lock_count++; cleanGeoms(); g2->recomputeAABB(); if (g2->parent_space == this){ // The block the geom is in Block* CurrentBlock = (Block*)g2->tome_ex; // Collide against block and its children DataCallback dc = {UserData, Callback}; CurrentBlock->Collide(g2, CurrentBlock->mFirst, &dc, swap_callback); // Collide against parents while ((CurrentBlock = CurrentBlock->mParent)) CurrentBlock->CollideLocal(g2, UserData, Callback); } else { DataCallback dc = {UserData, Callback}; Blocks[0].Collide(g2, Blocks[0].mFirst, &dc, swap_callback); } lock_count--; }
void dxSAPSpace::collide (void *data, dNearCallback *callback) { dAASSERT (callback); lock_count++; cleanGeoms(); // by now all geoms are in GeomList, and DirtyList must be empty int geomSize = GeomList.size(); dUASSERT( geomSize == count, "geom counts messed up" ); // separate all geoms into infinite AABBs and normal AABBs TmpGeomList.setSize(0); TmpInfGeomList.setSize(0); int axis0max = SortAxes.mAxis0*2+1; for( int i = 0; i < geomSize; ++i ) { dxGeom* g =GeomList[i]; if( !GEOM_ENABLED(g) ) // skip disabled ones continue; const dReal& amax = g->aabb[axis0max]; if( amax == dInfinity ) // HACK? probably not... TmpInfGeomList.push( g ); else TmpGeomList.push( g ); } // do SAP on normal AABBs Pairs overlapBoxes; bool isok = complete_box_pruning( TmpGeomList.size(), (const dxGeom**)TmpGeomList.data(), overlapBoxes, SortAxes ); // collide overlapping udword overlapCount = overlapBoxes.GetNbPairs(); for( udword j = 0; j < overlapCount; ++j ) { const Pair* pair = overlapBoxes.GetPair(j); dxGeom* g1 = TmpGeomList[pair->id0]; dxGeom* g2 = TmpGeomList[pair->id1]; collideGeomsNoAABBs( g1, g2, data, callback ); } int infSize = TmpInfGeomList.size(); int normSize = TmpGeomList.size(); int m, n; for( m = 0; m < infSize; ++m ) { dxGeom* g1 = TmpInfGeomList[m]; // collide infinite ones for( n = m+1; n < infSize; ++n ) { dxGeom* g2 = TmpInfGeomList[n]; collideGeomsNoAABBs( g1, g2, data, callback ); } // collide infinite ones with normal ones for( n = 0; n < normSize; ++n ) { dxGeom* g2 = TmpGeomList[n]; collideGeomsNoAABBs( g1, g2, data, callback ); } } lock_count--; }
void dxQuadTreeSpace::collide(void* UserData, dNearCallback* Callback){ dAASSERT(Callback); lock_count++; cleanGeoms(); Blocks[0].Collide(UserData, Callback); lock_count--; }