예제 #1
0
 public HashedOverlappingPairCache()
 {
     m_overlapFilterCallback = null;
     //m_blockedForChanges = false;
     m_ghostPairCallback = null;
     //int initialAllocatedSize= 2;
     m_overlappingPairArray = new List<BroadphasePair>();
     //m_overlappingPairTable = new Dictionary<ProxyPair, BroadphasePair>();
     //多分メモリ確保系の処理……(m_hashTableとm_nextとリンク)
     //growTables();
 }
예제 #2
0
        public virtual void SetInternalGhostPairCallback(IOverlappingPairCallback ghostPairCallback)
        {

        }
예제 #3
0
		public void SetOverlappingPairUserCallback(IOverlappingPairCallback pairCallback)
		{
			m_userPairCallback = pairCallback;
		}
예제 #4
0
		//public AxisSweep3Internal(ref Vector3 worldAabbMin,ref Vector3 worldAabbMax, int handleMask, int handleSentinel, int maxHandles = 16384, OverlappingPairCache* pairCache=0,bool disableRaycastAccelerator = false);
		public AxisSweep3Internal(ref Vector3 worldAabbMin, ref Vector3 worldAabbMax, int handleMask, ushort handleSentinel, ushort 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;
			ushort 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
			}

			//btAssert(bounds.HasVolume());

			// init bounds
			m_worldAabbMin = worldAabbMin;
			m_worldAabbMax = worldAabbMax;

			Vector3 aabbSize = m_worldAabbMax - m_worldAabbMin;

			int maxInt = m_handleSentinel;

			m_quantize = new Vector3((float)maxInt,(float)maxInt,(float)maxInt) / aabbSize;

			// allocate handles buffer, using btAlignedAlloc, and put all handles on free list
			m_pHandles = new Handle[maxHandles];
			for (int i = 0; i < m_pHandles.Length; ++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 (ushort i = m_firstFreeHandle; i < maxHandles; i++)
				{
					ushort nextFree = (ushort)(i + (ushort)1);
					m_pHandles[i].SetNextFree(nextFree);
				}
				m_pHandles[maxHandles - 1].SetNextFree(0);
			}

			{
				m_pEdges = new Edge[3, (maxHandles * 2)];
				// allocate edge buffers
				for (int i = 0; i < 3; i++)
				{
					for (int j = 0; j < maxHandles * 2; ++j)
					{
						m_pEdges[i,j] = new Edge();
					}
				}
			}
			//removed overlap management

			// make boundary sentinels
    	
			m_pHandles[0].SetClientObject(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

			}
		}
예제 #5
0
 public virtual void SetInternalGhostPairCallback(IOverlappingPairCallback ghostPairCallback)
 {
 }
예제 #6
0
 public void SetOverlappingPairUserCallback(IOverlappingPairCallback pairCallback)
 {
     m_userPairCallback = pairCallback;
 }
예제 #7
0
        //public AxisSweep3Internal(ref IndexedVector3 worldAabbMin,ref IndexedVector3 worldAabbMax, int handleMask, int handleSentinel, int maxHandles = 16384, OverlappingPairCache* pairCache=0,bool disableRaycastAccelerator = false);
        public AxisSweep3Internal(ref IndexedVector3 worldAabbMin, ref IndexedVector3 worldAabbMax, int handleMask, ushort handleSentinel, ushort 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;
            ushort 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
            }

            //btAssert(bounds.HasVolume());

            // init bounds
            m_worldAabbMin = worldAabbMin;
            m_worldAabbMax = worldAabbMax;

            IndexedVector3 aabbSize = m_worldAabbMax - m_worldAabbMin;

            int maxInt = m_handleSentinel;

            m_quantize = new IndexedVector3((float)maxInt) / aabbSize;

            // allocate handles buffer, using btAlignedAlloc, and put all handles on free list
            m_pHandles = new Handle[maxHandles];
            for (int i = 0; i < m_pHandles.Length; ++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 (ushort i = m_firstFreeHandle; i < maxHandles; i++)
                {
                    ushort nextFree = (ushort)(i + (ushort)1);
                    m_pHandles[i].SetNextFree(nextFree);
                }
                m_pHandles[maxHandles - 1].SetNextFree(0);
            }

            {
                m_pEdges = new Edge[3, (maxHandles * 2)];
                // allocate edge buffers
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < maxHandles * 2; ++j)
                    {
                        m_pEdges[i, j] = new Edge();
                    }
                }
            }
            //removed overlap management

            // make boundary sentinels

            m_pHandles[0].SetClientObject(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
            }
        }
예제 #8
0
파일: AxisSweep3.cs 프로젝트: himapo/ccm
        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

            }
        }