refactor for speed observer#5609
Open
Kadajett wants to merge 1 commit intosupertuxkart:BalanceSTK2from
Open
Conversation
Kadajett
commented
Jan 1, 2026
Comment on lines
+319
to
+349
| void Camera::updateDynamicFoV(float dt, float speed_ratio, bool boost_active) | ||
| { | ||
|
|
||
| const float max_fov_increase = 8.0f; | ||
|
|
||
| const float speed_threshold = 0.7f; | ||
|
|
||
| const float threshold_range = 0.3f; | ||
|
|
||
| const float lerp_speed = 4.0f; | ||
|
|
||
| // Factors | ||
| float speed_factor = 0.0f; | ||
|
|
||
| if(speed_ratio > speed_threshold) { | ||
| speed_factor = | ||
| (speed_ratio - speed_threshold) / threshold_range; | ||
| } | ||
|
|
||
| float total_factor = speed_factor * (boost_active ? 1.3f : 1.0f); | ||
| total_factor = std::min(total_factor, 1.5f); | ||
|
|
||
| float fov_increase = total_factor * DEGREE_TO_RAD * max_fov_increase; | ||
| m_target_fov = m_fov + fov_increase; | ||
|
|
||
| float lerp_factor = 1.0f - expf(-lerp_speed * dt); | ||
|
|
||
| m_current_fov = m_current_fov + (m_target_fov - m_current_fov) * lerp_factor; | ||
|
|
||
| m_camera->setFOV(m_current_fov); | ||
| } No newline at end of file |
Author
There was a problem hiding this comment.
Thinking about moving this out of the camera. Maybe boost logic shouldn't exist here, and we just call setFOV elsewhere.
Kadajett
commented
Jan 1, 2026
| #include "karts/kart_properties.hpp" | ||
| #include "karts/max_speed.hpp" | ||
| #include "karts/skidding.hpp" | ||
| #include "modes/soccer_world.hpp" |
Kadajett
commented
Jan 1, 2026
Comment on lines
+107
to
+111
| void CameraNormal::onBoostActivated(Kart* kart, unsigned int category, | ||
| float add_speed, int duration_ticks) | ||
| { | ||
| #ifndef SERVER_ONLY | ||
| // Only trigger effects for THIS camera's kart (current player) |
Author
There was a problem hiding this comment.
Not sure the best place for this either.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactored speed lines out of the rest of the code. Found a few smells along the way!
Agreement