Skip to content

Improved Mouse Look Camera Smoothing#2441

Merged
Interkarma merged 37 commits intoInterkarma:mouse-smoothingfrom
AverniteDF:master
Dec 16, 2022
Merged

Improved Mouse Look Camera Smoothing#2441
Interkarma merged 37 commits intoInterkarma:mouse-smoothingfrom
AverniteDF:master

Conversation

@AverniteDF
Copy link
Copy Markdown
Contributor

@AverniteDF AverniteDF commented Oct 9, 2022

This submission contains a reworking of the camera smoothing code located in PlayerMouseLook.cs. The purpose of this reworking is primarily to increase behavioral parity between the "smoothing" and "no smoothing" modes. Moving the mouse an inch in a certain direction should give identical yaw/pitch deltas (ultimately) for both modes, it's just that one mode is progressive and the other is immediate.

Note: To increase or decrease the camera smoothing effect you may edit the following value (located near top of class):

float smoothing = 0.5f;

For example, a value of 0.3f will give a very subtle smoothing effect and a value of 0.8f will give a very pronounced smoothing effect (at the cost of less responsiveness/higher latency). I have chosen a value of 0.5f because I feel it is suitable for production. It is possible that the "Mouse Smoothing" checkbox could be replaced with a slider ranged 0.0 to 0.9, in future releases.

@Interkarma
Copy link
Copy Markdown
Owner

Interkarma commented Oct 11, 2022

Something I like about this change is the mouselook sensitivity feels equivalent with smoothing on or off. In the current implementation, mouselook sensitivity must be set differently based on smoothing.

This also raises a minor issue. Anyone with current smoothing on will experience a slower-feeling mouselook sensitivity once change goes live. Multiplying sensitivityX and sensitivityY by 2.5 - 3.0 lands about the same "feel" as the current mouselook sensitivity 1.0 with smoothing enabled. But not sure adding magic numbers is the best approach. Probably best just to increase default mouselook sensitivity and try our best to communicate change so existing users retune mouselook sensitivity.

A stronger refactoring than previous commits. The Init method is no longer needed and has been eliminated. Other classes may safely change Yaw and Pitch members directly now because getter/setters have been improved (the change to SerializablePlayer.cs is no longer needed). General code cleanup.
PlayerMouseLook no longer needs changes to this file.
@AverniteDF
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback!

One idea would be to inform players with an in-game popup message.

The popup message could explain the change and ask the user if they'd like to apply correction scaling to their mouse sensitivity (YES/NO). The invocation of this popup could be controlled by the presence/absence of a DaggerfallUnityVersion field in the settings.ini file.

If settings.ini does not contain that field then you know it was generated by a version prior to 0.14.5, therefore display the popup for sensitivity upscaling--but only if MouseLookSmoothing = True because those are the users who are affected.

Versions 0.14.5+ would record DaggerfallUnityVersion in settings.ini. Having this information could potentially be useful in the future for other unforeseen reasons as well.

If a user plays with 0.14.5+ and then goes back to an older version they will experience a mouse sensitivity increase but I don't think that's as big a deal.

@Interkarma
Copy link
Copy Markdown
Owner

One idea would be to inform players with an in-game popup message.

No need for anything like that. I'll communicate change via patch notes and socials, then support anyone who doesn't get the memo.

Please don't make style-only changes to existing code such as PitchMin to PITCH_MIN. I prefer contributors to match the style of original author and only make changes with a clear functional purpose.

Stripping this PR down to bare essentials of improved smoothing calculation, what's the minimum number of lines changed could this be accomplished in?

@AverniteDF
Copy link
Copy Markdown
Contributor Author

AverniteDF commented Oct 12, 2022 via email

New camera smoothing implemented with minimal changes to existing code.
@AverniteDF
Copy link
Copy Markdown
Contributor Author

AverniteDF commented Oct 12, 2022 via email

@AverniteDF
Copy link
Copy Markdown
Contributor Author

AverniteDF commented Oct 14, 2022 via email

@Interkarma
Copy link
Copy Markdown
Owner

SettingsManager will sync with player's live settings by removing old values and adding new values based on defaults. The best approach is simply to add the new setting with a different name to defaults.ini.txt and remove the old setting. There's no need to retain old values for backwards compatibility, this will be automatic if player runs an older version of the game.

Something like MouseLookSmoothingStrength or similar will do the job for new value.

Thanks for your PR. I'll review when I can. It won't make it into 0.14.5, as that version is already in testing. I'll aim to get it into 0.14.6.

Comment thread Assets/Scripts/Game/PlayerMouseLook.cs Outdated
Comment thread Assets/Scripts/Game/PlayerMouseLook.cs
Comment thread Assets/Scripts/Game/UserInterfaceWindows/DaggerfallUnitySetupGameWizard.cs Outdated
Comment thread Assets/Scripts/SettingsManager.cs Outdated
@Interkarma
Copy link
Copy Markdown
Owner

This is looking good so far, thank you for all the work on this one. :)

I'll aim to complete review and have it merged ahead of next release. I'll let you know if any issues are found.



private static class ToggleMouseSmoothing
/*private static class ToggleMouseSmoothing
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You should remove obsolete code altogether, if people are interested in old code they can have a look at Git history ;)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Fair point. I'm rather guilty of this myself. :)

@Interkarma Interkarma changed the base branch from master to mouse-smoothing December 16, 2022 01:20
@Interkarma Interkarma merged commit 63e8b94 into Interkarma:mouse-smoothing Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants