private void RunJobsNow(NativeArray <double> heights, NativeArray <double3> vectors) { foreach (var cachedHeightWriter in CachedHeightWriters) // NOTE: Property { var handle = default(JobHandle); if (cachedHeightWriter.WriteHeight(ref handle, heights, vectors) == true) { handle.Complete(); } } if (heightmapData.IsCreated == true) { var job = new HeightmapJob(); job.Heights = heights; job.Vectors = vectors; job.Data = heightmapData; job.WaterLevel = waterLevel; job.Size = heightmapSize; job.Scale = heightmapSize / new double2(math.PI * 2.0, math.PI); job.Schedule(heights.Length, 1).Complete(); } var scaleJob = new ScaleJob(); scaleJob.Heights = heights; scaleJob.Radius = radius; scaleJob.Displacement = displacement; scaleJob.WaterLevel = waterLevel; scaleJob.ClampWater = clampWater; scaleJob.Schedule(heights.Length, 1).Complete(); }
private void Generate(SgtDynamicPlanetChunk chunk) { var startJob = new ChunkStartJob(); startJob.Points = SgtDynamicPlanetChunk.Config.POINTS; startJob.Cube = chunk.Cube; startJob.CubeH = chunk.CubeH; startJob.CubeV = chunk.CubeV; startJob.Vectors = chunkVectors; startJob.Heights = chunkHeights; var handle = startJob.Schedule(); foreach (var cachedHeightWriter in CachedHeightWriters) // NOTE: Property { cachedHeightWriter.WriteHeight(ref handle, chunkHeights, chunkVectors); } if (heightmapData.IsCreated == true) { var job = new HeightmapJob(); job.Heights = chunkHeights; job.Vectors = chunkVectors; job.Data = heightmapData; job.WaterLevel = waterLevel; job.Size = heightmapSize; job.Scale = heightmapSize / new double2(math.PI * 2.0, math.PI); handle = job.Schedule(chunkVectors.Length, math.max(1, chunkVectors.Length / SgtDynamicPlanetChunk.Config.BATCH_SPLIT), handle); } var scaleJob = new ScaleJob(); scaleJob.Heights = chunkHeights; scaleJob.Radius = radius; scaleJob.Displacement = displacement; scaleJob.WaterLevel = waterLevel; scaleJob.ClampWater = clampWater; handle = scaleJob.Schedule(chunkHeights.Length, 1, handle); var endJob = new ChunkEndJob(); endJob.Heights = chunkHeights; endJob.Vectors = chunkVectors; endJob.Coord = chunk.Coord; endJob.CoordM = chunk.CoordM; endJob.MeshPositions = meshPositions; endJob.MeshCoords0 = meshCoords0; endJob.MeshNormals = meshNormals; endJob.MeshTangents = meshTangents; endJob.Schedule(handle).Complete(); chunk.Corner = chunkVectors[SgtDynamicPlanetChunk.Config.LAST_POINT] * chunkHeights[SgtDynamicPlanetChunk.Config.LAST_POINT]; chunk.Mesh.SetVertices(ConvertNativeArray(meshPositions)); chunk.Mesh.SetNormals(ConvertNativeArray(meshNormals)); chunk.Mesh.SetTangents(ConvertNativeArray(meshTangents)); chunk.Mesh.SetUVs(0, ConvertNativeArray(meshCoords0)); chunk.Mesh.SetTriangles(SgtDynamicPlanetVisual.Config.INDICES, 0); }