void EndStroke()
{
painting = false;
// could possibly make this faster by avoiding the double apply..
if (tab == Tab.Deform)
{
Profiler.BeginSample("Recalculate Normals and Tangents");
for (int i = 0; i < jobs.Length; ++i)
{
PaintJob j = jobs[i];
if (j.stream.positions != null && j.stream.normals != null && j.stream.tangents != null)
{
Mesh m = j.stream.Apply(false);
m.triangles = j.meshFilter.sharedMesh.triangles;
m.RecalculateNormals();
if (j.stream.normals == null)
{
j.stream.normals = new Vector3[m.vertexCount];
}
m.normals.CopyTo(j.stream.normals, 0);
m.uv = j.meshFilter.sharedMesh.uv;
CalculateMeshTangents(m);
if (j.stream.tangents == null)
{
j.stream.tangents = new Vector4[m.vertexCount];
}
m.tangents.CopyTo(j.stream.tangents, 0);
m.RecalculateBounds();
j.stream.Apply();
}
}
Profiler.EndSample();
}
for (int i = 0; i < jobs.Length; ++i)
{
PaintJob j = jobs[i];
if (j.HasStream())
{
EditorUtility.SetDirty(j.stream);
EditorUtility.SetDirty(j.stream.gameObject);
}
}
}