Example #1
0
 /// <summary>
 /// Increases the allocation size of any buffers too small to hold the allocation target.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The final size of the allocated buffers are constrained by the allocator. It is not guaranteed to be exactly equal to the target, but it is guaranteed to be at least as large.
 /// </para>
 /// <para>
 /// This is primarily a convenience function. Everything it does internally can be done externally.
 /// For example, if only type batches need to be resized, the solver's own functions can be used directly.
 /// </para>
 /// </remarks>
 /// <param name="allocationTarget">Allocation sizes to guarantee sufficient size for.</param>
 public void EnsureCapacity(SimulationAllocationSizes allocationTarget)
 {
     Solver.EnsureSolverCapacities(allocationTarget.Bodies, allocationTarget.Constraints);
     Solver.MinimumCapacityPerTypeBatch = Math.Max(allocationTarget.ConstraintsPerTypeBatch, Solver.MinimumCapacityPerTypeBatch);
     Solver.EnsureTypeBatchCapacities();
     //Note that the bodies set has to come before the body layout optimizer; the body layout optimizer's sizes are dependent upon the bodies set.
     Bodies.EnsureCapacity(allocationTarget.Bodies);
     Bodies.MinimumConstraintCapacityPerBody = allocationTarget.ConstraintCountPerBodyEstimate;
     Bodies.EnsureConstraintListCapacities();
     BodyLayoutOptimizer.ResizeForBodiesCapacity(BufferPool);
     Statics.EnsureCapacity(allocationTarget.Statics);
     Shapes.EnsureBatchCapacities(allocationTarget.ShapesPerType);
     BroadPhase.EnsureCapacity(allocationTarget.Bodies, allocationTarget.Bodies + allocationTarget.Statics);
 }