Exemplo n.º 1
0
    public static void BakeMeshImmediate(Mesh mesh)
    {
        var       job        = new BakeJob(mesh.GetInstanceID());
        JobHandle currentJob = job.Schedule();

        currentJob.Complete();
    }
Exemplo n.º 2
0
    public static void StartBakingMesh(Mesh mesh)
    {
        var       job        = new BakeJob(mesh.GetInstanceID());
        JobHandle currentJob = job.Schedule();

        jobsByMesh.Add(mesh, currentJob);
    }
        IEnumerator BakeUpdator()
        {
            int counter = 0;

            while (true)
            {
                if (meshes.Count == 0)
                {
                    counter = 0;
                    yield return(null);

                    continue;
                }

                if (counter < 4 && meshes.Count < 5)
                {
                    counter++;
                    yield return(null);

                    continue;
                }

                meshIds = new NativeArray <int>(meshes.Count, Allocator.TempJob);

                for (int i = 0; i < meshes.Count; ++i)
                {
                    meshIds[i] = meshes[i].mesh.GetInstanceID();
                }

                BakeJob bakeJob = new BakeJob {
                    meshIds = meshIds
                };
                jobHandle = bakeJob.Schedule(meshIds.Length, 32);
                JobHandle.ScheduleBatchedJobs();
                int frameCount = 1;
                yield return(new WaitUntil(() =>
                {
                    frameCount++;
                    return jobHandle.IsCompleted || frameCount >= 4;
                }));

                jobHandle.Complete();
                meshIds.Dispose();

                for (int i = 0; i < meshes.Count; i++)
                {
                    meshes[i].chunk.SetSharedMesh(meshes[i].mesh);
                }

                meshes.Clear();
                counter = 0;
                yield return(null);
            }
        }
Exemplo n.º 4
0
 public void Schedule()
 {
     bakeHandle            = bakeJob.Schedule(bakeJob.curves.Length, 1);
     sampleLocalHandle     = sampleLocalPosesJob.Schedule(sampleLocalPosesJob.sampleRange.numFrames, 1, bakeHandle);
     convertToGlobalHandle = convertToGlobalPosesJob.Schedule(convertToGlobalPosesJob.sampleRange.numFrames, 1, sampleLocalHandle);
 }