]> git.tdb.fi Git - libs/demoscene.git/commitdiff
Move the Action class out of Sequencer
authorMikko Rasa <tdb@tdb.fi>
Tue, 30 Apr 2019 09:49:48 +0000 (12:49 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 30 Apr 2019 09:56:10 +0000 (12:56 +0300)
source/action.cpp [new file with mode: 0644]
source/action.h [new file with mode: 0644]
source/beatcounter.h
source/cameracontrol.h
source/colorfade.cpp
source/colorfade.h
source/sequencer.cpp
source/sequencer.h
source/stage.h

diff --git a/source/action.cpp b/source/action.cpp
new file mode 100644 (file)
index 0000000..b7cf082
--- /dev/null
@@ -0,0 +1,37 @@
+#include "action.h"
+
+InterpolationAction::InterpolationAction(bool h):
+       hermite(h),
+       start_beat(0),
+       duration(0)
+{ }
+
+void InterpolationAction::start(float b, float d)
+{
+       start_beat = b;
+       duration = d;
+       interpolate(0.0f, 0.0f);
+}
+
+void InterpolationAction::tick(float b, float d)
+{
+       if(duration)
+       {
+               float t = (b-start_beat)/duration;
+               float dt = d/duration;
+               if(hermite)
+               {
+                       dt = t-dt;
+                       t = (3-2*t)*t*t;
+                       dt = t-(3-2*dt)*dt*dt;
+               }
+               interpolate(t, dt);
+       }
+       else
+               interpolate(1.0f, 1.0f);
+}
+
+void InterpolationAction::end(float)
+{
+       interpolate(1.0f, 0.0f);
+}
diff --git a/source/action.h b/source/action.h
new file mode 100644 (file)
index 0000000..9988854
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef MSP_DEMOSCENE_ACTION_H_
+#define MSP_DEMOSCENE_ACTION_H_
+
+class Action
+{
+protected:
+       Action() { }
+public:
+       virtual ~Action() { }
+
+       virtual void start(float, float) { }
+       virtual void beat(int) { }
+       virtual void tick(float, float) { }
+       virtual void end(float) { }
+};
+
+class InterpolationAction: public Action
+{
+protected:
+       bool hermite;
+       float start_beat;
+       float duration;
+
+       InterpolationAction(bool = false);
+
+public:
+       virtual void start(float, float);
+       virtual void tick(float, float);
+       virtual void end(float);
+       virtual void interpolate(float, float) { }
+};
+
+#endif
index 856c8d7d7f2b4bd5fb4e2e4600701a0d6835c574..952ed6b0460869dd2af309257fb7336501e65cb7 100644 (file)
@@ -5,9 +5,9 @@
 #include <msp/gl/objectinstance.h>
 #include <msp/gl/renderable.h>
 #include <msp/gl/text.h>
-#include "sequencer.h"
+#include "action.h"
 
-class BeatCounter: public Msp::GL::Renderable, public Sequencer::Action
+class BeatCounter: public Msp::GL::Renderable, public Action
 {
 private:
        Msp::GL::Text text;
index 455bad602cebeb187b7d868271f56315ff5d908d..a8221446192fb57e2f51465d7638448828cd66b8 100644 (file)
@@ -3,12 +3,12 @@
 
 #include <msp/gl/animationplayer.h>
 #include <msp/gl/camera.h>
-#include "sequencer.h"
+#include "action.h"
 
-class CameraControl: public Sequencer::Action
+class CameraControl: public Action
 {
 public:
-       class SetCamera: public Sequencer::Action
+       class SetCamera: public Action
        {
        private:
                CameraControl &control;
@@ -20,7 +20,7 @@ public:
                virtual void start(float, float);
        };
 
-       class AnimateCamera: public Sequencer::Action
+       class AnimateCamera: public Action
        {
        private:
                CameraControl &control;
index dfe7472e04c49c8d1dfa34c9081da94fd65f07a7..30d96581f1f11bda8726bb52d353c48305540dbb 100644 (file)
@@ -3,7 +3,7 @@
 using namespace Msp;
 
 ColorFadeAction::ColorFadeAction(const GL::Color &c):
-       Sequencer::InterpolationAction(true),
+       InterpolationAction(true),
        end_color(c)
 { }
 
index ce2e0a64862d475e9f400052c1d48b434a756a2f..3b87513a00a5a03878e8bd76a24c606fcef3f582 100644 (file)
@@ -2,9 +2,9 @@
 #define MSP_DEMOSCENE_COLORFADE_H_
 
 #include <msp/gl/color.h>
-#include "sequencer.h"
+#include "action.h"
 
-class ColorFadeAction: public Sequencer::InterpolationAction
+class ColorFadeAction: public InterpolationAction
 {
 protected:
        Msp::GL::Color start_color;
index 4acad43b2891bc9bf813bf481e75277fa0a4bf71..d9d35614dbf4ed9fd897b60e5c5df67ee68d5f11 100644 (file)
@@ -1,5 +1,6 @@
 #include <cmath>
 #include <msp/core/algorithm.h>
+#include "action.h"
 #include "sequencer.h"
 
 using namespace std;
@@ -125,40 +126,3 @@ void Sequencer::update_next_event()
                if(i->end_beat>beat)
                        next_event = min(next_event, i->end_beat);
 }
-
-
-Sequencer::InterpolationAction::InterpolationAction(bool h):
-       hermite(h),
-       start_beat(0),
-       duration(0)
-{ }
-
-void Sequencer::InterpolationAction::start(float b, float d)
-{
-       start_beat = b;
-       duration = d;
-       interpolate(0.0f, 0.0f);
-}
-
-void Sequencer::InterpolationAction::tick(float b, float d)
-{
-       if(duration)
-       {
-               float t = (b-start_beat)/duration;
-               float dt = d/duration;
-               if(hermite)
-               {
-                       dt = t-dt;
-                       t = (3-2*t)*t*t;
-                       dt = t-(3-2*dt)*dt*dt;
-               }
-               interpolate(t, dt);
-       }
-       else
-               interpolate(1.0f, 1.0f);
-}
-
-void Sequencer::InterpolationAction::end(float)
-{
-       interpolate(1.0f, 0.0f);
-}
index 028c5d5161d5094ffb92bbd0f59b333ecfbabd6b..e6eb2b7849381a4f4ad2f4a6196c71610040d186 100644 (file)
@@ -6,38 +6,10 @@
 #include <msp/time/timedelta.h>
 #include <msp/time/timestamp.h>
 
+class Action;
+
 class Sequencer
 {
-public:
-       class Action
-       {
-       protected:
-               Action() { }
-       public:
-               virtual ~Action() { }
-
-               virtual void start(float, float) { }
-               virtual void beat(int) { }
-               virtual void tick(float, float) { }
-               virtual void end(float) { }
-       };
-
-       class InterpolationAction: public Action
-       {
-       protected:
-               bool hermite;
-               float start_beat;
-               float duration;
-
-               InterpolationAction(bool = false);
-
-       public:
-               virtual void start(float, float);
-               virtual void tick(float, float);
-               virtual void end(float);
-               virtual void interpolate(float, float) { }
-       };
-
 private:
        struct Segment
        {
index f34e6ae8462eeb01360c4bfab816ed3f969b9dfb..2933856c1d000428003bd8fc129e5db9d112940a 100644 (file)
@@ -3,11 +3,11 @@
 
 #include <msp/gl/pipeline.h>
 #include "cameracontrol.h"
-#include "sequencer.h"
+#include "action.h"
 
 struct Stage
 {
-       class UseInView: public Sequencer::Action
+       class UseInView: public Action
        {
        private:
                Msp::GL::View &view;