ClearBuffered() public method

public ClearBuffered ( ) : void
return void
Ejemplo n.º 1
0
        public void Commit()
        {
            int removeCount = 0;

            Proxy[] proxies = _broadPhase._proxyPool;

            for (int i = 0; i < _pairBufferCount; ++i)
            {
                Pair pair = Find(_pairBuffer[i].ProxyId1, _pairBuffer[i].ProxyId2);
                Box2DXDebug.Assert(pair.IsBuffered());
                pair.ClearBuffered();

                Box2DXDebug.Assert(pair.ProxyId1 < Settings.MaxProxies && pair.ProxyId2 < Settings.MaxProxies);

                Proxy proxy1 = proxies[pair.ProxyId1];
                Proxy proxy2 = proxies[pair.ProxyId2];

                Box2DXDebug.Assert(proxy1.IsValid);
                Box2DXDebug.Assert(proxy2.IsValid);

                if (pair.IsRemoved())
                {
                    // It is possible a pair was added then removed before a commit. Therefore,
                    // we should be careful not to tell the user the pair was removed when the
                    // the user didn't receive a matching add.
                    if (pair.IsFinal() == true)
                    {
                        _callback.PairRemoved(proxy1.UserData, proxy2.UserData, pair.UserData);
                    }

                    // Store the ids so we can actually remove the pair below.
                    _pairBuffer[removeCount].ProxyId1 = pair.ProxyId1;
                    _pairBuffer[removeCount].ProxyId2 = pair.ProxyId2;
                    ++removeCount;
                }
                else
                {
                    Box2DXDebug.Assert(_broadPhase.TestOverlap(proxy1, proxy2) == true);

                    if (pair.IsFinal() == false)
                    {
                        pair.UserData = _callback.PairAdded(proxy1.UserData, proxy2.UserData);
                        pair.SetFinal();
                    }
                }
            }

            for (int i = 0; i < removeCount; ++i)
            {
                RemovePair(_pairBuffer[i].ProxyId1, _pairBuffer[i].ProxyId2);
            }

            _pairBufferCount = 0;

            if (BroadPhase.IsValidate)
            {
                ValidateTable();
            }
        }
Ejemplo n.º 2
0
        public void Commit()
        {
            int num = 0;

            Proxy[] proxyPool = this._broadPhase._proxyPool;
            for (int i = 0; i < this._pairBufferCount; i++)
            {
                Pair pair = this.Find((int)this._pairBuffer[i].ProxyId1, (int)this._pairBuffer[i].ProxyId2);
                Box2DXDebug.Assert(pair.IsBuffered());
                pair.ClearBuffered();
                Box2DXDebug.Assert((int)pair.ProxyId1 < Settings.MaxProxies && (int)pair.ProxyId2 < Settings.MaxProxies);
                Proxy proxy  = proxyPool[(int)pair.ProxyId1];
                Proxy proxy2 = proxyPool[(int)pair.ProxyId2];
                Box2DXDebug.Assert(proxy.IsValid);
                Box2DXDebug.Assert(proxy2.IsValid);
                if (pair.IsRemoved())
                {
                    if (pair.IsFinal())
                    {
                        this._callback.PairRemoved(proxy.UserData, proxy2.UserData, pair.UserData);
                    }
                    this._pairBuffer[num].ProxyId1 = pair.ProxyId1;
                    this._pairBuffer[num].ProxyId2 = pair.ProxyId2;
                    num++;
                }
                else
                {
                    Box2DXDebug.Assert(this._broadPhase.TestOverlap(proxy, proxy2));
                    if (!pair.IsFinal())
                    {
                        pair.UserData = this._callback.PairAdded(proxy.UserData, proxy2.UserData);
                        pair.SetFinal();
                    }
                }
            }
            for (int i = 0; i < num; i++)
            {
                this.RemovePair((int)this._pairBuffer[i].ProxyId1, (int)this._pairBuffer[i].ProxyId2);
            }
            this._pairBufferCount = 0;
            if (BroadPhase.IsValidate)
            {
                this.ValidateTable();
            }
        }