Posted: Fri 10 Mar, 2006 9:02 pm
The "Permadi-way" will visit every grid if you combine the traversal of both horiz/vert rays. Since you jump 1 step in X and 1 step in Y independently, you will not miss any grid cells.
And yes, I used a flag matrix created in the raycaster to quickly figure out the conservative visibility of an object (simply check visited[obj.y][obj.x]).
I'm not sure how one would go about "storing objects as rays pass by", because that would require you to quickly figure out what objects are close to a ray for each step. These kind of problems have a number of solutions (with additional "derivatives" of course):
1) Test each object at each ray step (ugh!).
2) Flag for visited cells and then test all objects at once.
3) Store objects in dynamic arrays in a matrix (maybe even only allowing 1 object/grid cell).
The 3rd alternative gives a couple of nice features, such as controlling the number of objects in grid cells for collision detection.
And yes, I used a flag matrix created in the raycaster to quickly figure out the conservative visibility of an object (simply check visited[obj.y][obj.x]).
I'm not sure how one would go about "storing objects as rays pass by", because that would require you to quickly figure out what objects are close to a ray for each step. These kind of problems have a number of solutions (with additional "derivatives" of course):
1) Test each object at each ray step (ugh!).
2) Flag for visited cells and then test all objects at once.
3) Store objects in dynamic arrays in a matrix (maybe even only allowing 1 object/grid cell).
The 3rd alternative gives a couple of nice features, such as controlling the number of objects in grid cells for collision detection.