From: Mikko Rasa Date: Tue, 21 May 2019 22:45:52 +0000 (+0300) Subject: Turn interpolation action mode into an enum X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=da21a5a971c2dfa3fdd729c4f799908253bb3873;p=libs%2Fdemoscene.git Turn interpolation action mode into an enum This makes it clearer what kind of interpolation is used and allows adding other types in the future. --- diff --git a/source/action.cpp b/source/action.cpp index b7cf082..f67bb28 100644 --- a/source/action.cpp +++ b/source/action.cpp @@ -1,7 +1,7 @@ #include "action.h" -InterpolationAction::InterpolationAction(bool h): - hermite(h), +InterpolationAction::InterpolationAction(Mode m): + mode(m), start_beat(0), duration(0) { } @@ -19,7 +19,7 @@ void InterpolationAction::tick(float b, float d) { float t = (b-start_beat)/duration; float dt = d/duration; - if(hermite) + if(mode==HERMITE) { dt = t-dt; t = (3-2*t)*t*t; diff --git a/source/action.h b/source/action.h index 9988854..980b038 100644 --- a/source/action.h +++ b/source/action.h @@ -17,11 +17,17 @@ public: class InterpolationAction: public Action { protected: - bool hermite; + enum Mode + { + LINEAR, + HERMITE + }; + + Mode mode; float start_beat; float duration; - InterpolationAction(bool = false); + InterpolationAction(Mode = LINEAR); public: virtual void start(float, float); diff --git a/source/colorfade.cpp b/source/colorfade.cpp index 30d9658..edfd1e0 100644 --- a/source/colorfade.cpp +++ b/source/colorfade.cpp @@ -3,7 +3,7 @@ using namespace Msp; ColorFadeAction::ColorFadeAction(const GL::Color &c): - InterpolationAction(true), + InterpolationAction(HERMITE), end_color(c) { }