]> git.tdb.fi Git - libs/demoscene.git/commitdiff
Turn interpolation action mode into an enum
authorMikko Rasa <tdb@tdb.fi>
Tue, 21 May 2019 22:45:52 +0000 (01:45 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 21 May 2019 22:48:32 +0000 (01:48 +0300)
This makes it clearer what kind of interpolation is used and allows
adding other types in the future.

source/action.cpp
source/action.h
source/colorfade.cpp

index b7cf08278485747282d4aa80ee5b997ff9c7ba4b..f67bb28b517b136670e9d3e6fbd4a57786328424 100644 (file)
@@ -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;
index 998885452d609b94ca2a991caaae8223344b96d3..980b038a27b4469cd74ff49b5df0153ace8b70b5 100644 (file)
@@ -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);
index 30d96581f1f11bda8726bb52d353c48305540dbb..edfd1e03a7092db8cf1bfcfad9b7aeca06025e2a 100644 (file)
@@ -3,7 +3,7 @@
 using namespace Msp;
 
 ColorFadeAction::ColorFadeAction(const GL::Color &c):
-       InterpolationAction(true),
+       InterpolationAction(HERMITE),
        end_color(c)
 { }