-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cursor position when weapon FOV does not match player FOV #42
base: master
Are you sure you want to change the base?
Fix cursor position when weapon FOV does not match player FOV #42
Conversation
@@ -35,7 +35,7 @@ local function shouldAcceptInput() | |||
end | |||
|
|||
-- don't process input if we're doing VGUI stuff (and not in context menu) | |||
if vgui.CursorVisible() and vgui.GetHoveredPanel() ~= g_ContextMenu then | |||
if vgui.CursorVisible() and vgui.GetHoveredPanel() ~= g_ContextMenu and not vgui.IsHoveringWorld() then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seemed necessary because when calling gui.EnableScreenClicker(true)
in my weapon to bring up the mouse, input did not seem to be accepted because I was hovering the world panel.
Ok it looks like this did break some things, so I might need to add a specific function for weapons like entities have |
Ok I seem to have fixed the issues by adding a new function to only correct FOV using view model when rendering for a weapon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks. If you can just add ScrW and ScrH to .luacheckrc, I can merge this. Could also add a short mention to README
This is a PR which fixes #35
As far as I can tell this hasn't broken anything else but if someone can confirm that would be great.
I ended up adding a new function specifically for weapons because we only want to do FOV corrects for view models.
I did not automatically convert the position and angles using
ENTITY:LocalToWorld(pos)
because I assumed most people will be positioning view model UI relative to bone positions andENTITY:GetBonePosition(n)
always returns values in world space coordinates.Before Fix:
gmod_huaxYFYBfd.mp4
Notice how the mouse does not line up with the cursor while the screen clicker is active (the virtual cursor is being rendered by the weapon's
SWEP:PostDrawViewMode
)After Fix:
gmod_hKxs9xbz2R.mp4
I can interact with both the button positioned in the world and the button positioned on the view model accurately to the mouse cursor.