Update FoV dynamically when HMD FoV changes
https://github.com/praydog/UEVR/issues/371
Note that this is a very simple and awkward fix of the issue and I dont think it is good to merge yet. I need some help improving it.
Key idea: OpenXR::update_matrices() is, i guess, called every frame. The projection matrix(for intricsic parameters) update are somehow skipped in the function. And since convergence settings are effectly changing the intricsic parameters, we got convergence settings ignored in uevr. So to fix it, we just force the projection matrix update every 100frames (in case it is expensive, which looks unlikely).
To improve it, I have 2 ideas.
- (A) we force the projection matrix update every call of OpenXR::update_matrices(). But it can have some cost
- (B) we cache this->views[0].fov and this->views[1].fov. if this call's these variables are different from our cached version, we update the projection matrix.
Sorry for the awkward commit title. It is written without much mind and as a sentence it looks incorrect. We can fix it later when merging if it got updated and merged later.
Selected road (B):
Implemented FOV change detection for dynamic projection matrix updates.
- Mechanism: The FOV values for both eyes (8 floats total from
this->views[0].fovandthis->views[1].fov) are cached inthis->last_fovseach frame. - Comparison: A
memcmpchecks for exact bitwise equality between the current and cached FOV data. - Action: On any change (
fov_updated == true), the projection matrix is recalculated and the new FOV values are cached intothis->last_fovs.
@Asxcvbn you might update your PR title if you can. Maybe: Update FoV dynamically when HMD FoV changes?
I tested it and it works great!
@praydog this MR is a great improvement for users with 3D displays that use VRto3D, WibbleWobble, etc. It allows us to change the FoV dynamically to adjust the strength of the 3D effect. It is also useful for quickly finding the right horizontal FoV for the gameplay.