Batch across skeletons.

This commit is contained in:
NathanSweet 2013-04-11 10:52:00 +02:00
parent f935a4ede0
commit 71bffc5356
3 changed files with 17 additions and 21 deletions

View File

@ -88,7 +88,9 @@ namespace Spine {
time += gameTime.ElapsedGameTime.Milliseconds / 1000f;
animation.Apply(skeleton, time, true);
skeleton.UpdateWorldTransform();
skeletonRenderer.Begin();
skeletonRenderer.Draw(skeleton);
skeletonRenderer.End();
base.Draw(gameTime);
}

View File

@ -53,12 +53,25 @@ namespace Spine {
Bone.yDown = true;
}
public void Begin () {
device.RasterizerState = rasterizerState;
device.BlendState = BlendState.AlphaBlend;
}
public void End () {
foreach (EffectPass pass in effect.CurrentTechnique.Passes) {
pass.Apply();
batcher.Draw(device);
}
}
public void Draw (Skeleton skeleton) {
List<Slot> drawOrder = skeleton.DrawOrder;
for (int i = 0, n = drawOrder.Count; i < n; i++) {
Slot slot = drawOrder[i];
Attachment attachment = slot.Attachment;
if (attachment == null) continue;
if (attachment == null)
continue;
if (attachment is RegionAttachment) {
RegionAttachment regionAttachment = (RegionAttachment)attachment;
@ -112,14 +125,6 @@ namespace Spine {
item.vertexTR.TextureCoordinate.Y = uvs[RegionAttachment.Y4];
}
}
device.RasterizerState = rasterizerState;
device.BlendState = BlendState.AlphaBlend;
foreach (EffectPass pass in effect.CurrentTechnique.Passes) {
pass.Apply();
batcher.Draw(device);
}
}
}
}

View File

@ -77,11 +77,6 @@ namespace Spine {
/// sent to the GPU).
/// </summary>
public class SpriteBatcher {
/*
* Note that this class is fundamental to high performance for SpriteBatch games. Please exercise
* caution when making changes to this class.
*/
/// <summary>
/// Initialization size for the batch item list and queue.
/// </summary>
@ -175,11 +170,6 @@ namespace Spine {
_vertexArray = new VertexPositionColorTexture[4 * numBatchItems];
}
/// <summary>
/// Sorts the batch items and then groups batch drawing into maximal allowed batch sets that do not
/// overflow the 16 bit array indices for vertices.
/// </summary>
/// <param name="sortMode">The type of depth sorting desired for the rendering.</param>
public void Draw (GraphicsDevice device) {
// nothing to do
if (_batchItemList.Count == 0)
@ -225,8 +215,7 @@ namespace Spine {
}
// flush the remaining vertexArray data
FlushVertexArray(device, startIndex, index);
// Update our batch count to continue the process of culling down
// large batches
// Update our batch count to continue the process of culling down large batches
batchCount -= numBatchesToProcess;
}
_batchItemList.Clear();