For these who still don't get it on a grid raycasting looks this way:
step 1: calculate step x and y lengths so ray intersects with a nearest grid of map
step 2: do a step and check if there is a wall on that grid location
step 3: no wall? calculate next step - literally back to step 1 and repeat until you hit a wall
Repeat for each column of screen. If room has large empty space this would take ages because you are visiting whole empty space cell by cell.
In polygonal rooms:
step 1: calculate distance from your position to the nearest wall
Congratulations! You know how far away from wall you are! IN ONE EASY STEP! You don't need to care how large the room is.
Now draw a line on screen that corresponds to the height of the wall so you have some perspective. Fast as fuck and map takes LESS RAM. Not to mention it fits way better in cache
If you implement variable heights of floor just draw uer and lower fragments of the scene and don't draw anything inside the hole until you calculate intersection with wall of another room behind the portal.
Repeat as long as you wish or as lon there is any space on screen left to draw (if you "painted" whole column already you can stop giving a fuck about further intersections)
Basically what Ulitima Undeground, System Shock, Build engine did.
Do you see "the genius of John Carmack" now?