3#include "game/kart/KartObjectManager.hh"
8KartScale::KartScale(
const KartParam::Stats &stats) {
11 for (
u16 i = 0; i < 4; ++i) {
12 m_scaleTarget[i] = s_baseScaleTarget[i];
16 m_scaleTarget[i] = stats.shrinkScale;
19 m_scaleTarget[i] = stats.megaScale;
28KartScale::~KartScale() =
default;
31void KartScale::reset() {
33 m_sizeScale = EGG::Vector3f::unit;
34 m_scaleTransformOffset.setZero();
35 m_scaleTransformSlope.setZero();
36 m_scaleAnmActive =
false;
41 m_pressScale = EGG::Vector3f::unit;
45void KartScale::calc() {
46 if (m_scaleAnmActive) {
49 scaleAnm = KartObjectManager::ThunderScaleUpAnmChr();
50 }
else if (m_type == 1) {
51 scaleAnm = KartObjectManager::ThunderScaleDownAnmChr();
53 PANIC(
"Invalid scale type");
57 auto anmResult = scaleAnm->getAnmResult(m_anmFrame, 0);
58 m_sizeScale = m_scaleTransformOffset + m_scaleTransformSlope * anmResult.scale();
61 if (m_anmFrame > scaleAnm->frameCount()) {
62 m_scaleAnmActive =
false;
63 m_sizeScale.set(m_scaleTarget[m_type]);
64 m_scaleTransformOffset.setZero();
65 m_scaleTransformSlope.setZero();
73void KartScale::startCrush() {
81void KartScale::endCrush() {
89void KartScale::startShrink(s32 unk) {
90 m_type = unk > 0 ? 2 : 1;
92 m_scaleAnmActive =
true;
93 f32 tmp = m_scaleTarget[m_type];
94 m_scaleTransformSlope = (
EGG::Vector3f(tmp, tmp, tmp) - m_sizeScale) /
95 (s_baseScaleTarget[m_type] - s_baseScaleStart[m_type]);
96 m_scaleTransformOffset = m_sizeScale - m_scaleTransformSlope * s_baseScaleStart[m_type];
100void KartScale::endShrink(s32 unk) {
101 m_type = unk > 0 ? 3 : 0;
103 m_scaleAnmActive =
true;
104 f32 tmp = m_scaleTarget[m_type];
105 m_scaleTransformSlope = (
EGG::Vector3f(tmp, tmp, tmp) - m_sizeScale) /
106 (s_baseScaleTarget[m_type] - s_baseScaleStart[m_type]);
107 m_scaleTransformOffset = m_sizeScale - m_scaleTransformSlope * s_baseScaleStart[m_type];
111void KartScale::calcCrush() {
112 constexpr f32 SCALE_SPEED = 0.2f;
119 m_pressScale.y -= SCALE_SPEED;
120 if (m_pressScale.y < CRUSH_SCALE) {
121 m_pressScale.y = CRUSH_SCALE;
127 const auto *scaleAnm = KartObjectManager::PressScaleUpAnmChr();
138 const auto *scaleAnm = KartObjectManager::PressScaleUpAnmChr();
140 return scaleAnm->getAnmResult(frame, 0).scale();
Represents the CHR0 file format, which pertains to model movement animations.
bool m_calcCrush
Set while crush scaling is occurring.
CrushState m_crushState
Specifies the current crush/uncrush state.
f32 m_uncrushAnmFrame
Current frame of the unsquish animation.
Pertains to kart-related functionality.