collide method
Implementation
void collide(DBVTNode node1, DBVTNode node2) {
int stackCount = 2;
Shape s1, s2;
DBVTNode n1, n2;
bool l1, l2;
stack[0] = node1;
stack[1] = node2;
while( stackCount > 0 ){
n1 = stack[--stackCount]!;
n2 = stack[--stackCount]!;
l1 = n1.proxy != null;
l2 = n2.proxy != null;
numPairChecks++;
if( l1 && l2 ){
s1 = n1.proxy!.shape;
s2 = n2.proxy!.shape;
if ( s1 == s2 || s1.aabb.intersectTest( s2.aabb ) || !isAvailablePair( s1, s2 ) ) continue;
addPair(s1,s2);
}
else{
if ( n1.aabb.intersectTest( n2.aabb ) ) continue;
if( l2 || !l1 && (n1.aabb.surfaceArea() > n2.aabb.surfaceArea()) ){
stack[stackCount++] = n1.child1!;
stack[stackCount++] = n2;
stack[stackCount++] = n1.child2!;
stack[stackCount++] = n2;
}
else{
stack[stackCount++] = n1;
stack[stackCount++] = n2.child1!;
stack[stackCount++] = n1;
stack[stackCount++] = n2.child2!;
}
}
}
}