Skip to content

Commit

Permalink
Merge pull request EsotericSoftware#46 from Dgizusse/master
Browse files Browse the repository at this point in the history
Small fix and optimization when updating the mesh.
  • Loading branch information
NathanSweet committed May 15, 2013
2 parents 27d6766 + 99c8efb commit 78d687e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion spine-tk2d/Code/tk2dSpineSkeleton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,24 @@ private void UpdateMesh() {
}
}

mesh.Clear();

mesh.vertices = vertices;
mesh.colors = colors;
mesh.uv = uvs;
mesh.triangles = triangles;
mesh.RecalculateNormals();

if (skeletonDataAsset.sprites.normalGenerationMode != tk2dSpriteCollection.NormalGenerationMode.None) {
mesh.RecalculateNormals();

if (skeletonDataAsset.sprites.normalGenerationMode == tk2dSpriteCollection.NormalGenerationMode.NormalsAndTangents) {
Vector4[] tangents = new Vector4[mesh.normals.Length];
for (int t = 0; t < tangents.Length; ++t) {
tangents[t] = new Vector4(1, 0, 0, 1);
}
mesh.tangents = tangents;
}
}

renderer.sharedMaterial = skeletonDataAsset.sprites.spriteCollection.inst.materials[0];
}
Expand Down

0 comments on commit 78d687e

Please sign in to comment.