public static BatchCollection CreateSpriteBatch(SpriteBatchInfo info, IEnumerable <BetterSprite> data) { BatchCollection result = new BatchCollection(); BetterSprite[] container = data.ToArray(); int batchSize = (int)info.BatchSize; int total = data.Count(); if (total < batchSize) { result.Batches.Add(CreateBatch(info.Execution, new Span <BetterSprite>(container))); return(result); } int maxBatches = total / batchSize; int i = 0; for (; i < maxBatches; i++) { var span = new Span <BetterSprite>(container, i * batchSize, batchSize); result.Batches.Add(CreateBatch(info.Execution, span)); } if (i < total) { int remaining = total - (maxBatches * batchSize); var span = new Span <BetterSprite>(container, i * batchSize, remaining); result.Batches.Add(CreateBatch(info.Execution, span)); } return(result);
public static BatchCollection CreateSpriteBatch(SpriteBatchInfo info, params BetterSprite[] data) { return(CreateSpriteBatch(info, data as IEnumerable <BetterSprite>)); }