I have a function that isn’t making sense with mutithreading, because it is writing results from a different gameobject than called by the function:

``````function multicore_normals (go: GameObject ){

yield WaitForSeconds(0.2);
//yield WaitForFixedUpdate;
var mesh : Mesh = go.GetComponent(MeshFilter).mesh;
var indicies: int[] = mesh.triangles;
var myvertices : Vector3[] = mesh.vertices;
var mynormals: Vector3[] = mesh.normals;
mynormals  = new Vector3[mesh.vertices.length];

Loom.RunAsync(function() {//----=-=-=-=-multicore from unitygems
for(var i :int= 0; i < indicies.Length; i += 3)
{
var v0: Vector3= myvertices[indicies*];*
``````
• `````` 	var v1 :Vector3= myvertices[indicies[i+1]];*
``````
• `````` 	var v2 :Vector3= myvertices[indicies[i+2]];*
``````
• `````` 	var  normal : Vector3= Vector3.Normalize(Vector3.Cross(v1 - v0, v2 - v0));*
``````

_ mynormals[indicies*] += normal;_
_
mynormals[indicies[i+1]] += normal;_
_
mynormals[indicies[i+2]] += normal;*_

* }*
for(i = 0; i < myvertices.Length; i++)
{
mynormals = Vector3.Normalize(mynormals*);*
}

*//mesh.normals = mynormals ; *
});});//----=-=-=-=-

* yield WaitForFixedUpdate;*

* mesh.normals = mynormals ; *

}
Result, every 1000 or so objects, i find a GameObject that has normals applied to it, that belong to a different GameObject, or that haven’t been calculated at all for that object. how can it rewrite the vertices of the object, and then fail to write normals on it, or write normals from a different GameObject of unity?
To call the newnormals function, the code does:
get meshObject, rewrite vertices,
newnormals(meshObject)

You might want to take a look at the Loom class when it comes to threading.