imgui icon indicating copy to clipboard operation
imgui copied to clipboard

Fix cursor position when weapon FOV does not match player FOV

Open dhkatz opened this issue 2 years ago • 2 comments

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 and ENTITY:GetBonePosition(n) always returns values in world space coordinates.

Before Fix:

https://github.com/wyozi-gmod/imgui/assets/8341611/be1b8c26-5bd8-4c32-b11b-a447c3dc861c

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:

https://github.com/wyozi-gmod/imgui/assets/8341611/d42aafc4-5370-4436-9cb1-8776b70dddbb

I can interact with both the button positioned in the world and the button positioned on the view model accurately to the mouse cursor.

dhkatz avatar Oct 29 '23 20:10 dhkatz

Ok it looks like this did break some things, so I might need to add a specific function for weapons like entities have

dhkatz avatar Oct 29 '23 21:10 dhkatz

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

dhkatz avatar Oct 29 '23 22:10 dhkatz