Skip to content

Collision Iterators

Prokop edited this page Jun 7, 2016 · 10 revisions

Consider I have a spacial datastructure which divide space into some bounding boxes ( e.g. 3D grid, octree, bounding volume hierarchy ), in each box I have stored several objects (e.g. spherical balls).

Now I would like to do these two operations:

  • shoot a ray from point gun.pos in direction gun.dir and execute ball.some_procedure() for all balls which colide with that ray.
  • execute some_procedure(ball,test_ball) for all balls which collide with a test ball

The straightforward code for this operations (without iterators) would look something like this:

Clone this wiki locally