public ScheduleAssignTilesJob ( ITerrainSampler terrainSampler, DaggerfallWorkshop.MapPixelData &mapData, JobHandle dependencies, bool march = true ) : JobHandle | ||
terrainSampler | ITerrainSampler | |
mapData | DaggerfallWorkshop.MapPixelData | |
dependencies | JobHandle | |
march | bool | |
return | JobHandle |
/// <summary> /// Update map pixel data based on current coordinates. (first of a two stage process) /// /// 1) BeginMapPixelDataUpdate - Schedules terrain data update using jobs system. /// 2) CompleteMapPixelDataUpdate - Completes terrain data update using jobs system. /// </summary> /// <param name="terrainTexturing">Instance of TerrainTexturing class to use.</param> /// <returns>JobHandle of the scheduled jobs</returns> public JobHandle BeginMapPixelDataUpdate(TerrainTexturing terrainTexturing = null) { // Get basic terrain data. MapData = TerrainHelper.GetMapPixelData(dfUnity.ContentReader, MapPixelX, MapPixelY); // Create data array for heightmap. MapData.heightmapData = new NativeArray <float>(heightmapDim * heightmapDim, Allocator.TempJob); // Create data array for tilemap data. MapData.tilemapData = new NativeArray <byte>(tilemapDim * tilemapDim, Allocator.TempJob); // Create data array for shader tile map data. MapData.tileMap = new NativeArray <Color32>(tilemapDim * tilemapDim, Allocator.TempJob); // Create data array for average & max heights. MapData.avgMaxHeight = new NativeArray <float>(new float[] { 0, float.MinValue }, Allocator.TempJob); // Create list for recording native arrays that need disposal after jobs complete. MapData.nativeArrayList = new List <IDisposable>(); // Generate heightmap samples. (returns when complete) JobHandle generateHeightmapSamplesJobHandle = dfUnity.TerrainSampler.ScheduleGenerateSamplesJob(ref MapData); // Handle location if one is present on terrain. JobHandle blendLocationTerrainJobHandle; if (MapData.hasLocation) { // Schedule job to calc average & max heights. JobHandle calcAvgMaxHeightJobHandle = TerrainHelper.ScheduleCalcAvgMaxHeightJob(ref MapData, generateHeightmapSamplesJobHandle); JobHandle.ScheduleBatchedJobs(); // Set location tiles. TerrainHelper.SetLocationTiles(ref MapData); // Schedule job to blend and flatten location heights. (depends on SetLocationTiles being done first) blendLocationTerrainJobHandle = TerrainHelper.ScheduleBlendLocationTerrainJob(ref MapData, calcAvgMaxHeightJobHandle); } else { blendLocationTerrainJobHandle = generateHeightmapSamplesJobHandle; } // Assign tiles for terrain texturing. JobHandle assignTilesJobHandle = (terrainTexturing == null) ? blendLocationTerrainJobHandle : terrainTexturing.ScheduleAssignTilesJob(dfUnity.TerrainSampler, ref MapData, blendLocationTerrainJobHandle); // Update tile map for shader. JobHandle updateTileMapJobHandle = TerrainHelper.ScheduleUpdateTileMapDataJob(ref MapData, assignTilesJobHandle); JobHandle.ScheduleBatchedJobs(); return(updateTileMapJobHandle); }