For 2D grid pathfinding, I want to do a quick broadphase to check if there is a direct path from the start to the target by conceptually checking all nodes touching the line segment formed by connecting the start and target nodes.
Is there an efficient way to iterate over each grid node between 2 grid nodes? If there isn't, would this broadphase be worth it?
Note: Grid nodes are stored in a 2D array like Node[,]. They each store a boolean describing whether one can be walked on or not, and also store their position on the grid. The information supplied for pathfinding (and this broadphase) is 2 grid nodes: a start and end node.
The grid points lying on the line connecting point $a$ with position $(x_1, y_1)$ to point $b$ with position $(x_2, y_2)$ can be found from the slope, which is given by $\frac{y_2 - y_1}{x_2 - x_1}$.
In the example below, $a=(3,2)$, $b=(28,12)$, and the slope is $\frac{y_2 - y_1}{x_2 - x_1}=\frac{12-2}{28-3}=\frac{2}{5}$.
So $a + k (5,2)$ for $k=1,\ldots$