Exemplo n.º 1
0
            public void Constructor(BroadphaseProxy obsoleteProxy)
            {
                m_obsoleteProxy = obsoleteProxy;

            }
Exemplo n.º 2
0
        private BroadphasePair internalAddPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
        {
            //どうもここはBroadphasePairを作成した上でm_overlappingPairArrayに追加しているようだ。
            //その際にダブらないような工夫をしている
            //ただ、やはりプールは使ったほうがよさそうだ……

            if (proxy0.m_uniqueId > proxy1.m_uniqueId)
                BulletGlobal.Swap(ref proxy0, ref proxy1);
            int proxyId1 = proxy0.UID;
            int proxyId2 = proxy1.UID;

            //既存の中にあるか検索
            BroadphasePair pair = internalFindPair(proxy0, proxy1);
            if (pair != null)
            {
                return pair;
            }

            //this is where we add an actual pair, so also call the 'ghost'
            if (m_ghostPairCallback != null)
                m_ghostPairCallback.addOverlappingPair(proxy0, proxy1);

            pair = BroadphasePair.Allocate(proxy0, proxy1);
            //m_overlappingPairTable.Add(new ProxyPair { proxyId1 = proxyId1, proxyId2 = proxyId2 }, pair);
            m_overlappingPairArray.Add(pair);
            pair.m_algorithm = null;
            pair.m_internalTmpValue = 0;

            return pair;
        }
Exemplo n.º 3
0
        private BroadphasePair internalFindPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
        {
            int proxyId1 = proxy0.UID;
            int proxyId2 = proxy1.UID;

            for(int i=0;i<m_overlappingPairArray.Count;i++)
            {
                var it = m_overlappingPairArray[i];
                if (it.m_pProxy0.UID == proxyId1 && it.m_pProxy1.UID == proxyId2)
                    return it;
            }
            /*ProxyPair pair = new ProxyPair { proxyId1 = proxy0.UID, proxyId2 = proxy1.UID };
            if (m_overlappingPairTable.ContainsKey(pair))
                return m_overlappingPairTable[pair];*/

            return null;
        }
Exemplo n.º 4
0
 public virtual BroadphasePair findPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
 {
     return null;
 }
Exemplo n.º 5
0
 public void cleanProxyFromPairs(BroadphaseProxy proxy, IDispatcher dispatcher)
 {
     cleanPairs.Constructor(proxy, this, dispatcher);
     processAllOverlappingPairs(cleanPairs, dispatcher);
 }
Exemplo n.º 6
0
 public abstract bool process(BroadphaseProxy proxy);
Exemplo n.º 7
0
 public void destroyProxy(BroadphaseProxy absproxy, IDispatcher dispatcher)
 {
     DbvtProxy proxy = (DbvtProxy)absproxy;
     if (proxy.stage == STAGECOUNT)
         m_sets[1].remove(proxy.leaf);
     else
         m_sets[0].remove(proxy.leaf);
     listremove(proxy, m_stageRoots[proxy.stage]);
     m_paircache.removeOverlappingPairsContainingProxy(proxy, dispatcher);
     m_needcleanup = true;
 }
Exemplo n.º 8
0
 public virtual void getAabb(BroadphaseProxy proxy, out btVector3 aabbMin, out btVector3 aabbMax)
 {
     Handle pHandle = (Handle)(proxy);
     aabbMin = pHandle.m_aabbMin;
     aabbMax = pHandle.m_aabbMax;
 }
Exemplo n.º 9
0
        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;
        }
Exemplo n.º 10
0
 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.m_uniqueId), dispatcher);
 }
Exemplo n.º 11
0
 public virtual void setAabb(BroadphaseProxy proxy,ref btVector3 aabbMin,ref btVector3 aabbMax, IDispatcher dispatcher)
 {
     Handle handle = (Handle)proxy;
     handle.m_aabbMin = aabbMin;
     handle.m_aabbMax = aabbMax;
     updateHandle((ushort)handle.m_uniqueId, aabbMin, aabbMax, dispatcher);
     if (m_raycastAccelerator != null)
         m_raycastAccelerator.setAabb(handle.m_dbvtProxy,ref aabbMin,ref aabbMax, dispatcher);
 }
Exemplo n.º 12
0
 public void removeOverlappingPairsContainingProxy(BroadphaseProxy proxy0, IDispatcher dispatcher)
 {
 }
Exemplo n.º 13
0
 public object removeOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, IDispatcher dispatcher)
 {
     return null;
 }
Exemplo n.º 14
0
 public BroadphasePair addOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
 {
     return null;
 }
Exemplo n.º 15
0
        public void removeOverlappingPairsContainingProxy(BroadphaseProxy proxy, IDispatcher dispatcher)
        {
            removeCallback.Constructor(proxy);

            processAllOverlappingPairs(removeCallback, dispatcher);
        }
Exemplo n.º 16
0
        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;
        }
Exemplo n.º 17
0
        public virtual object removeOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, IDispatcher dispatcher)
        {
            //gRemovePairs++;//使ってない?
            if (proxy0.m_uniqueId > proxy1.m_uniqueId)
            {
                BroadphaseProxy tmp = proxy0;
                proxy0 = proxy1;
                proxy1 = tmp;
                //btSwap(proxy0,proxy1);
            }
            int proxyId1 = proxy0.UID;
            int proxyId2 = proxy1.UID;

            /*if (proxyId1 > proxyId2) 
                btSwap(proxyId1, proxyId2);*/

            //int	hash = (int)(getHash((uint)(proxyId1),(uint)(proxyId2)) & (m_overlappingPairArray.Count-1));

            BroadphasePair pair = internalFindPair(proxy0, proxy1);
            if (pair == null)
            {
                return null;
            }

            cleanOverlappingPair(pair, dispatcher);

            object userData = null;//pair.m_internalInfo1;//どうも使われてない……?

            Debug.Assert(pair.m_pProxy0.UID == proxyId1);
            Debug.Assert(pair.m_pProxy1.UID == proxyId2);

            int pairIndex = m_overlappingPairArray.IndexOf(pair);
            Debug.Assert(pairIndex < m_overlappingPairArray.Count);

            // Remove the pair from the hash table.
            //単純にハッシュテーブルから削除
            //m_overlappingPairArray[pairIndex].free();
            m_overlappingPairArray.RemoveAt(pairIndex);
            pair.free();
            //m_overlappingPairTable.Remove(new ProxyPair { proxyId1 = proxyId1, proxyId2 = proxyId2 });

#if false //ハッシュテーブルからの検索と削除
	        int index = m_hashTable[hash];
	        btAssert(index != BT_NULL_PAIR);

	        int previous = BT_NULL_PAIR;
	        while (index != pairIndex)
	        {
		        previous = index;
		        index = m_next[index];
	        }

	        if (previous != BT_NULL_PAIR)
	        {
		        btAssert(m_next[previous] == pairIndex);
		        m_next[previous] = m_next[pairIndex];
	        }
	        else
	        {
		        m_hashTable[hash] = m_next[pairIndex];
	        }
#endif
            // 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.
#if false
	        int lastPairIndex = m_overlappingPairArray.size() - 1;
#endif
            if (m_ghostPairCallback != null)
                m_ghostPairCallback.removeOverlappingPair(proxy0, proxy1, dispatcher);
#if false//ハッシュテーブルの再構築作業?
	        // If the removed pair is the last pair, we are done.
	        if (lastPairIndex == pairIndex)
	        {
		        m_overlappingPairArray.pop_back();
		        return userData;
	        }

	        // Remove the last pair from the hash table.
	        const btBroadphasePair* last = &m_overlappingPairArray[lastPairIndex];
		        /* missing swap here too, Nat. */ 
	        int lastHash = static_cast<int>(getHash(static_cast<unsigned int>(last->m_pProxy0->getUid()), static_cast<unsigned int>(last->m_pProxy1->getUid())) & (m_overlappingPairArray.capacity()-1));

	        index = m_hashTable[lastHash];
	        btAssert(index != BT_NULL_PAIR);

	        previous = BT_NULL_PAIR;
	        while (index != lastPairIndex)
	        {
		        previous = index;
		        index = m_next[index];
	        }

	        if (previous != BT_NULL_PAIR)
	        {
		        btAssert(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.pop_back();
#endif
            return userData;
        }
Exemplo n.º 18
0
        public virtual BroadphasePair addOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
        {
            gAddedPairs++;

            if (!needsBroadphaseCollision(proxy0, proxy1))
                return null;

            return internalAddPair(proxy0, proxy1);
        }
Exemplo n.º 19
0
        public void setAabb(BroadphaseProxy absproxy,ref btVector3 aabbMin,ref btVector3 aabbMax, IDispatcher dispatcher)
        {
            DbvtProxy proxy = (DbvtProxy)absproxy;

            DbvtAabbMm aabb;// = DbvtAabbMm.FromMM(aabbMin, aabbMax);
            DbvtAabbMm.FromMM(ref aabbMin, ref aabbMax, out aabb);
#if DBVT_BP_PREVENTFALSEUPDATE
	        if(NotEqual(aabb,proxy->leaf->volume))
#endif
            {
                bool docollide = false;
                if (proxy.stage == STAGECOUNT)
                {/* fixed -> dynamic set	*/
                    m_sets[1].remove(proxy.leaf);
                    proxy.leaf = m_sets[0].insert(ref aabb, proxy);
                    docollide = true;
                }
                else
                {/* dynamic set				*/
                    ++m_updates_call;
                    if (Dbvt.Intersect(ref proxy.leaf.volume,ref aabb))
                    {/* Moving				*/

                        btVector3 delta = aabbMin - proxy.m_aabbMin;
                        btVector3 velocity = (((proxy.m_aabbMax - proxy.m_aabbMin) / 2) * m_prediction);
                        if (delta.X < 0) velocity.X = -velocity.X;
                        if (delta.Y < 0) velocity.Y = -velocity.Y;
                        if (delta.Z < 0) velocity.Z = -velocity.Z;
                        if (
                            m_sets[0].update(proxy.leaf, ref aabb,ref velocity, DBVT_BP_MARGIN)
                            )
                        {
                            ++m_updates_done;
                            docollide = true;
                        }
                    }
                    else
                    {/* Teleporting			*/
                        m_sets[0].update(proxy.leaf, ref aabb);
                        ++m_updates_done;
                        docollide = true;
                    }
                }
                listremove(proxy, m_stageRoots[proxy.stage]);
                proxy.m_aabbMin = aabbMin;
                proxy.m_aabbMax = aabbMax;
                proxy.stage = m_stageCurrent;
                listappend(ref proxy, ref m_stageRoots[m_stageCurrent]);
                if (docollide)
                {
                    m_needcleanup = true;
                    if (!m_deferedcollide)
                    {
                        //DbvtTreeCollider	collider(this);
                        //m_sets[1].collideTTpersistentStack(m_sets[1].m_root,proxy.leaf,collider);
                        //m_sets[0].collideTTpersistentStack(m_sets[0].m_root,proxy.leaf,collider);
                        //GC回避のために以下のように関数を変更
                        m_sets[1].collideTTpersistentStack(m_sets[1].m_root, proxy.leaf, this);
                        m_sets[0].collideTTpersistentStack(m_sets[0].m_root, proxy.leaf, this);
                    }
                }
            }
        }
Exemplo n.º 20
0
 public void Constructor(BroadphaseProxy cleanProxy, IOverlappingPairCache pairCache, IDispatcher dispatcher)
 {
     m_cleanProxy = cleanProxy;
     m_pairCache = pairCache;
     m_dispatcher = dispatcher;
 }
Exemplo n.º 21
0
 public void getAabb(BroadphaseProxy proxy, out btVector3 aabbMin, out btVector3 aabbMax)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 22
0
 public virtual void cleanProxyFromPairs(BroadphaseProxy proxy, IDispatcher dispatcher)
 {
 }