forwarding (drawing) line in 3d grid

I need something like Bresenham algorithm but not quite and for 3d grid-space.

I got 3d grid of cells (edge size 1.0) need to start in point S and advance to point K 'touching' all the cells the line touches (even if only edge point is touched I need to touch all 8 cells).

Need to use it for traversal writing values to the cells or reading values from the cells and need it to be as fast as manageable (it would be in massive use of drawing millions of such 3d grid lines per frame).

Could somebody say how it could look like?


Solution 1:

Consider using of Woo and Amanatides grid traversal algorithm: article "Fast Voxel Traversal Algorithm..."

Practical implementation is in grid traversal section here

2d-case illustration:

enter image description here