public Object RemoveOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, IDispatcher dispatcher) { if (!HasDeferredRemoval()) { BroadphasePair findPair = new BroadphasePair(proxy0,proxy1); int findIndex = m_overlappingPairArray.IndexOf(findPair); if (findIndex >= 0 && findIndex < m_overlappingPairArray.Count) { OverlappingPairCacheGlobals.gOverlappingPairs--; BroadphasePair pair = m_overlappingPairArray[findIndex]; Object userData = pair.m_internalInfo1; CleanOverlappingPair(pair,dispatcher); if (m_ghostPairCallback != null) { m_ghostPairCallback.RemoveOverlappingPair(proxy0, proxy1,dispatcher); } //BroadphasePair temp = m_overlappingPairArray[findIndex]; //m_overlappingPairArray[findIndex] = m_overlappingPairArray[m_overlappingPairArray.Count-1]; //m_overlappingPairArray[m_overlappingPairArray.Count-1] = temp; m_overlappingPairArray.RemoveAt(m_overlappingPairArray.Count - 1); return userData; } } return 0; }
public override void RemoveOverlappingObjectInternal(BroadphaseProxy otherProxy, IDispatcher dispatcher, BroadphaseProxy thisProxy) { CollisionObject otherObject = (CollisionObject)otherProxy.m_clientObject; BroadphaseProxy actualThisProxy = thisProxy != null ? thisProxy : GetBroadphaseHandle(); System.Diagnostics.Debug.Assert(actualThisProxy != null); System.Diagnostics.Debug.Assert(otherObject != null); if(m_overlappingObjects.Contains(otherObject)) { m_overlappingObjects.Remove(otherObject); m_hashPairCache.RemoveOverlappingPair(actualThisProxy, otherProxy, dispatcher); } }
public virtual Object RemoveOverlappingPair(BroadphaseProxy proxy0,BroadphaseProxy proxy1,IDispatcher dispatcher) { CollisionObject colObj0 = (CollisionObject) proxy0.m_clientObject; CollisionObject colObj1 = (CollisionObject) proxy1.m_clientObject; GhostObject ghost0 = GhostObject.Upcast(colObj0); GhostObject ghost1 = GhostObject.Upcast(colObj1); if (ghost0 != null) { ghost0.RemoveOverlappingObjectInternal(proxy1, dispatcher, proxy0); } if (ghost1 != null) { ghost1.RemoveOverlappingObjectInternal(proxy0, dispatcher, proxy1); } return null; }
public virtual BroadphasePair AddOverlappingPair(BroadphaseProxy proxy0,BroadphaseProxy proxy1) { CollisionObject colObj0 = (CollisionObject) proxy0.m_clientObject; CollisionObject colObj1 = (CollisionObject) proxy1.m_clientObject; GhostObject ghost0 = GhostObject.Upcast(colObj0); GhostObject ghost1 = GhostObject.Upcast(colObj1); if (ghost0 != null) { ghost0.AddOverlappingObjectInternal(proxy1, proxy0); } if (ghost1 != null) { ghost1.AddOverlappingObjectInternal(proxy0, proxy1); } return null; }
public BroadphasePair AddOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1) { //don't add overlap with own Debug.Assert(proxy0 != proxy1); if (!NeedsBroadphaseCollision(proxy0,proxy1)) { return null; } // MAN - 2.76 - uses expand noninitializing....?? BroadphasePair pair = new BroadphasePair(proxy0,proxy1); m_overlappingPairArray.Add(pair); OverlappingPairCacheGlobals.gOverlappingPairs++; OverlappingPairCacheGlobals.gAddedPairs++; if (m_ghostPairCallback != null) { m_ghostPairCallback.AddOverlappingPair(proxy0, proxy1); } return pair; }
public override bool Process(BroadphaseProxy proxy) { ///terminate further ray tests, once the closestHitFraction reached zero if (MathUtil.FuzzyZero(m_resultCallback.m_closestHitFraction)) { return false; } CollisionObject collisionObject = (CollisionObject)proxy.m_clientObject; //only perform raycast if filterMask matches if(m_resultCallback.NeedsCollision(collisionObject.GetBroadphaseHandle())) { //RigidcollisionObject* collisionObject = ctrl.GetRigidcollisionObject(); //Vector3 collisionObjectAabbMin,collisionObjectAabbMax; //#if 0 //#ifdef RECALCULATE_AABB // Vector3 collisionObjectAabbMin,collisionObjectAabbMax; // collisionObject.getCollisionShape().getAabb(collisionObject.getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax); //#else //getBroadphase().getAabb(collisionObject.getBroadphaseHandle(),collisionObjectAabbMin,collisionObjectAabbMax); Vector3 collisionObjectAabbMin = collisionObject.GetBroadphaseHandle().m_aabbMin; Vector3 collisionObjectAabbMax = collisionObject.GetBroadphaseHandle().m_aabbMax; //#endif //#endif //float hitLambda = m_resultCallback.m_closestHitFraction; //culling already done by broadphase //if (btRayAabb(m_rayFromWorld,m_rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,m_hitNormal)) { Matrix trans = collisionObject.GetWorldTransform(); m_world.RayTestSingle(ref m_rayFromTrans,ref m_rayToTrans, collisionObject, collisionObject.GetCollisionShape(), ref trans, m_resultCallback); } } return true; }
public virtual bool Process(BroadphaseProxy proxy) { CollisionObject collisionObject = (CollisionObject)proxy.m_clientObject; if (collisionObject == m_collisionObject) { return true; } //only perform raycast if filterMask matches if(m_resultCallback.NeedsCollision(collisionObject.GetBroadphaseHandle())) { CollisionAlgorithm algorithm = m_world.GetDispatcher().FindAlgorithm(m_collisionObject,collisionObject); if (algorithm != null) { BridgedManifoldResult contactPointResult = new BridgedManifoldResult(m_collisionObject,collisionObject, m_resultCallback); //discrete collision detection query algorithm.ProcessCollision(m_collisionObject,collisionObject, m_world.GetDispatchInfo(),contactPointResult); algorithm.Cleanup(); m_world.GetDispatcher().FreeCollisionAlgorithm(algorithm); } } return true; }
public override bool Process(BroadphaseProxy proxy) { ///terminate further convex sweep tests, once the closestHitFraction reached zero if (MathUtil.FuzzyZero(m_resultCallback.m_closestHitFraction)) { return false; } CollisionObject collisionObject = (CollisionObject)proxy.m_clientObject; //only perform raycast if filterMask matches if(m_resultCallback.NeedsCollision(collisionObject.GetBroadphaseHandle())) { //RigidcollisionObject* collisionObject = ctrl.GetRigidcollisionObject(); Matrix temp = collisionObject.GetWorldTransform(); CollisionWorld.ObjectQuerySingle(m_castShape, ref m_convexFromTrans,ref m_convexToTrans, collisionObject, collisionObject.GetCollisionShape(), ref temp, m_resultCallback, m_allowedCcdPenetration); } return true; }
public override bool NeedsCollision(BroadphaseProxy proxy0) { //don't collide with itself if (proxy0.m_clientObject == m_me) return false; ///don't do CCD when the collision filters are not matching if (!base.NeedsCollision(proxy0)) return false; CollisionObject otherObj = (CollisionObject)proxy0.m_clientObject; //call needsResponse, see http://code.google.com/p/bullet/issues/detail?id=179 if (m_dispatcher.NeedsResponse(m_me, otherObj)) { ///don't do CCD when there are already contact points (touching contact/penetration) ObjectArray<PersistentManifold> manifoldArray = new ObjectArray<PersistentManifold>(); BroadphasePair collisionPair = m_pairCache.FindPair(m_me.GetBroadphaseHandle(), proxy0); if (collisionPair != null) { if (collisionPair.m_algorithm != null) { collisionPair.m_algorithm.GetAllContactManifolds(manifoldArray); int length = manifoldArray.Count; for (int i = 0; i < length; ++i) { if (manifoldArray[i].GetNumContacts() > 0) { return false; } } } } } return true; }
private BroadphasePair InternalAddPair(BroadphaseProxy proxy0,BroadphaseProxy proxy1) { if(proxy0.m_uniqueId>proxy1.m_uniqueId) { BroadphaseProxy temp = proxy0; proxy0 = proxy1; proxy1 = temp; } int proxyId1 = proxy0.GetUid(); int proxyId2 = proxy1.GetUid(); int hash = (int)(GetHash((uint)proxyId1,(uint)proxyId2) & (m_overlappingPairArray.Capacity-1)); // New hash value with new mask BroadphasePair pair = InternalFindPair(proxy0, proxy1, hash); if (pair != null) { return pair; } else { /*for(int i=0;i<m_overlappingPairArray.size();++i) { if( (m_overlappingPairArray[i].m_pProxy0==proxy0)&& (m_overlappingPairArray[i].m_pProxy1==proxy1)) { printf("Adding duplicated %u<>%u\r\n",proxyId1,proxyId2); internalFindPair(proxy0, proxy1, hash); } }*/ int count = m_overlappingPairArray.Count; int oldCapacity = m_overlappingPairArray.Capacity; // MAN - 2.76 - uses expand noninitializing....?? //void* mem = &m_overlappingPairArray.expand(); //this is where we add an actual pair, so also call the 'ghost' if (m_ghostPairCallback != null) { m_ghostPairCallback.AddOverlappingPair(proxy0, proxy1); } pair = new BroadphasePair(proxy0, proxy1); m_overlappingPairArray.Add(pair); int newCapacity = m_overlappingPairArray.Capacity; if (oldCapacity < newCapacity) { GrowTables(); //hash with new capacity hash = (int)(GetHash((uint)(proxyId1), (uint)(proxyId2)) & (m_overlappingPairArray.Capacity - 1)); } m_next[count] = m_hashTable[hash]; m_hashTable[hash] = count; return pair; } }
///this method is mainly for expert/internal use only. public virtual void AddOverlappingObjectInternal(BroadphaseProxy otherProxy, BroadphaseProxy thisProxy) { CollisionObject otherObject = (CollisionObject)otherProxy.m_clientObject; System.Diagnostics.Debug.Assert(otherObject != null); ///if this linearSearch becomes too slow (too many overlapping objects) we should add a more appropriate data structure if(!m_overlappingObjects.Contains(otherObject)) { //not found m_overlappingObjects.Add(otherObject); } }
protected SimpleBroadphaseProxy GetSimpleProxyFromProxy(BroadphaseProxy proxy) { SimpleBroadphaseProxy proxy0 = (SimpleBroadphaseProxy)(proxy); return proxy0; }
public virtual void SetAabb(BroadphaseProxy proxy, ref Vector3 aabbMin, ref Vector3 aabbMax, IDispatcher dispatcher) { MultiSapProxy multiProxy = (MultiSapProxy)proxy; multiProxy.m_aabbMin = aabbMin; multiProxy.m_aabbMax = aabbMax; MyNodeOverlapCallback myNodeCallback = new MyNodeOverlapCallback(this,multiProxy,dispatcher); if (m_optimizedAabbTree != null) { m_optimizedAabbTree.ReportAabbOverlappingNodex(myNodeCallback, ref aabbMin, ref aabbMax); } for (int i = 0; i < multiProxy.m_bridgeProxies.Count; i++) { Vector3 worldAabbMin = Vector3.Zero, worldAabbMax = Vector3.Zero; multiProxy.m_bridgeProxies[i].m_childBroadphase.GetBroadphaseAabb(ref worldAabbMin, ref worldAabbMax); bool overlapsBroadphase = AabbUtil2.TestAabbAgainstAabb2(ref worldAabbMin, ref worldAabbMax, ref multiProxy.m_aabbMin, ref multiProxy.m_aabbMax); if (!overlapsBroadphase) { //remove it now BridgeProxy bridgeProxy = multiProxy.m_bridgeProxies[i]; BroadphaseProxy childProxy = bridgeProxy.m_childProxy; bridgeProxy.m_childBroadphase.DestroyProxy(childProxy, dispatcher); //multiProxy.m_bridgeProxies.swap(i, multiProxy.m_bridgeProxies.Count - 1); //multiProxy.m_bridgeProxies.pop_back(); multiProxy.m_bridgeProxies.RemoveAt(i); } } /* if (1) { //find broadphase that contain this multiProxy int numChildBroadphases = getBroadphaseArray().size(); for (int i=0;i<numChildBroadphases;i++) { btBroadphaseInterface* childBroadphase = getBroadphaseArray()[i]; btVector3 worldAabbMin,worldAabbMax; childBroadphase->getBroadphaseAabb(worldAabbMin,worldAabbMax); bool overlapsBroadphase = TestAabbAgainstAabb2(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax); // fullyContained = fullyContained || boxIsContainedWithinBox(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax); int containingBroadphaseIndex = -1; //if already contains this for (int i=0;i<multiProxy->m_bridgeProxies.size();i++) { if (multiProxy->m_bridgeProxies[i]->m_childBroadphase == childBroadphase) { containingBroadphaseIndex = i; } alreadyInSimple = alreadyInSimple || (multiProxy->m_bridgeProxies[i]->m_childBroadphase == m_simpleBroadphase); } if (overlapsBroadphase) { if (containingBroadphaseIndex<0) { btBroadphaseProxy* childProxy = childBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher); childProxy->m_multiSapParentProxy = multiProxy; addToChildBroadphase(multiProxy,childProxy,childBroadphase); } } else { if (containingBroadphaseIndex>=0) { //remove btBridgeProxy* bridgeProxy = multiProxy->m_bridgeProxies[containingBroadphaseIndex]; btBroadphaseProxy* childProxy = bridgeProxy->m_childProxy; bridgeProxy->m_childBroadphase->destroyProxy(childProxy,dispatcher); multiProxy->m_bridgeProxies.swap( containingBroadphaseIndex,multiProxy->m_bridgeProxies.size()-1); multiProxy->m_bridgeProxies.pop_back(); } } } ///If we are in no other child broadphase, stick the proxy in the global 'simple' broadphase (brute force) ///hopefully we don't end up with many entries here (can assert/provide feedback on stats) if (0)//!multiProxy->m_bridgeProxies.size()) { ///we don't pass the userPtr but our multisap proxy. We need to patch this, before processing an actual collision ///this is needed to be able to calculate the aabb overlap btBroadphaseProxy* childProxy = m_simpleBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher); childProxy->m_multiSapParentProxy = multiProxy; addToChildBroadphase(multiProxy,childProxy,m_simpleBroadphase); } } if (!multiProxy->m_bridgeProxies.size()) { ///we don't pass the userPtr but our multisap proxy. We need to patch this, before processing an actual collision ///this is needed to be able to calculate the aabb overlap btBroadphaseProxy* childProxy = m_simpleBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher); childProxy->m_multiSapParentProxy = multiProxy; addToChildBroadphase(multiProxy,childProxy,m_simpleBroadphase); } */ //update for (int i = 0; i < multiProxy.m_bridgeProxies.Count; i++) { BridgeProxy bridgeProxyRef = multiProxy.m_bridgeProxies[i]; bridgeProxyRef.m_childBroadphase.SetAabb(bridgeProxyRef.m_childProxy, ref aabbMin, ref aabbMax, dispatcher); } }
public virtual void GetAabb(BroadphaseProxy proxy,ref Vector3 aabbMin, ref Vector3 aabbMax) { SimpleBroadphaseProxy sbp = GetSimpleProxyFromProxy(proxy); aabbMin = sbp.GetMinAABB(); aabbMax = sbp.GetMaxAABB(); }
public bool TestAabbOverlap(BroadphaseProxy proxy0,BroadphaseProxy proxy1) { return AabbOverlap((SimpleBroadphaseProxy)proxy0, (SimpleBroadphaseProxy)proxy1); }
public bool NeedsBroadphaseCollision(BroadphaseProxy proxy0,BroadphaseProxy proxy1) { if (m_overlapFilterCallback != null) { return m_overlapFilterCallback.NeedBroadphaseCollision(proxy0,proxy1); } bool collides = (proxy0.m_collisionFilterGroup & proxy1.m_collisionFilterMask) != 0; collides = collides && ((proxy1.m_collisionFilterGroup & proxy0.m_collisionFilterMask) != 0); return collides; }
public virtual void SetAabb(BroadphaseProxy proxy,ref Vector3 aabbMin,ref Vector3 aabbMax, IDispatcher dispatcher) { SimpleBroadphaseProxy sbp = GetSimpleProxyFromProxy(proxy); sbp.SetMinAABB(ref aabbMin); sbp.SetMaxAABB(ref aabbMax); }
public virtual void SetAabb(BroadphaseProxy proxy,ref Vector3 aabbMin,ref Vector3 aabbMax,IDispatcher dispatcher) { Handle handle = (Handle)proxy; handle.SetMinAABB(ref aabbMin); handle.SetMaxAABB(ref aabbMax); UpdateHandle((ushort)handle.GetUid(), ref aabbMin, ref aabbMax,dispatcher); if (m_raycastAccelerator != null) { m_raycastAccelerator.SetAabb(handle.m_dbvtProxy,ref aabbMin,ref aabbMax,dispatcher); } }
///unQuantize should be conservative: aabbMin/aabbMax should be larger then 'getAabb' result public void UnQuantize(BroadphaseProxy proxy,ref Vector3 aabbMin, ref Vector3 aabbMax ) { Handle pHandle = (Handle)proxy; ushort[] vecInMin = new ushort[3]; ushort[] vecInMax = new ushort[3]; vecInMin[0] = (ushort)m_pEdges[0,pHandle.m_minEdges[0]].m_pos ; vecInMax[0] = (ushort)(m_pEdges[0,pHandle.m_maxEdges[0]].m_pos + 1); vecInMin[1] = (ushort)m_pEdges[1,pHandle.m_minEdges[1]].m_pos; vecInMax[1] = (ushort)(m_pEdges[1,pHandle.m_maxEdges[1]].m_pos + 1); vecInMin[2] = (ushort)m_pEdges[2,pHandle.m_minEdges[2]].m_pos; vecInMax[2] = (ushort)(m_pEdges[2,pHandle.m_maxEdges[2]].m_pos + 1); aabbMin.X = (float)(vecInMin[0]) / (m_quantize.X); aabbMin.Y = (float)(vecInMin[1]) / (m_quantize.Y); aabbMin.Z = (float)(vecInMin[2]) / (m_quantize.Z); aabbMin += m_worldAabbMin; aabbMax.X = (float)(vecInMax[0]) / (m_quantize.X); aabbMax.Y = (float)(vecInMax[1]) / (m_quantize.Y); aabbMax.Z = (float)(vecInMax[2]) / (m_quantize.Z); aabbMax += m_worldAabbMax; }
public virtual bool NeedsCollision(BroadphaseProxy proxy0) { bool collides = (proxy0.m_collisionFilterGroup & m_collisionFilterMask) != 0; collides = collides && ((m_collisionFilterGroup & proxy0.m_collisionFilterMask) != 0); return collides; }
public virtual void RemoveOverlappingPairsContainingProxy(BroadphaseProxy proxy,IDispatcher dispatcher) { RemovePairCallback removeCallback = new RemovePairCallback(proxy); ProcessAllOverlappingPairs(removeCallback,dispatcher); }
public BroadphasePair FindPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1) { OverlappingPairCacheGlobals.gFindPairs++; if(proxy0.m_uniqueId>proxy1.m_uniqueId) { BroadphaseProxy temp; temp = proxy0; proxy0 = proxy1; proxy1 = temp; } int proxyId1 = proxy0.GetUid(); int proxyId2 = proxy1.GetUid(); /*if (proxyId1 > proxyId2) btSwap(proxyId1, proxyId2);*/ int hash = (int)(GetHash((uint)(proxyId1), (uint)(proxyId2)) & (m_overlappingPairArray.Capacity-1)); if (hash >= m_hashTable.Count) { return null; } int index = m_hashTable[hash]; while (index != BT_NULL_PAIR && EqualsPair(m_overlappingPairArray[index], proxyId1, proxyId2) == false) { index = m_next[index]; } if (index == BT_NULL_PAIR) { return null; } Debug.Assert(index < m_overlappingPairArray.Count); return m_overlappingPairArray[index]; }
public void CleanProxyFromPairs(BroadphaseProxy proxy,IDispatcher dispatcher) { CleanPairCallback cleanPairs = new CleanPairCallback(proxy,this,dispatcher); ProcessAllOverlappingPairs(cleanPairs,dispatcher); }
// Add a pair and return the new pair. If the pair already exists, // no new pair is created and the old one is returned. public virtual BroadphasePair AddOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1) { OverlappingPairCacheGlobals.gAddedPairs++; if (!NeedsBroadphaseCollision(proxy0,proxy1)) { return null; } return InternalAddPair(proxy0,proxy1); }
public virtual void DestroyProxy(BroadphaseProxy proxy,IDispatcher dispatcher) { Handle handle = (Handle)proxy; if (m_raycastAccelerator != null) { m_raycastAccelerator.DestroyProxy(handle.m_dbvtProxy,dispatcher); } RemoveHandle((ushort)handle.GetUid(), dispatcher); }
public virtual Object RemoveOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, IDispatcher dispatcher) { OverlappingPairCacheGlobals.gRemovePairs++; if(proxy0.m_uniqueId>proxy1.m_uniqueId) { BroadphaseProxy temp = proxy0; proxy0 = proxy1; proxy1 = temp; } int proxyId1 = proxy0.GetUid(); int proxyId2 = proxy1.GetUid(); int hash = (int)(GetHash((uint)(proxyId1),(uint)(proxyId2)) & (m_overlappingPairArray.Capacity-1)); BroadphasePair pair = InternalFindPair(proxy0, proxy1, hash); if (pair == null) { return null; } CleanOverlappingPair(pair,dispatcher); Object userData = pair.m_internalInfo1; Debug.Assert(pair.m_pProxy0.GetUid() == proxyId1); Debug.Assert(pair.m_pProxy1.GetUid() == proxyId2); int pairIndex = m_overlappingPairArray.IndexOf(pair); Debug.Assert(pairIndex < m_overlappingPairArray.Count); // Remove the pair from the hash table. int index = m_hashTable[hash]; Debug.Assert(index != BT_NULL_PAIR); int previous = BT_NULL_PAIR; while (index != pairIndex) { previous = index; index = m_next[index]; } if (previous != BT_NULL_PAIR) { Debug.Assert(m_next[previous] == pairIndex); m_next[previous] = m_next[pairIndex]; } else { m_hashTable[hash] = m_next[pairIndex]; } // We now move the last pair into spot of the // pair being removed. We need to fix the hash // table indices to support the move. int lastPairIndex = m_overlappingPairArray.Count - 1; if (m_ghostPairCallback != null) { m_ghostPairCallback.RemoveOverlappingPair(proxy0, proxy1,dispatcher); } // If the removed pair is the last pair, we are done. if (lastPairIndex == pairIndex) { m_overlappingPairArray.RemoveAt(lastPairIndex); return userData; } // Remove the last pair from the hash table. BroadphasePair last = m_overlappingPairArray[lastPairIndex]; /* missing swap here too, Nat. */ int lastHash = (int)(GetHash((uint)(last.m_pProxy0.GetUid()), (uint)(last.m_pProxy1.GetUid())) & (m_overlappingPairArray.Capacity-1)); index = m_hashTable[lastHash]; Debug.Assert(index != BT_NULL_PAIR); previous = BT_NULL_PAIR; while (index != lastPairIndex) { previous = index; index = m_next[index]; } if (previous != BT_NULL_PAIR) { Debug.Assert(m_next[previous] == lastPairIndex); m_next[previous] = m_next[lastPairIndex]; } else { m_hashTable[lastHash] = m_next[lastPairIndex]; } // Copy the last pair into the remove pair's spot. m_overlappingPairArray[pairIndex] = m_overlappingPairArray[lastPairIndex]; // Insert the last pair into the hash table m_next[pairIndex] = m_hashTable[lastHash]; m_hashTable[lastHash] = pairIndex; m_overlappingPairArray.RemoveAt(lastPairIndex); return userData; }
public virtual void GetAabb(BroadphaseProxy proxy,ref Vector3 aabbMin, ref Vector3 aabbMax ) { Handle pHandle = (Handle)proxy; aabbMin = pHandle.GetMinAABB(); aabbMax = pHandle.GetMaxAABB(); }
public BroadphasePair InternalFindPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, int hash) { BroadphasePair[] rawPairArray = m_overlappingPairArray.GetRawArray(); int proxyId1 = proxy0.GetUid(); int proxyId2 = proxy1.GetUid(); //#if 0 // wrong, 'equalsPair' use unsorted uids, copy-past devil striked again. Nat. //if (proxyId1 > proxyId2) // btSwap(proxyId1, proxyId2); //#endif int index = m_hashTable[hash]; while (index != BT_NULL_PAIR && EqualsPair(rawPairArray[index], proxyId1, proxyId2) == false) { index = m_next[index]; } if ( index == BT_NULL_PAIR ) { return null; } //btAssert(index < m_overlappingPairArray.size()); return rawPairArray[index]; }
public bool TestAabbOverlap(BroadphaseProxy proxy0, BroadphaseProxy proxy1) { Handle pHandleA = (Handle)(proxy0); Handle pHandleB = (Handle)(proxy1); //optimization 1: check the array index (memory address), instead of the m_pos for (int axis = 0; axis < 3; axis++) { if (pHandleA.m_maxEdges[axis] < pHandleB.m_minEdges[axis] || pHandleB.m_maxEdges[axis] < pHandleA.m_minEdges[axis]) { return false; } } return true; }
public virtual void DestroyProxy(BroadphaseProxy proxy,IDispatcher dispatcher) { SimpleBroadphaseProxy proxy0 = (SimpleBroadphaseProxy)(proxy); //freeHandle(proxy0); m_pairCache.RemoveOverlappingPairsContainingProxy(proxy,dispatcher); }