示例#1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="BroadPhase" /> class
        /// </summary>
        /// <param name="worldAabb">The world aabb</param>
        /// <param name="callback">The callback</param>
        public BroadPhase(Aabb worldAabb, PairCallback callback)
        {
            PairManager = new PairManager();
            PairManager.Initialize(this, callback);

            Box2DxDebug.Assert(worldAabb.IsValid);
            WorldAabb  = worldAabb;
            ProxyCount = 0;

            Vec2 d = worldAabb.UpperBound - worldAabb.LowerBound;

            QuantizationFactor.X = BroadphaseMax / d.X;
            QuantizationFactor.Y = BroadphaseMax / 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 = 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 = 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
 /// <summary>
 ///     Initializes the broad phase
 /// </summary>
 /// <param name="broadPhase">The broad phase</param>
 /// <param name="callback">The callback</param>
 public void Initialize(BroadPhase broadPhase, PairCallback callback)
 {
     BroadPhase = broadPhase;
     Callback   = callback;
 }