public void collideTTpersistentStack(DbvtNode root0, DbvtNode root1, DbvtBroadphase pbp) { if (root0 != null && root1 != null) { //int depth=1; //int treshold=DOUBLE_STACKSIZE-4; //中身はただのPush-Pop動作なので、それに置き換え m_stkStack.Clear(); //m_stkStack.AddRange(DOUBLE_STACKSIZE); m_stkStack.Add(new sStkNN(root0, root1)); do { //sStkNN p=m_stkStack[--depth]; sStkNN p = m_stkStack[m_stkStack.Count - 1]; /* if(depth>treshold) { m_stkStack.resize(m_stkStack.size()*2); treshold=m_stkStack.size()-4; }*/ if (p.a == p.b) { if (p.a.isinternal()) { /*m_stkStack[depth++]=sStkNN(p.a->childs[0],p.a->childs[0]); m_stkStack[depth++]=sStkNN(p.a->childs[1],p.a->childs[1]); m_stkStack[depth++]=sStkNN(p.a->childs[0],p.a->childs[1]); */ m_stkStack.Add(new sStkNN(p.a.childs[0], p.a.childs[0])); m_stkStack.Add(new sStkNN(p.a.childs[1], p.a.childs[1])); m_stkStack.Add(new sStkNN(p.a.childs[0], p.a.childs[1])); } } else if (Intersect(ref p.a.volume,ref p.b.volume)) { if (p.a.isinternal()) { if (p.b.isinternal()) { /*m_stkStack[depth++]=sStkNN(p.a->childs[0],p.b->childs[0]); m_stkStack[depth++]=sStkNN(p.a->childs[1],p.b->childs[0]); m_stkStack[depth++]=sStkNN(p.a->childs[0],p.b->childs[1]); m_stkStack[depth++]=sStkNN(p.a->childs[1],p.b->childs[1]); */ m_stkStack.Add(new sStkNN(p.a.childs[0], p.b.childs[0])); m_stkStack.Add(new sStkNN(p.a.childs[1], p.b.childs[0])); m_stkStack.Add(new sStkNN(p.a.childs[0], p.b.childs[1])); m_stkStack.Add(new sStkNN(p.a.childs[1], p.b.childs[1])); } else { /*m_stkStack[depth++]=sStkNN(p.a->childs[0],p.b); m_stkStack[depth++]=sStkNN(p.a->childs[1],p.b); */ m_stkStack.Add(new sStkNN(p.a.childs[0], p.b)); m_stkStack.Add(new sStkNN(p.a.childs[1], p.b)); } } else { if (p.b.isinternal()) { /*m_stkStack[depth++] = sStkNN(p.a, p.b->childs[0]); m_stkStack[depth++] = sStkNN(p.a, p.b->childs[1]); m_stkStack[depth++] = sStkNN(p.a, p.b->childs[0]); m_stkStack[depth++] = sStkNN(p.a, p.b->childs[1]); */ m_stkStack.Add(new sStkNN(p.a, p.b.childs[0])); m_stkStack.Add(new sStkNN(p.a, p.b.childs[1])); m_stkStack.Add(new sStkNN(p.a, p.b.childs[0])); m_stkStack.Add(new sStkNN(p.a, p.b.childs[1])); } else { //policy.Process(p.a,p.b); DbvtTreeCollider.Process(pbp, p.a, p.b);//stackにclassをnewできないので回避処理…… } } } } while (m_stkStack.Count > 0); } }
public void Constructor(btVector3 worldAabbMin, btVector3 worldAabbMax, UInt16 handleMask, UInt16 handleSentinel, UInt16 userMaxHandles, IOverlappingPairCache pairCache, bool disableRaycastAccelerator) { m_bpHandleMask = handleMask; m_handleSentinel = handleSentinel; m_pairCache = pairCache; m_userPairCallback = null; //m_ownsPairCache=false; m_invalidPair = 0; m_raycastAccelerator = null; UInt16 maxHandles = (ushort)(userMaxHandles + 1);//need to add one sentinel handle if (m_pairCache == null) { m_pairCache = new HashedOverlappingPairCache(); //m_ownsPairCache = true; } if (!disableRaycastAccelerator) { m_nullPairCache = new NullPairCache(); m_raycastAccelerator = new DbvtBroadphase(m_nullPairCache);//m_pairCache); m_raycastAccelerator.m_deferedcollide = true;//don't add/remove pairs } // init bounds m_worldAabbMin = worldAabbMin; m_worldAabbMax = worldAabbMax; btVector3 aabbSize = m_worldAabbMax - m_worldAabbMin; UInt16 maxInt = m_handleSentinel; m_quantize = new btVector3(maxInt, maxInt, maxInt) / aabbSize; // allocate handles buffer, using btAlignedAlloc, and put all handles on free list m_pHandles = new Handle[maxHandles]; for (int i = 0; i < maxHandles; i++) m_pHandles[i] = new Handle(); //m_maxHandles = maxHandles; m_numHandles = 0; // handle 0 is reserved as the null index, and is also used as the sentinel m_firstFreeHandle = 1; { for (UInt16 i = m_firstFreeHandle; i < m_pHandles.Length; i++) m_pHandles[i].SetNextFree((ushort)(i + 1)); m_pHandles[m_pHandles.Length - 1].SetNextFree(0); } { // allocate edge buffers for (int i = 0; i < 3; i++) { m_pEdges[i] = new Edge[maxHandles * 2]; } } //removed overlap management // make boundary sentinels m_pHandles[0].m_clientObject = null; for (int axis = 0; axis < 3; axis++) { m_pHandles[0].m_minEdges[axis] = 0; m_pHandles[0].m_maxEdges[axis] = 1; m_pEdges[axis][0].m_pos = 0; m_pEdges[axis][0].m_handle = 0; m_pEdges[axis][1].m_pos = m_handleSentinel; m_pEdges[axis][1].m_handle = 0; #if DEBUG_BROADPHASE debugPrintAxis(axis); #endif //DEBUG_BROADPHASE } }