示例#1
0
        protected override JobHandle StartGeneration(JobHandle lastHandle = default)
        {
            Dispose();
            CheckData(data, info);

            CreateMeshData();

            bool useHeightData = info.UseHeightData && data.HasHeights;

            var infoArray = new NativeArray <TopCellInfo>(data.RawData.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);

            AddTemp(infoArray);

            lastHandle = ScheduleCalculateInfoJob(data, info, infoArray, vertices, triangles, normals, uvs, lastHandle);

            JobHandle vertexHandle = ScheduleCalculateVerticesJob(data, info, useHeightData, cellSize, infoArray, vertices, lastHandle);

            if (info.GenerateUvs)
            {
                vertexHandle = ScheduleCalculateUVJob(data, info, cellSize, infoArray, vertices, uvs, vertexHandle);
            }

            JobHandle triangleHandle = ScheduleCalculateTrianglesJob(data.ColNum, data.RowNum, infoArray, triangles, info.IsFlipped, lastHandle);

            lastHandle = JobHandle.CombineDependencies(vertexHandle, triangleHandle);

            if (info.GenerateNormals && useHeightData)
            {
                lastHandle = CalculateNormals.ScheduleDeferred(vertices, triangles, normals, lastHandle);
            }

            return(lastHandle);
        }
示例#2
0
        protected override JobHandle StartGeneration(JobHandle lastHandle = default)
        {
            Dispose();
            CheckData(data, info);

            CreateMeshData();

            bool useCullingData      = info.UseCullingData && data.HasCullingData;
            bool useHeightData       = info.UseHeightData && data.HasHeights;
            bool needsEdgeNormalData = info.ScaledOffset > 0;

            var mergeInfoArray = new NativeArray <MergeCellInfo>(data.RawData.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);

            AddTemp(mergeInfoArray);

            lastHandle = ScheduleGenerateOptimizationData(data, info, useCullingData, useHeightData, mergeInfoArray, lastHandle);

            var infoArray = new NativeArray <TopCellInfo>(data.RawData.Length, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);

            AddTemp(infoArray);

            lastHandle = ScheduleCalculateInfoJob(data, info, useCullingData, infoArray, mergeInfoArray, vertices, triangles, normals, uvs, lastHandle);

            NativeArray <EdgeNormals> edgeNormalsArray = default;

            if (needsEdgeNormalData)
            {
                edgeNormalsArray = new NativeArray <EdgeNormals>(data.RawData.Length, Allocator.TempJob, NativeArrayOptions.ClearMemory);
                AddTemp(edgeNormalsArray);

                lastHandle = ScheduleEdgeNormalsJob(new TopCellEdgeNormalCalculator(), data.ColNum, data.RowNum, infoArray, edgeNormalsArray, info.LerpToExactEdge, lastHandle);
            }

            JobHandle vertexHandle = ScheduleCalculateVerticesJob(data, info, useHeightData, cellSize, infoArray, vertices, edgeNormalsArray, lastHandle);

            if (info.GenerateUvs)
            {
                vertexHandle = ScheduleCalculateUVJob(data, info, cellSize, infoArray, vertices, uvs, vertexHandle);
            }

            JobHandle triangleHandle = ScheduleCalculateTrianglesJob(data.ColNum, data.RowNum, infoArray, mergeInfoArray, triangles, info.IsFlipped, lastHandle);

            lastHandle = JobHandle.CombineDependencies(vertexHandle, triangleHandle);

            if (info.GenerateNormals && useHeightData)
            {
                lastHandle = CalculateNormals.ScheduleDeferred(vertices, triangles, normals, lastHandle);
            }

            return(lastHandle);
        }