Example #1
0
 protected ShapeBatch(BufferPool pool, int initialShapeCount)
 {
     this.pool = pool;
     TypeId    = default(TShape).TypeId;
     InternalResize(initialShapeCount, 0);
     IdPool <Buffer <int> > .Create(pool.SpecializeFor <int>(), initialShapeCount, out idPool);
 }
Example #2
0
        /// <summary>
        /// Creates a character controller systme.
        /// </summary>
        /// <param name="pool">Pool to allocate resources from.</param>
        /// <param name="initialCharacterCapacity">Number of characters to initially allocate space for.</param>
        /// <param name="initialBodyHandleCapacity">Number of body handles to initially allocate space for in the body handle->character mapping.</param>
        public CharacterControllers(BufferPool pool, int initialCharacterCapacity = 4096, int initialBodyHandleCapacity = 4096)
        {
            this.pool  = pool;
            characters = new QuickList <CharacterController>(initialCharacterCapacity, pool);
            IdPool <Buffer <int> > .Create(pool.SpecializeFor <int>(), initialCharacterCapacity, out characterIdPool);

            ResizeBodyHandleCapacity(initialBodyHandleCapacity);
            analyzeContactsWorker = AnalyzeContactsWorker;
        }
Example #3
0
        public Deactivator(Bodies bodies, Solver solver, BufferPool pool)
        {
            this.bodies = bodies;
            this.solver = solver;
            this.pool   = pool;
            IdPool <Buffer <int> > .Create(pool.SpecializeFor <int>(), 16, out islandIdPool);

            workDelegate = Work;
        }
Example #4
0
        public unsafe Statics(BufferPool pool, Shapes shapes, Bodies bodies, BroadPhase broadPhase, int initialCapacity = 4096)
        {
            this.pool = pool;
            InternalResize(Math.Max(1, initialCapacity));

            this.shapes     = shapes;
            this.bodies     = bodies;
            this.broadPhase = broadPhase;

            IdPool <Buffer <int> > .Create(pool.SpecializeFor <int>(), initialCapacity, out HandlePool);
        }
 public ref T CreateContinuation(int slotsInContinuation, BufferPool pool, out int index)
 {
     if (!Continuations.Allocated)
     {
         Debug.Assert(!IdPool.Allocated);
         //Lazy initialization.
         pool.Take(InitialCapacity, out Continuations);
         IdPool <Buffer <int> > .Create(pool.SpecializeFor <int>(), InitialCapacity, out IdPool);
     }
     index = IdPool.Take();
     if (index >= Continuations.Length)
     {
         pool.Resize(ref Continuations, index + 1, index);
     }
     ref var continuation = ref Continuations[index];
Example #6
0
        /// <summary>
        /// Constructs a new bodies collection. Initialize must be called for the instance to be ready for use.
        /// </summary>
        /// <param name="pool">Pool for the collection to pull persistent allocations from.</param>
        /// <param name="shapes">Shapes referenced by the collection's bodies.</param>
        /// <param name="broadPhase">Broad phase containing the body collidables.</param>
        /// <param name="initialBodyCapacity">Initial number of bodies to allocate space for in the active set.</param>
        /// <param name="initialIslandCapacity">Initial number of islands to allocate space for in the Sets buffer.</param>
        /// <param name="initialConstraintCapacityPerBody">Expected number of constraint references per body to allocate space for.</param>
        public unsafe Bodies(BufferPool pool, Shapes shapes, BroadPhase broadPhase,
                             int initialBodyCapacity, int initialIslandCapacity, int initialConstraintCapacityPerBody)
        {
            this.pool = pool;

            //Note that the id pool only grows upon removal, so this is just a heuristic initialization.
            //You could get by with something a lot less aggressive, but it does tend to avoid resizes in the case of extreme churn.
            IdPool <Buffer <int> > .Create(pool.SpecializeFor <int>(), initialBodyCapacity, out HandlePool);

            ResizeHandles(initialBodyCapacity);
            ResizeSetsCapacity(initialIslandCapacity + 1, 0);
            ActiveSet       = new BodySet(initialBodyCapacity, pool);
            this.shapes     = shapes;
            this.broadPhase = broadPhase;
            MinimumConstraintCapacityPerBody = initialConstraintCapacityPerBody;
        }
                public ContinuationCache(BufferPool pool)
                {
                    IdPool <Buffer <int> > .Create(pool.SpecializeFor <int>(), 32, out Ids);

                    pool.SpecializeFor <T>().Take(128, out Caches);
                }