Fix set_fov-induced grayscreen

This commit is contained in:
Lars Müller 2024-04-28 00:12:15 +02:00 committed by GitHub
parent a7bde8e523
commit 0837d674eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 31 deletions

View File

@ -97,38 +97,21 @@ void Camera::notifyFovChange()
PlayerFovSpec spec = player->getFov(); PlayerFovSpec spec = player->getFov();
/* // Remember old FOV in case a transition is wanted
* Update m_old_fov_degrees first - it serves as the starting point of the f32 m_old_fov_degrees = m_fov_transition_active
* upcoming transition. ? m_curr_fov_degrees // FOV is overridden with transition
* : m_server_sent_fov
* If an FOV transition is already active, mark current FOV as the start of ? m_target_fov_degrees // FOV is overridden without transition
* the new transition. If not, set it to the previous transition's target FOV. : m_cache_fov; // FOV is not overridden
*/
if (m_fov_transition_active)
m_old_fov_degrees = m_curr_fov_degrees;
else
m_old_fov_degrees = m_server_sent_fov ? m_target_fov_degrees : m_cache_fov;
/* m_server_sent_fov = spec.fov > 0.0f;
* Update m_server_sent_fov next - it corresponds to the target FOV of the m_target_fov_degrees = m_server_sent_fov
* upcoming transition. ? spec.is_multiplier
* ? m_cache_fov * spec.fov // apply multiplier to client-set FOV
* Set it to m_cache_fov, if server-sent FOV is 0. Otherwise check if : spec.fov // absolute override
* server-sent FOV is a multiplier, and multiply it with m_cache_fov instead : m_cache_fov; // reset to client-set FOV
* of overriding.
*/
if (spec.fov == 0.0f) {
m_server_sent_fov = false;
m_target_fov_degrees = m_cache_fov;
} else {
m_server_sent_fov = true;
m_target_fov_degrees = spec.is_multiplier ? m_cache_fov * spec.fov : spec.fov;
}
if (spec.transition_time > 0.0f) m_fov_transition_active = spec.transition_time > 0.0f;
m_fov_transition_active = true;
// If FOV smooth transition is active, initialize required variables
if (m_fov_transition_active) { if (m_fov_transition_active) {
m_transition_time = spec.transition_time; m_transition_time = spec.transition_time;
m_fov_diff = m_target_fov_degrees - m_old_fov_degrees; m_fov_diff = m_target_fov_degrees - m_old_fov_degrees;

View File

@ -241,7 +241,7 @@ private:
// Server-sent FOV variables // Server-sent FOV variables
bool m_server_sent_fov = false; bool m_server_sent_fov = false;
f32 m_curr_fov_degrees, m_old_fov_degrees, m_target_fov_degrees; f32 m_curr_fov_degrees, m_target_fov_degrees;
// FOV transition variables // FOV transition variables
bool m_fov_transition_active = false; bool m_fov_transition_active = false;