public void PaintMesh(MeshFilter meshFilter) { Mesh mesh = meshFilter.mesh; if (mesh == null || Mathf.Approximately(outerRadius, 0.0f)) return; if (mode == Mode.SingleCPU) { System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); Transform meshTransform = meshFilter.transform; Vector3[] vertices = mesh.vertices; Color[] colors = new Color[vertices.Length]; for (int i = 0; i < vertices.Length; ++i) { float verticeDistance = Vector3.Distance(this.transform.position, meshTransform.TransformPoint(vertices[i])); float colorWeight = (verticeDistance - innerRadius) / (outerRadius - innerRadius); colors[i] = Color.Lerp(paintColor, outRadiusColor, colorWeight); } mesh.colors = colors; stopWatch.Stop(); //Debug.LogFormat("Mesh {0} done in {1} ms", meshFilter.gameObject.name, stopWatch.ElapsedMilliseconds); } else // if (mode == Mode.JobSystem) { //Debug.LogFormat("Queue new job for mesh {0}...", meshFilter.gameObject.name); VCPaintJobHandle.Args args = new VCPaintJobHandle.Args(); args.innerColor = paintColor; args.outerColor = outRadiusColor; args.meshFilter = meshFilter; args.innerRadius = innerRadius; args.outerRadius = outerRadius; args.brushPosition = this.transform.position; VCPaintJobHandle newJobHandle = new VCPaintJobHandle(); newJobHandle.OnJobCompleted += OnJobCompleted; paintJobHandles.Add(newJobHandle); newJobHandle.Start(args); } }
private void OnJobCompleted(VCPaintJobHandle jobHandle) { //Debug.Log("Paint job completed!"); }