mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Batch across skeletons.
This commit is contained in:
parent
f935a4ede0
commit
71bffc5356
@ -88,7 +88,9 @@ namespace Spine {
|
|||||||
time += gameTime.ElapsedGameTime.Milliseconds / 1000f;
|
time += gameTime.ElapsedGameTime.Milliseconds / 1000f;
|
||||||
animation.Apply(skeleton, time, true);
|
animation.Apply(skeleton, time, true);
|
||||||
skeleton.UpdateWorldTransform();
|
skeleton.UpdateWorldTransform();
|
||||||
|
skeletonRenderer.Begin();
|
||||||
skeletonRenderer.Draw(skeleton);
|
skeletonRenderer.Draw(skeleton);
|
||||||
|
skeletonRenderer.End();
|
||||||
|
|
||||||
base.Draw(gameTime);
|
base.Draw(gameTime);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,12 +53,25 @@ namespace Spine {
|
|||||||
Bone.yDown = true;
|
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) {
|
public void Draw (Skeleton skeleton) {
|
||||||
List<Slot> drawOrder = skeleton.DrawOrder;
|
List<Slot> drawOrder = skeleton.DrawOrder;
|
||||||
for (int i = 0, n = drawOrder.Count; i < n; i++) {
|
for (int i = 0, n = drawOrder.Count; i < n; i++) {
|
||||||
Slot slot = drawOrder[i];
|
Slot slot = drawOrder[i];
|
||||||
Attachment attachment = slot.Attachment;
|
Attachment attachment = slot.Attachment;
|
||||||
if (attachment == null) continue;
|
if (attachment == null)
|
||||||
|
continue;
|
||||||
if (attachment is RegionAttachment) {
|
if (attachment is RegionAttachment) {
|
||||||
RegionAttachment regionAttachment = (RegionAttachment)attachment;
|
RegionAttachment regionAttachment = (RegionAttachment)attachment;
|
||||||
|
|
||||||
@ -112,14 +125,6 @@ namespace Spine {
|
|||||||
item.vertexTR.TextureCoordinate.Y = uvs[RegionAttachment.Y4];
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,11 +77,6 @@ namespace Spine {
|
|||||||
/// sent to the GPU).
|
/// sent to the GPU).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SpriteBatcher {
|
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>
|
/// <summary>
|
||||||
/// Initialization size for the batch item list and queue.
|
/// Initialization size for the batch item list and queue.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -175,11 +170,6 @@ namespace Spine {
|
|||||||
_vertexArray = new VertexPositionColorTexture[4 * numBatchItems];
|
_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) {
|
public void Draw (GraphicsDevice device) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
if (_batchItemList.Count == 0)
|
if (_batchItemList.Count == 0)
|
||||||
@ -225,8 +215,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
// flush the remaining vertexArray data
|
// flush the remaining vertexArray data
|
||||||
FlushVertexArray(device, startIndex, index);
|
FlushVertexArray(device, startIndex, index);
|
||||||
// Update our batch count to continue the process of culling down
|
// Update our batch count to continue the process of culling down large batches
|
||||||
// large batches
|
|
||||||
batchCount -= numBatchesToProcess;
|
batchCount -= numBatchesToProcess;
|
||||||
}
|
}
|
||||||
_batchItemList.Clear();
|
_batchItemList.Clear();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user