protected void GImpactVsGImpactFindPairs( ref IndexedMatrix trans0, ref IndexedMatrix trans1, GImpactShapeInterface shape0, GImpactShapeInterface shape1, PairSet pairset) { if (shape0.HasBoxSet() && shape1.HasBoxSet()) { GImpactQuantizedBvh.FindCollision(shape0.GetBoxSet(), ref trans0, shape1.GetBoxSet(), ref trans1, pairset); } else { AABB boxshape0 = new AABB(); AABB boxshape1 = new AABB(); int i = shape0.GetNumChildShapes(); while (i-- != 0) { shape0.GetChildAabb(i, ref trans0, out boxshape0.m_min, out boxshape0.m_max); int j = shape1.GetNumChildShapes(); while (j-- != 0) { shape1.GetChildAabb(i, ref trans1, out boxshape1.m_min, out boxshape1.m_max); if (boxshape1.HasCollision(ref boxshape0)) { pairset.PushPair(i, j); } } } } #if DEBUG if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugGimpactAlgo) { BulletGlobals.g_streamWriter.WriteLine("GImpactAglo::GImpactVsGImpactFindPairs [{0}]", pairset.Count); } #endif }
public static void FindQuantizedCollisionPairsRecursive( GImpactQuantizedBvh boxset0, GImpactQuantizedBvh boxset1, PairSet collision_pairs, ref BT_BOX_BOX_TRANSFORM_CACHE trans_cache_1to0, int node0, int node1, bool complete_primitive_tests) { if (QuantizedNodeCollision( boxset0, boxset1, trans_cache_1to0, node0, node1, complete_primitive_tests) == false) { return; //avoid colliding internal nodes } if (boxset0.IsLeafNode(node0)) { if (boxset1.IsLeafNode(node1)) { // collision result collision_pairs.PushPair(boxset0.GetNodeData(node0), boxset1.GetNodeData(node1)); return; } else { //collide left recursive FindQuantizedCollisionPairsRecursive( boxset0, boxset1, collision_pairs, ref trans_cache_1to0, node0, boxset1.GetLeftNode(node1), false); //collide right recursive FindQuantizedCollisionPairsRecursive( boxset0, boxset1, collision_pairs, ref trans_cache_1to0, node0, boxset1.GetRightNode(node1), false); } } else { if (boxset1.IsLeafNode(node1)) { //collide left recursive FindQuantizedCollisionPairsRecursive( boxset0, boxset1, collision_pairs, ref trans_cache_1to0, boxset0.GetLeftNode(node0), node1, false); //collide right recursive FindQuantizedCollisionPairsRecursive( boxset0, boxset1, collision_pairs, ref trans_cache_1to0, boxset0.GetRightNode(node0), node1, false); } else { //collide left0 left1 FindQuantizedCollisionPairsRecursive( boxset0, boxset1, collision_pairs, ref trans_cache_1to0, boxset0.GetLeftNode(node0), boxset1.GetLeftNode(node1), false); //collide left0 right1 FindQuantizedCollisionPairsRecursive( boxset0, boxset1, collision_pairs, ref trans_cache_1to0, boxset0.GetLeftNode(node0), boxset1.GetRightNode(node1), false); //collide right0 left1 FindQuantizedCollisionPairsRecursive( boxset0, boxset1, collision_pairs, ref trans_cache_1to0, boxset0.GetRightNode(node0), boxset1.GetLeftNode(node1), false); //collide right0 right1 FindQuantizedCollisionPairsRecursive( boxset0, boxset1, collision_pairs, ref trans_cache_1to0, boxset0.GetRightNode(node0), boxset1.GetRightNode(node1), false); } // else if node1 is not a leaf } // else if node0 is not a leaf }