Fixed the polygon hit detection by not skipping the last edge.