Skip to content

refactor for speed observer#5609

Open
Kadajett wants to merge 1 commit intosupertuxkart:BalanceSTK2from
Kadajett:feature/speed_lines
Open

refactor for speed observer#5609
Kadajett wants to merge 1 commit intosupertuxkart:BalanceSTK2from
Kadajett:feature/speed_lines

Conversation

@Kadajett
Copy link

@Kadajett Kadajett commented Jan 1, 2026

Refactored speed lines out of the rest of the code. Found a few smells along the way!

Agreement

By creating a pull request in stk-code, you hereby agree to dual-license your contribution as
GNU General Public License version 3 or any later version and
Mozilla Public License version 2 or any later version.

This includes your previous contribution(s) under the same name of contributor.

Keep the above statement in the pull request comment for agreement.

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
Copy link
Author

Choose a reason for hiding this comment

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

Thinking about moving this out of the camera. Maybe boost logic shouldn't exist here, and we just call setFOV elsewhere.

#include "karts/kart_properties.hpp"
#include "karts/max_speed.hpp"
#include "karts/skidding.hpp"
#include "modes/soccer_world.hpp"
Copy link
Author

Choose a reason for hiding this comment

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

Linter moved this one. 🤷🏻

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)
Copy link
Author

Choose a reason for hiding this comment

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

Not sure the best place for this either.

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.

1 participant