1#include "KartBurnout.hh"
3#include "game/kart/KartPhysics.hh"
4#include "game/kart/KartState.hh"
6#include <egg/math/Math.hh>
11KartBurnout::KartBurnout() =
default;
14KartBurnout::~KartBurnout() =
default;
17void KartBurnout::start() {
25void KartBurnout::calc() {
26 constexpr u32 BURNOUT_DURATION = 120;
34 if (calcEnd(BURNOUT_DURATION)) {
39f32 KartBurnout::pitch()
const {
44void KartBurnout::calcRotation() {
45 constexpr u16 PHASE_INCREMENT = 800;
46 constexpr f32 PHASE_TO_FIDX = 1.0f / 256.0f;
47 constexpr f32 AMPLITUDE_FACTOR = 40.0f;
48 constexpr f32 DAMPENING_THRESHOLD = 30.0f;
49 constexpr f32 DAMPENING_FACTOR = 0.97f;
51 m_phase += PHASE_INCREMENT;
53 f32 sin = EGG::Mathf::SinFIdx(
static_cast<f32
>(m_phase) * PHASE_TO_FIDX);
56 if (
static_cast<f32
>(m_timer) > DAMPENING_THRESHOLD) {
57 m_amplitude *= DAMPENING_FACTOR;
60 m_pitch = DEG2RAD * (AMPLITUDE_FACTOR * sin) * m_amplitude;
65 physics()->composeStuntRot(rpy);
69bool KartBurnout::calcEnd(u32 duration) {
70 return ++m_timer >= duration;
74void KartBurnout::activate() {
75 state()->setBurnout(
true);
79void KartBurnout::deactivate() {
80 state()->setBurnout(
false);
84bool KartBurnout::isActive()
const {
85 return state()->isBurnout();
Pertains to kart-related functionality.
A quaternion, used to represent 3D rotation.
void setRPY(const Vector3f &rpy)
Sets roll, pitch, and yaw.