Example #1
0
		protected bool TestOverlap2D(Handle pHandleA, Handle pHandleB, int axis0, int axis1)
		{
			//optimization 1: check the array index (memory address), instead of the m_pos

			if (pHandleA.m_maxEdges[axis0] < pHandleB.m_minEdges[axis0] ||
			    pHandleB.m_maxEdges[axis0] < pHandleA.m_minEdges[axis0] ||
			    pHandleA.m_maxEdges[axis1] < pHandleB.m_minEdges[axis1] ||
			    pHandleB.m_maxEdges[axis1] < pHandleA.m_minEdges[axis1])
			{
				return false;
			}
			return true;


		}
Example #2
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

			}
		}
Example #3
0
		private void SanityCheckHandle(Handle handle,int axis)
		{
			if (handle.m_minEdges[axis] == ushort.MaxValue)
			{
				int ibreak = 0;
			}

		}