[csharp] Thread safety for acquiring next VertexAttachment ID. 8a78eb4cf5

This commit is contained in:
pharan 2017-06-13 08:52:37 +08:00
parent 7481a05931
commit 61a5058a5c

View File

@ -34,8 +34,17 @@ namespace Spine {
/// <summary>>An attachment with vertices that are transformed by one or more bones and can be deformed by a slot's vertices.</summary> /// <summary>>An attachment with vertices that are transformed by one or more bones and can be deformed by a slot's vertices.</summary>
public class VertexAttachment : Attachment { public class VertexAttachment : Attachment {
static int nextID = 0; static int nextID = 0;
static Object nextIdLock = new Object();
static int GetNextID () {
int returnValue;
lock (nextIdLock) {
returnValue = nextID;
nextID++;
}
return returnValue;
}
internal readonly int id = (nextID++ & 65535) << 11; internal readonly int id = (VertexAttachment.GetNextID() & 65535) << 11;
internal int[] bones; internal int[] bones;
internal float[] vertices; internal float[] vertices;
internal int worldVerticesLength; internal int worldVerticesLength;