Ejemplo n.º 1
0
        public AxisSweep3(Vector3 worldAabbMin, Vector3 worldAabbMax, int maxHandles)
            : base()
        {
            BulletDebug.Assert(maxHandles > 1 && maxHandles < 32767);

            // init bounds
            _worldAabbMin = worldAabbMin;
            _worldAabbMax = worldAabbMax;

            Vector3 aabbSize = _worldAabbMax - _worldAabbMin;
            _quantize = new Vector3(65535.0f, 65535.0f, 65535.0f) / aabbSize;

            // allocate handles buffer and put all handles on free list
            _handles = new Handle[maxHandles];
            for (int i = 0; i < maxHandles; i++)
                _handles[i] = new Handle();
            _maxHandles = maxHandles;
            _numHandles = 0;

            // handle 0 is reserved as the null index, and is also used as the sentinel
            _firstFreeHandle = 1;
            {
                for (int i = _firstFreeHandle; i < maxHandles; i++)
                {
                    _handles[i].NextFree = (ushort)(i + 1);
                }
                _handles[maxHandles - 1].NextFree = 0;
            }

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

            // make boundary sentinels

            _handles[0].ClientData = 0;

            for (int axis = 0; axis < 3; axis++)
            {
                _handles[0].MinEdges[axis] = 0;
                _handles[0].MaxEdges[axis] = 1;

                _edges[axis][0].Position = 0;
                _edges[axis][0].Handle = 0;
                _edges[axis][1].Position = 0xffff;
                _edges[axis][1].Handle = 0;
            }
        }
Ejemplo n.º 2
0
		private bool TestOverlap(int ignoreAxis, Handle pHandleA, Handle pHandleB)
        {
	        for (int axis = 0; axis < 3; axis++)
	        { 
		        if (axis != ignoreAxis)
		        {
                    if (pHandleA.MaxEdges[axis] < pHandleB.MinEdges[axis] ||
                        pHandleB.MaxEdges[axis] < pHandleA.MinEdges[axis]) 
			        { 
				        return false; 
			        } 
		        }
	        } 

	        return true;
        }