// We need the main viewport where the game content is displayed, as certain UI layouts (e.g. Separated HUD) can make it a different size to the game window.
varmousePos=_inputManager.MouseScreenPosition.Position;// TODO: If we ever get a right-aligned Separated HUD setting, this might need to be adjusted for that.
varviewportSize=vp.PixelSize;// The size of the game viewport, including black bars - does not include the chatbox in Separated HUD view.
varscalingViewportSize=vp.ViewportSize*vp.CurrentRenderScale;// The size of the viewport in which the game is rendered (i.e. not including black bars). Note! Can extend outside the game window with certain zoom settings!
varvisibleViewportSize=Vector2.Min(viewportSize,scalingViewportSize);// The size of the game viewport that is "actually visible" to the player, cutting off over-extensions and not counting black bar padding.
varmouseCoords=Vector2.Transform(mousePos,matrix);// Gives the mouse position inside of the *scaling viewport*, i.e. 0,0 is inside the black bars. Note! 0,0 can be outside the game window with certain zoom settings!
varboundedMousePos=Vector2.Clamp(Vector2.Min(mouseCoords,mousePos),Vector2.Zero,visibleViewportSize);// Mouse position inside the visible game viewport's bounds.
// The offset must account for the in-world rotation.
vareyeRotation=_eyeManager.CurrentEye.Rotation;
varmouseActualRelativePos=Vector2.Transform(mouseNormalizedPos,System.Numerics.Quaternion.CreateFromAxisAngle(-System.Numerics.Vector3.UnitZ,(float)(eyeRotation.Opposite().Theta)));// I don't know, it just works.
// Caps the offset into a circle around the player.