In my script, I need to find the screen coordinates (2d) of some points in the viewport. The condition is that the relationship between the points from 3d has to be maintained in 2d as well (like parallel coordinates should also be parallel in 2d).
With location_3d_to_region_2d I get the right coordinates only if the view is in orthographic mode. But if the view is in perspective mode, the perspective correction causes distortions. How do I get the orthographic coordinates regardless of whether the view mode is perspective, orthographic or camera?
(I also tried changing the view mode to orthographic through the script itself. But for some reasons, the location_3d_to_region_2d call returns the coordinates of the old mode.)
Edit: Here's an illustration. The two lines are parallel as can be seen in the orthographic views. The screen coordinates of the orthographic view maintain this parallel relationship between the lines (the same slope for 2d lines) whereas the perspective view doesn't (different slopes, the lines are clearly not parallel). I need the screen coordinates of orthographic view, even if the viewport mode is set to perspective.