コード例 #1
0
 public virtual BroadphasePair FindPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
 {
     return(null);
 }
コード例 #2
0
 public bool     IsSoftBody()
 {
     return(BroadphaseProxy.IsSoftBody(GetShapeType()));
 }
コード例 #3
0
        ///this method is mainly for expert/internal use only.
        public override void AddOverlappingObjectInternal(BroadphaseProxy otherProxy, BroadphaseProxy thisProxy)
        {
            BroadphaseProxy actualThisProxy = thisProxy != null ? thisProxy : GetBroadphaseHandle();

            Debug.Assert(actualThisProxy != null);

            CollisionObject otherObject = otherProxy.m_clientObject as CollisionObject;

            Debug.Assert(otherObject != null);
            if (!m_overlappingObjects.Contains(otherObject))
            {
                m_overlappingObjects.Add(otherObject);
                m_hashPairCache.AddOverlappingPair(actualThisProxy, otherProxy);
            }
        }
コード例 #4
0
 public bool     IsPolyhedral()
 {
     return(BroadphaseProxy.IsPolyhedral(GetShapeType()));
 }
コード例 #5
0
 public bool     IsConcave()
 {
     return(BroadphaseProxy.IsConcave(GetShapeType()));
 }
コード例 #6
0
 public virtual void RemoveOverlappingPairsContainingProxy(BroadphaseProxy proxy0, IDispatcher dispatcher)
 {
 }
コード例 #7
0
 public RemovePairCallback(BroadphaseProxy obsoleteProxy)
 {
     m_obsoleteProxy = obsoleteProxy;
 }
コード例 #8
0
        public virtual void SetAabb(BroadphaseProxy absproxy, ref IndexedVector3 aabbMin, ref IndexedVector3 aabbMax, IDispatcher dispatcher)
        {
            DbvtProxy  proxy = absproxy as DbvtProxy;
            DbvtAabbMm aabb  = DbvtAabbMm.FromMM(ref aabbMin, ref aabbMax);

#if DBVT_BP_PREVENTFALSEUPDATE
            if (NotEqual(ref 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 (DbvtAabbMm.Intersect(ref proxy.leaf.volume, ref aabb))
                    {/* Moving				*/
                        IndexedVector3 delta    = aabbMin - proxy.m_aabbMin;
                        IndexedVector3 velocity = (((proxy.m_aabbMax - proxy.m_aabbMin) / 2f) * 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 (
#if DBVT_BP_MARGIN
                            m_sets[0].Update(proxy.leaf, ref aabb, ref velocity, DBVT_BP_MARGIN)
#else
                            m_sets[0].update(proxy.leaf, aabb, ref velocity)
#endif
                            )
                        {
                            ++m_updates_done;
                            docollide = true;
                        }
                    }
                    else
                    {/* Teleporting			*/
                        m_sets[0].Update(proxy.leaf, ref aabb);
                        ++m_updates_done;
                        docollide = true;
                    }
                }
                ListRemove(proxy, ref m_stageRoots[proxy.stage]);
                proxy.m_aabbMin = aabbMin;
                proxy.m_aabbMax = aabbMax;
                proxy.stage     = m_stageCurrent;
                ListAppend(proxy, ref m_stageRoots[m_stageCurrent]);
                if (docollide)
                {
                    m_needcleanup = true;
                    if (!m_deferedcollide)
                    {
                        DbvtTreeCollider collider = BulletGlobals.DbvtTreeColliderPool.Get();
                        collider.Initialize(this);
                        Dbvt.CollideTTpersistentStack(m_sets[1].m_root, proxy.leaf, collider);
                        Dbvt.CollideTTpersistentStack(m_sets[0].m_root, proxy.leaf, collider);
                        BulletGlobals.DbvtTreeColliderPool.Free(collider);
                    }
                }
            }
        }
コード例 #9
0
 public virtual void DestroyProxy(BroadphaseProxy proxy, IDispatcher dispatcher)
 {
     ///not yet
     Debug.Assert(false);
 }
コード例 #10
0
 public bool TestAabbOverlap(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
 {
     return(AabbOverlap((SimpleBroadphaseProxy)proxy0, (SimpleBroadphaseProxy)proxy1));
 }
コード例 #11
0
 public SimpleBroadphaseProxy GetSimpleProxyFromProxy(BroadphaseProxy proxy)
 {
     return(proxy as SimpleBroadphaseProxy);
 }
コード例 #12
0
 public abstract bool Process(BroadphaseProxy proxy);
コード例 #13
0
 public virtual void RemoveOverlappingPairsContainingProxy(BroadphaseProxy proxy0, IDispatcher dispatcher)
 {
     Debug.Assert(false);
     //need to keep track of all ghost objects and call them here
     //m_hashPairCache->removeOverlappingPairsContainingProxy(proxy0,dispatcher);
 }
コード例 #14
0
        public override void RemoveOverlappingObjectInternal(BroadphaseProxy otherProxy, IDispatcher dispatcher, BroadphaseProxy thisProxy)
        {
            CollisionObject otherObject     = otherProxy.m_clientObject as CollisionObject;
            BroadphaseProxy actualThisProxy = thisProxy != null ? thisProxy : GetBroadphaseHandle();

            Debug.Assert(actualThisProxy != null);

            Debug.Assert(otherObject != null);
            if (m_overlappingObjects.Remove(otherObject))
            {
                m_hashPairCache.RemoveOverlappingPair(actualThisProxy, otherProxy, dispatcher);
            }
        }
コード例 #15
0
 public virtual BroadphasePair AddOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1)
 {
     return(null);
 }
コード例 #16
0
        public virtual void SetAabb(BroadphaseProxy proxy, ref IndexedVector3 aabbMin, ref IndexedVector3 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++)
            {
                IndexedVector3 worldAabbMin;
                IndexedVector3 worldAabbMax;
                multiProxy.m_bridgeProxies[i].m_childBroadphase.GetBroadphaseAabb(out worldAabbMin, out 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.RemoveAtQuick(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);
            }
        }
コード例 #17
0
 public virtual Object RemoveOverlappingPair(BroadphaseProxy proxy0, BroadphaseProxy proxy1, IDispatcher dispatcher)
 {
     return(null);
 }
コード例 #18
0
 public void SetBroadphaseHandle(BroadphaseProxy handle)
 {
     m_broadphaseHandle = handle;
 }
コード例 #19
0
 public CleanPairCallback(BroadphaseProxy cleanProxy, IOverlappingPairCache pairCache, IDispatcher dispatcher)
 {
     m_cleanProxy = cleanProxy;
     m_pairCache  = pairCache;
     m_dispatcher = dispatcher;
 }
コード例 #20
0
        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);
            // we've already found this.
            int pairIndex = pair.m_index;

            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);

#if DEBUG
            if (BulletGlobals.g_streamWriter != null && BulletGlobals.debugPairCache)
            {
                BulletGlobals.g_streamWriter.WriteLine("HPC:RemoveOverlappingPair endSize[{0}].", m_overlappingPairArray.Count);
            }
#endif
            return(userData);
        }
コード例 #21
0
        public virtual void RemoveOverlappingPairsContainingProxy(BroadphaseProxy proxy, IDispatcher dispatcher)
        {
            RemovePairCallback removeCallback = new RemovePairCallback(proxy);

            ProcessAllOverlappingPairs(removeCallback, dispatcher);
        }
コード例 #22
0
        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);
            }
        }
コード例 #23
0
 public bool     IsNonMoving()
 {
     return(BroadphaseProxy.IsNonMoving(GetShapeType()));
 }
コード例 #24
0
        public void CleanProxyFromPairs(BroadphaseProxy proxy, IDispatcher dispatcher)
        {
            CleanPairCallback cleanPairs = new CleanPairCallback(proxy, this, dispatcher);

            ProcessAllOverlappingPairs(cleanPairs, dispatcher);
        }
コード例 #25
0
 public bool IsCompound()
 {
     return(BroadphaseProxy.IsCompound(GetShapeType()));
 }
コード例 #26
0
 public virtual void CleanProxyFromPairs(BroadphaseProxy proxy, IDispatcher dispatcher)
 {
 }
コード例 #27
0
 ///isInfinite is used to catch simulation error (aabb check)
 public bool IsInfinite()
 {
     return(BroadphaseProxy.IsInfinite(GetShapeType()));
 }
コード例 #28
0
        ///this method is mainly for expert/internal use only.
        public virtual void RemoveOverlappingObjectInternal(BroadphaseProxy otherProxy, IDispatcher dispatcher, BroadphaseProxy thisProxy)
        {
            CollisionObject otherObject = otherProxy.m_clientObject as CollisionObject;

            Debug.Assert(otherObject != null);
            ///if this linearSearch becomes too slow (too many overlapping objects) we should add a more appropriate data structure
            {
                m_overlappingObjects.RemoveQuick(otherObject);
            }
        }