Assets/Examples/Scripts/HeightmapTerrainDensityCalculationJob.cs
/// <summary>
/// The execute method required for Unity's IJobParallelFor job type
/// </summary>
/// <param name="index">The iteration index provided by Unity's Job System</param>
The execute method required for Unity's IJobParallelFor job type
The execute method required for Unity ' s IJobParallelFor job type
public void Execute(int index)
        {
            int worldPositionX = index / (chunkSize * chunkSize) + offset.x;
            int worldPositionY = index / chunkSize % chunkSize + offset.y;
            int worldPositionZ = index % chunkSize + offset.z;
            float density = 0;
            if (worldPositionX < heightmapWidth && worldPositionZ < heightmapHeight)
            {
                density = CalculateDensity(worldPositionX, worldPositionY, worldPositionZ);
            }
            densities[index] = math.clamp(density, -1, 1);
        }
public void Execute ( int index ) { int worldPositionX = index / ( chunkSize * chunkSize ) + offset . x ; int worldPositionY = index / chunkSize % chunkSize + offset . y ; int worldPositionZ = index % chunkSize + offset . z ; float density = 0 ; if ( worldPositionX < heightmapWidth && worldPositionZ < heightmapHeight ) { density = CalculateDensity ( worldPositionX , worldPositionY , worldPositionZ ) ; } densities [ index ] = math . clamp ( density , - 1 , 1 ) ; }
The execute method required for Unity's IJobParallelFor job type
The execute method required for Unity ' s IJobParallelFor job type
index
int
The iteration index provided by Unity's Job System
The iteration index provided by Unity ' s Job System