Tested rudimentarily by creating an arbitrary 2D point, and converting back n forth. seems to work, but can't tell for sure with Z... (there seem to be an inversion of direction, maybe from the OpenGL 180° rotation around X, when converting to world coord, and I get huge z when converting back. example of test below):
viewport: 635x621
glProjection / glModelView: defaults from runSofa2's BaseCamera
input point: 142 142
toViewportCoord: 0.223622 0.228663 1
toWorldCoord: -0.0047776 0.00458704 -1.02025
back to viewportCoord: 0.223622 -0.271337 2492.75
back to screenCoord: 142 -168.5 2492.75
I wanted to add a unit test in SofaBaseVisual, but I don't know how to mock the glProjection / glModelView that are retrieved in getOpenGLProjection / getOpenGLModelView called within my added methods... I'll look into it on monday ;)
This PR:
[ ] builds with SUCCESS for all platforms on the CI.
[ ] does not generate new warnings.
[ ] does not generate new unit test failures.
[ ] does not generate new scene test failures.
[ ] does not break API compatibility.
[ ] is more than 1 week old (or has fast-merge label).
Reviewers will merge only if all these checks are true.
Tested rudimentarily by creating an arbitrary 2D point, and converting back n forth. seems to work, but can't tell for sure with Z... (there seem to be an inversion of direction, maybe from the OpenGL 180° rotation around X, when converting to world coord, and I get huge z when converting back. example of test below):
I wanted to add a unit test in SofaBaseVisual, but I don't know how to mock the glProjection / glModelView that are retrieved in getOpenGLProjection / getOpenGLModelView called within my added methods... I'll look into it on monday ;)
This PR:
Reviewers will merge only if all these checks are true.