示例#1
0
        public BroadPhase(AABB worldAABB, PairCallback callback)
        {
            _pairManager = new PairManager();
            _pairManager.Initialize(this, callback);

            Box2DNetDebug.Assert(worldAABB.IsValid);
            _worldAABB  = worldAABB;
            _proxyCount = 0;

            Vec2 d = worldAABB.UpperBound - worldAABB.LowerBound;

            _quantizationFactor.X = (float)BROADPHASE_MAX / d.X;
            _quantizationFactor.Y = (float)BROADPHASE_MAX / d.Y;

            for (ushort i = 0; i < Settings.MaxProxies - 1; ++i)
            {
                _proxyPool[i]              = new Proxy();
                _proxyPool[i].Next         = (ushort)(i + 1);
                _proxyPool[i].TimeStamp    = 0;
                _proxyPool[i].OverlapCount = BroadPhase.Invalid;
                _proxyPool[i].UserData     = null;
            }
            _proxyPool[Settings.MaxProxies - 1]              = new Proxy();
            _proxyPool[Settings.MaxProxies - 1].Next         = PairManager.NullProxy;
            _proxyPool[Settings.MaxProxies - 1].TimeStamp    = 0;
            _proxyPool[Settings.MaxProxies - 1].OverlapCount = BroadPhase.Invalid;
            _proxyPool[Settings.MaxProxies - 1].UserData     = null;
            _freeProxy = 0;

            _timeStamp        = 1;
            _queryResultCount = 0;

            for (int i = 0; i < 2; i++)
            {
                _bounds[i] = new Bound[(2 * Settings.MaxProxies)];
            }

            int bCount = 2 * Settings.MaxProxies;

            for (int j = 0; j < 2; j++)
            {
                for (int k = 0; k < bCount; k++)
                {
                    _bounds[j][k] = new Bound();
                }
            }
        }
示例#2
0
 public void Initialize(BroadPhase broadPhase, PairCallback callback)
 {
     _broadPhase = broadPhase;
     _callback   = callback;
 }