private void TranslateMesh(Vector3 direction) { //Dont schedule another job if the current one has not finished yet, or the last change still has to be uploaded if (translateJobHandle.HasValue /* || vertexUploadData.changed > 0*/) { return; } //Perform operation on a worker thread (job) var job = new VertexJob { V = V, VSize = VSize, direction = direction }; translateJobHandle = job.Schedule(); }
private void Update() { var handle = new VertexJob() { vertices = vertices, time = Time.time }.Schedule(TOTAL_SIZE, 0); new RecalculateGridNormalsJob() { vertices = vertices, normals = normals, size = SIZE }.Schedule(TOTAL_SIZE, 0, handle).Complete(); /* * Profiler.BeginSample("SetVertices managed array"); * mesh.SetVertices(vertexArray); * Profiler.EndSample(); */ float3[] managedF3s = new float3[TOTAL_SIZE]; Profiler.BeginSample("CopyTo"); vertices.CopyTo(managedF3s); Profiler.EndSample(); Profiler.BeginSample("Copy vertices"); for (int i = 0; i < TOTAL_SIZE; i++) { vertexArray[i] = vertices[i]; } Profiler.EndSample(); Profiler.BeginSample("SetVertices NativeArray"); mesh.SetVertices(vertices); Profiler.EndSample(); Profiler.BeginSample("SetVertices NativeArray"); mesh.SetNormals(normals); Profiler.EndSample(); /* * Profiler.BeginSample("Recalculate normals"); * mesh.RecalculateNormals(); * Profiler.EndSample();*/ }