Got some plane-to-tile collisions working! It certainly took me a while and a few tries to get exactly what I wanted.
http://www.youtube.com/watch?v=m1x2hYsK62Q
From the description:
Finally got plane-to-tile collisions to work. Spent the past two weeks thinking of and trying various schemes for tile-exact collisions without being too stupid slow.
First scheme was to detect whether there was a tile at the Goplane's current position + speed. If a solid tile is detected, do line-line intersects with the tile edges the Goplane potentially touched. (no more than 2 at a time, so it wasn't that bad). The intersection would be where the plane would bounce of from. But it didn't work because the player speed could potentially be greater than the tile width, making the Goplane "skip" tiles and going through them. Plus another corner case that was super annoying made me drop this scheme.
The second scheme was the first thing I had thought of, but dismissed as being potentially too slow. Instead of detecting a single position ahead of the plane, I cast a ray from the player to the its next position using the Bresenham line algorithm. If a solid tile is detected, then use the position previous to the detection of the collision.
Spent an afternoon benchmarking probably a dozen different C-language implementations of Bresenham's line algorithm and various tweaks to find the fastest one. Moral of the story: ever take a guy's claim of "fastest line algorithm evar" at face value.
Also, before the plane was using a virtual coordinate system of 128 points for every pixel. This made casting a ray very, very expensive (length of pixel ray * 128). The virtual coordinate system is used to smooth out the plane's motion across pixels, especially when flying at the angles it does. I simplified the virtual coordinate system to be 2 points for every pixel and the results are still pretty darn good. So casting a ray is much faster.
The white square ahead of the plane indicates the plane's angle and whether the plane is colliding with a tile.
The collision method is still kinda expensive, but in my current plans, only the Goplane will collide with tiles this way. Other objects will have much simpler collision detection.
Next step is to make the plane bounce off surfaces.