6

I want to test for an intersection of a ray with a voxel field.

I could naively crawl through the voxel field by calculating a ray-box intersection with the edge of the current voxel, then doing the same for the next voxel until I hit something. But isn't there a faster way to trace through a voxel field? I was thinking something along the lines of Bresenham's line algorithm in 3D, something that could quickly give me all of the cells a given line intersects. Anyone done this before?

Due to certian limitations and the fact that these ray traces aren't happening that often, I do not want to build an octree or any other data structure.

Olivier Moindrot
  • 27,908
  • 11
  • 92
  • 91
Hannesh
  • 7,256
  • 7
  • 46
  • 80

2 Answers2

4

Here's an implementation of Bresenham's in 3D. It's in matlab; if you don't speak that you can see a C implementation here.

Xodarap
  • 11,581
  • 11
  • 56
  • 94
-2

I believe the octree-algorithm does what your asking for.

RobotRock
  • 4,211
  • 6
  • 46
  • 86