Browse Source

[xna] Fixed another (not so apparent) bug in multi pass rending (item texture reference was cleared to null and added to free pool too early). See #1554.

Harald Csaszar 5 years ago
parent
commit
6730852e86
1 changed files with 6 additions and 3 deletions
  1. 6 3
      spine-xna/src/MeshBatcher.cs

+ 6 - 3
spine-xna/src/MeshBatcher.cs

@@ -157,14 +157,17 @@ namespace Spine {
 
 
 				Array.Copy(item.vertices, 0, vertexArray, vertexCount, itemVertexCount);
 				Array.Copy(item.vertices, 0, vertexArray, vertexCount, itemVertexCount);
 				vertexCount += itemVertexCount;
 				vertexCount += itemVertexCount;
-
-				item.texture = null;
-				freeItems.Enqueue(item);
 			}
 			}
 			FlushVertexArray(device, vertexCount, triangleCount);
 			FlushVertexArray(device, vertexCount, triangleCount);
 		}
 		}
 
 
 		public void AfterLastDrawPass () {
 		public void AfterLastDrawPass () {
+			int itemCount = items.Count;
+			for (int i = 0; i < itemCount; i++) {
+				var item = items[i];
+				item.texture = null;
+				freeItems.Enqueue(item);
+			}
 			items.Clear();
 			items.Clear();
 		}
 		}