Suppose I am fighting an enemy with the usual 5-foot reach. He is standing next to a wall beside an open doorway. I am in next to him in the room. Without leaving his 5-foot range, I move to the other side of the wall. Does he get an opportunity attack?
M
-------- ----- to --------M ----- to-------- -----
EM E E
Assume that the wall is only a foot thick and is halfway in E's square and halfway in mine, so that E(nemy) and M(e) are in adjacent squares in the final diagram. But the enemy cannot reach me through the wall, so have I "left his reach" taking an opportunity attack while in the doorway?
If there was no wall there, I could move to that position without provoking any opportunity attack. Does the wall being there make it easier for the foe to attack me somehow?
Does your analysis change in the 3-dimensional case where the creature potentially leaving reach is an incorporeal creature moving from the square next to an enemy to the square (cube) next to and below the enemy?