Terrain detection. C2 version without raycasting