SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
NerveUtil.cpp
1#include "Game/Util/NerveUtil.hpp"
2#include "Game/Util.hpp"
3
4namespace MR {
5 bool isStep(const NerveExecutor *pExecutor, s32 step) {
6 return pExecutor->getNerveStep() == step;
7 }
8
9 bool isFirstStep(const NerveExecutor *pExecutor) {
10 return MR::isStep(pExecutor, 0);
11 }
12
13 bool isLessStep(const NerveExecutor *pExecutor, s32 step) {
14 return pExecutor->getNerveStep() < step;
15 }
16
17 bool isLessEqualStep(const NerveExecutor *pExecutor, s32 step) {
18 return pExecutor->getNerveStep() <= step;
19 }
20
21 bool isGreaterStep(const NerveExecutor *pExecutor, s32 step) {
22 return pExecutor->getNerveStep() > step;
23 }
24
25 bool isGreaterEqualStep(const NerveExecutor *pExecutor, s32 step) {
26 return pExecutor->getNerveStep() >= step;
27 }
28
29 bool isIntervalStep(const NerveExecutor *pExecutor, s32 step) {
30 s32 curStep = pExecutor->getNerveStep();
31 s32 ratio = curStep / step;
32 s32 mult = ratio * step;
33 return mult == curStep;
34 }
35
36 bool isNewNerve(const NerveExecutor *pExecutor) {
37 return pExecutor->getNerveStep() < 0;
38 }
39
40 f32 calcNerveRate(const NerveExecutor *pExecutor, s32 a2) {
41 f32 rate;
42 if (a2 <= 0) {
43 rate = 1.0f;
44 }
45 else {
46 rate = MR::clamp((f32)pExecutor->getNerveStep() / (f32)a2, 0.0f, 1.0f);
47 }
48
49 return rate;
50 }
51
52 f32 calcNerveEaseInRate(const NerveExecutor *pExecutor, s32 a2) {
53 f32 rate;
54 if (a2 <= 0) {
55 rate = 1.0f;
56 }
57 else {
58 rate = MR::clamp((f32)pExecutor->getNerveStep() / (f32)a2, 0.0f, 1.0f);
59 }
60
61 return MR::getEaseInValue(rate, 0.0f, 1.0f, 1.0f);
62 }
63
64 f32 calcNerveEaseOutRate(const NerveExecutor *pExecutor, s32 a2) {
65 f32 rate;
66 if (a2 <= 0) {
67 rate = 1.0f;
68 }
69 else {
70 rate = MR::clamp((f32)pExecutor->getNerveStep() / (f32)a2, 0.0f, 1.0f);
71 }
72
73 return MR::getEaseOutValue(rate, 0.0f, 1.0f, 1.0f);
74 }
75
76 f32 calcNerveValue(const NerveExecutor *pExecutor, s32 a2, f32 a3, f32 a4) {
77 f32 rate;
78 if (a2 <= 0) {
79 rate = 1.0f;
80 }
81 else {
82 rate = MR::clamp((f32)pExecutor->getNerveStep() / (f32)a2, 0.0f, 1.0f);
83 }
84
85 return MR::getLinerValue(rate, a3, a4, 1.0f);
86 }
87
88 f32 calcNerveEaseInOutValue(const NerveExecutor *pExecutor, s32 a2, f32 a3, f32 a4) {
89 f32 rate;
90 if (a2 <= 0) {
91 rate = 1.0f;
92 }
93 else {
94 rate = MR::clamp((f32)pExecutor->getNerveStep() / (f32)a2, 0.0f, 1.0f);
95 }
96
97 return MR::getEaseInOutValue(rate, a3, a4, 1.0f);
98 }
99
100 f32 calcNerveEaseInOutValue(const NerveExecutor *pExecutor, s32 a2, s32 a3, f32 a4, f32 a5) {
101 f32 norm = MR::normalize(pExecutor->getNerveStep(), a2, a3);
102 f32 clamp = MR::clamp(norm, 0.0f, 1.0f);
103 return MR::getEaseInOutValue(clamp, a4, a5, 1.0f);
104 }
105
106 void setNerveAtStep(NerveExecutor *pExecutor, const Nerve *pNerve, s32 step) {
107 if (step == pExecutor->getNerveStep()) {
108 pExecutor->setNerve(pNerve);
109 }
110 }
111};
Used for executing states of a LiveActor.
Definition Nerve.hpp:6