Archive 17/01/2023.

Correct ScreenToWorldPoint()

freegodsoul

Hi!
Camera::ScreenToWorldPoint() works as not as expected. Currently, depth of the screen point is used as a distance on normalized ray. It gives a spherical distortion effect to flat geometry on screen (right picture). ?ommon sense prompts me that this method should unproject point by using camera projection matrix inverse (left picture). Ray-based method should be renamed for example in ScreenToWorldPointPolar or something else. In some cases this can be useful.

cadaver

Good point, the current implementation is indeed wrong.

You can easily get the current behavior by calling GetScreenRay() and manipulating the returned ray so I don’t believe a separate function is needed.

cadaver

Fixed in master branch.

freegodsoul

Thanks! =)