You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ScreenToWorld and WorldToScreen adjust the screen position by the origin of the viewport. However, when the origin of the window is not (0,0) this also adjusts by whatever the offset of the window is. This is very unlikely to be what you want since things like MouseState position or TouchState position are already relative to the window and so you are required to pre-emptively undo the correction made by ScreenToWorld (or WorldToScreen) using window information.
The text was updated successfully, but these errors were encountered:
To add to this, whatever the intended behavior of WorldToScreen, I assume that ScreenToWorld should be the direct inverse. Currently this is not the case.
The current implementation of ScreenToWorld return Vector2.Transform(screenPosition - new Vector2(viewport.X, viewport.Y), Matrix.Invert(GetViewMatrix()));
And the current implementation of WorldToScreen, which is not the inverse of the above. return Vector2.Transform(worldPosition + new Vector2(viewport.X, viewport.Y), GetViewMatrix());
I believe the intended implementation of WorldToScreen is the following: return Vector2.Transform(worldPosition, GetViewMatrix()) + new Vector2(viewport.X, viewport.Y);
ScreenToWorld
andWorldToScreen
adjust the screen position by the origin of the viewport. However, when the origin of the window is not(0,0)
this also adjusts by whatever the offset of the window is. This is very unlikely to be what you want since things likeMouseState
position orTouchState
position are already relative to the window and so you are required to pre-emptively undo the correction made byScreenToWorld
(orWorldToScreen
) using window information.The text was updated successfully, but these errors were encountered: