From what I can tell, there is currently no way of achieving what I was hoping for.
Overlapping polygons can be detected, but polylines only if one of the points are accually inside the polygon.
In short: I could not find a way to detect if a polyline with points on either side of a polygon, was accually "touching" the polygon.
A workaround could have been to take each "leg" of the polyline, split into several lines (256 for example, depending on the resolution you need), and checking each of these points, to see if they are inside the polygon.
This however, was much to slow for what I needed, since it would result i many many thousands of points to be checked individually.
Also it's more of a hack than a solution, and I don't approve of that in a solution ment for production.