NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
calc_ratio.hpp
1#pragma once
2
3namespace m3d {
4 /**
5 * @brief Class to smoothly blend between two values.
6 *
7 * This interpolation is done using a custom interpolation.
8 * The mWeight follows an ease-in/ease-out curve and the difference
9 * between the previous and current value of this weight is used
10 * to compute the actual interpolation.
11 */
13 public:
14 calcRatio_c(); ///< Constructs a ratio calculator.
15 virtual ~calcRatio_c() {} ///< Destroys the ratio calculator.
16
17 bool isEnd() const; ///< Returns whether the blend is complete.
18 void calc(); ///< Advances the blend by one time step.
19 void set(float duration); ///< Starts a blend with a given duration.
20 void remove(); ///< Cancels and resets the blend.
21 void reset(); ///< Resets the blend to its initial state.
22 void offUpdate(); ///< Pauses the blend.
23
24 float getScaleFrom() { return mScaleFrom; }
25 float getScaleTo() { return mScaleTo; }
26 float getSlerpParam() { return mInterpolateT; }
27
28 bool isActive() const { return mIsActive; }
29 bool isBlending() const { return mIsBlending; }
30
31 private:
32 float mWeight; ///< Current weight of the blend.
33 float mT; ///< The current time of the blend, between 0 and 1.
34 float mTimeStep; ///< How much to advance mT by each iteration.
35
36 float mScaleFrom; ///< How much to multiply the old value by (between 0 and 1).
37 float mScaleTo; ///< How much to multiply the new value by (between 0 and 1).
38 float mInterpolateT; ///< If using an interpolation function, use this as the @p t parameter.
39
40 bool mIsActive; ///< Whether the blend is paused.
41 bool mIsBlending; ///< Whether the blend is active.
42 };
43}
void set(float duration)
Starts a blend with a given duration.
float mTimeStep
How much to advance mT by each iteration.
bool mIsBlending
Whether the blend is active.
void remove()
Cancels and resets the blend.
float mScaleTo
How much to multiply the new value by (between 0 and 1).
bool mIsActive
Whether the blend is paused.
float mWeight
Current weight of the blend.
virtual ~calcRatio_c()
Destroys the ratio calculator.
void reset()
Resets the blend to its initial state.
float mT
The current time of the blend, between 0 and 1.
calcRatio_c()
Constructs a ratio calculator.
Definition calc_ratio.cpp:4
float mScaleFrom
How much to multiply the old value by (between 0 and 1).
void offUpdate()
Pauses the blend.
bool isEnd() const
Returns whether the blend is complete.
void calc()
Advances the blend by one time step.
float mInterpolateT
If using an interpolation function, use this as the t parameter.
mLib 3D library
Definition anm_chr.hpp:5