Skip to content
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

Scale mouse/joystick sensitivity depending on FOV #11007

Merged
merged 1 commit into from Mar 19, 2021
Merged

Scale mouse/joystick sensitivity depending on FOV #11007

merged 1 commit into from Mar 19, 2021

Conversation

ryvnf
Copy link
Contributor

@ryvnf ryvnf commented Feb 28, 2021

Fixes #11005 for joystick and mouse input.

How to test

Use the zoom-key and compare the mouse responsiveness when zoomed in and not. It should feel just as responsive.

Compare that to without this patch where it will feel a lot more responsive when zoomed in.

@lhofhansl
Copy link
Contributor

I like the idea. Tested and works.

Took me a minute to reason through why tan(fov / 2.0).

@Zughy
Copy link
Member

Zughy commented Mar 1, 2021

Really needed feature for FPS games. Tested, works, just two things:

  1. mouse sensitivity: what was 0.2 before, it's now 0.25 (in terms of speed)
  2. I've tested in my FPS and it feels a bit too slow when zooming in. (I tend to play a lot of frantic FPSs, just to say I know what I'm talking about)

@sfan5 sfan5 added @ Client / Controls / Input Feature ✨ PRs that add or enhance a feature labels Mar 1, 2021
src/client/game.cpp Outdated Show resolved Hide resolved
src/client/game.cpp Outdated Show resolved Hide resolved
@ryvnf
Copy link
Contributor Author

ryvnf commented Mar 1, 2021

  • mouse sensitivity: what was 0.2 before, it's now 0.25 (in terms of speed)

  • I've tested in my FPS and it feels a bit too slow when zooming in. (I tend to play a lot of frantic FPSs, just to say I know what I'm talking about)

What aspect ratio and FOV do you use? I did make it such that the speed should be equal from before the change when playing on 72 degree FOV at 16:9 aspect ratio. I verified that the commited function returns 1.0 when playing using these values. I assume that is what most people play with.

// Multiply by a constant such that it becomes 1.0 at 72 degree FOV and
// 16:9 aspect ratio to minimize disruption of existing sensitivity
// settings.
return tan(fov_y / 2.0f) * 1.3763818698f;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this constant should be a DEFINE in order to understand what is this directly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it hard to give such a constant a meaningful name so I thought it was more clear just to multiply with it and explain its purpose in the comments. If std::tan was constexpr in C++11 I could do the something like following which would be more clear about its purpose and where it comes from:

static constexpr float default_fov_y = 72.0f * M_PI / 180.0f;
static constexpr float constant = 1.0f / tan(default_fov_y / 2.0f);

This works for gcc but as far as I know std::tan isn't is not guaranteed to be constexpr in C++11.

Maybe you have a better idea what to call such a constant?

Also where should I put it? I think it is better to have a constexpr variable in the function instead of a global macro because it is only used in that function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I think the comment right above it good enough to explain it.

@lhofhansl
Copy link
Contributor

Off-topic: @Zughy what mods do you use for your Minetest FPS games?

@Zughy
Copy link
Member

Zughy commented Mar 1, 2021

@ryvnf I didn't change the default FOV and I have a 16:9

@lhofhansl https://gitlab.com/zughy-friends-minetest/block_league (you can find it on AES server)

@ryvnf
Copy link
Contributor Author

ryvnf commented Mar 2, 2021

I didn't change the default FOV and I have a 16:9

Mathematically this shouldn't be the case. The sensitivity is multiplied by 1.3763818698. That constant is given by

1 / tan(degree_to_radians(72) / 2) = 1.3763818698

which when multiplied by tan(degree_to_radians(72) / 2) the result becomes

 tan(degree_to_radians(72) / 2) / tan(degree_to_radians(72) / 2) = 1

@lhofhansl
Copy link
Contributor

Where are we with this? I like this feature and stand by my "One Approval".

@ryvnf ryvnf requested review from sfan5 and nerzhul March 15, 2021 16:09
Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me. Initially the movement seemed very slow to me, but I suppose that's because I'm used to the normal speed.

Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me but we might have to add a setting for this once someone complainsnames a good usecase.

@SmallJoker SmallJoker merged commit 59a1b53 into minetest:master Mar 19, 2021
@Zughy Zughy mentioned this pull request Jun 28, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scale mouse sensitivity when changing FOV or zooming
6 participants