25 void initKeyframes(f32 startRate, f32 endRate, f32 tDelta, u32 param4) {
28 setStartKeyframe(startRate);
29 addKeyframe(endRate, tDelta, param4);
36 bool calc(f32 tDelta) {
37 m_rate = calcInterpRate(m_time);
40 bool endOfKeyframe = m_time > m_keyframes[1].m_time;
42 m_time = m_keyframes[1].m_time;
49 void setStartKeyframe(f32 param1) {
50 m_keyframes[m_numKeyframes].m_interpRate = param1;
51 m_keyframes[m_numKeyframes].m_time = 0.0f;
56 void addKeyframe(f32 rate, f32 tDelta, u32 ) {
57 m_keyframes[m_numKeyframes].m_interpRate = rate;
58 m_keyframes[m_numKeyframes].m_time = tDelta + m_keyframes[m_numKeyframes - 1].m_time;
63 [[nodiscard]] f32 calcInterpRate(f32 time)
const {
68 for (u32 idx = 0; idx < m_numKeyframes - 1; ++idx) {
69 currKeyframe = &m_keyframes[iVar5];
70 nextKeyframe = &m_keyframes[iVar5 + 1];
71 if (currKeyframe->m_time <= time && time < nextKeyframe->m_time) {
76 f32 timePastKeyframe = time - currKeyframe->m_time;
77 f32 keyframeDuration = nextKeyframe->m_time - currKeyframe->m_time;
79 timePastKeyframe = std::clamp(timePastKeyframe, 0.0f, keyframeDuration);
81 return Lerp(currKeyframe->m_interpRate, nextKeyframe->m_interpRate,
82 timePastKeyframe / keyframeDuration);
85 [[nodiscard]] f32 rate()
const {
98 [[nodiscard]]
static f32 Lerp(f32 a, f32 b, f32 t) {
99 f32 sin = EGG::Mathf::SinFIdx(RAD2FIDX * (-HALF_PI + t * (HALF_PI - -HALF_PI)));
100 f32 interpFactor = std::clamp(0.5f * (1.0f + sin), 0.0f, 1.0f);
102 return a + interpFactor * (b - a);
118 void createSwitchRace() {
140 m_state = State::Away;
148 if (m_switchReverse && m_switchReverse->isOn()) {
156 void calcSwitches() {
157 if (m_switchReverse) {
158 m_switchReverse->calc();
165 m_pos.y = m_kartObj->pos().y;
169 void calcCollision();
181 return v0 + (v1 - v0) * t;
184 static constexpr std::array<StateManagerEntry, 2> STATE_ENTRIES = {{
185 StateEntry<JugemUnit, &JugemUnit::enterIdle, &JugemUnit::calcIdle>(0),
186 StateEntry<JugemUnit, &JugemUnit::enterReverse, &JugemUnit::calcReverse>(1),