public void DeformTerrain(IBrush brush, BrushOperation operation) { var bounds = brush.GetBounds(); var minIndex = (int3)math.floor(bounds.min / (TerrainChunk.CHUNK_SIZE * voxelSize)); var maxIndex = (int3)math.floor(bounds.max / (TerrainChunk.CHUNK_SIZE * voxelSize)); for (var x = minIndex.x; x <= maxIndex.x; x++) { for (var y = minIndex.y; y <= maxIndex.y; y++) { for (var z = minIndex.z; z <= maxIndex.z; z++) { var chunk = GetOrCreateChunkByKey(new ChunkKey { origin = math.int3(x, y, z) }); chunk.ScheduleApplyBrushJob(brush, operation); } } } }