jimy-byerley / pymadcad

Simple yet powerful CAD (Computer Aided Design) library, written with Python.
https://madcad.netlify.app/
GNU Lesser General Public License v3.0
208 stars 16 forks source link

bad depth for the point retreived with `View.ptat` #32

Closed jimy-byerley closed 10 months ago

jimy-byerley commented 2 years ago

description

When using View.ptat() to get the 3d position on an object of the screen, the point is well placed on the screen from the point of view of the camera, but doest have the correct depth, resulting in a point much farther the pointed surface. This issue is more described in #28

current resolution state

For the implementation of ptat I relied on the OpenGL internal depthmap to get the view-object distance, and then recover the 3d position with the view perspective informations. But for some reasons OpenGL is giving me incorrect values (not conform to what the specifications I read says). So I experimentally patched the wrong depth value with a factor 0.53 which was giving something precise at ~5% at the time. Recently I noticed 0.5 was much closer to the reality, which was not the case at the time.

jimy-byerley commented 10 months ago

I didn't seen this problem for a while now, This was surely solved I don't know how by some changes in the shaders at some point ...