Node update callbacks do not need to be disabled

This commit is contained in:
Bruno Herbelin
2021-12-20 00:26:08 +01:00
parent f921e7610c
commit a3a581794e
2 changed files with 12 additions and 18 deletions

View File

@@ -17,15 +17,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
**/
#include "UpdateCallback.h"
#include <glm/gtc/type_ptr.hpp>
#include "defines.h"
#include "Scene.h"
#include "Log.h"
#include <glm/gtc/type_ptr.hpp>
#include "UpdateCallback.h"
UpdateCallback::UpdateCallback() : enabled_(true), finished_(false)
UpdateCallback::UpdateCallback() : finished_(false), initialized_(false)
{
}
@@ -43,7 +43,7 @@ void CopyCallback::update(Node *n, float)
MoveToCallback::MoveToCallback(glm::vec3 target, float duration) : UpdateCallback(),
duration_(duration), progress_(0.f), initialized_(false), target_(target)
duration_(duration), progress_(0.f), target_(target)
{
}
@@ -71,7 +71,7 @@ void MoveToCallback::update(Node *n, float dt)
}
RotateToCallback::RotateToCallback(float target, float duration) : UpdateCallback(),
duration_(duration), progress_(0.f), initialized_(false), startingangle_(0.f), target_(target)
duration_(duration), progress_(0.f), startingangle_(0.f), target_(target)
{
}
@@ -101,7 +101,7 @@ void RotateToCallback::update(Node *n, float dt)
}
BounceScaleCallback::BounceScaleCallback(float scale) : UpdateCallback(),
initialized_(false), duration_(100.f), scale_(scale), progress_(0.f)
duration_(100.f), scale_(scale), progress_(0.f)
{
}
@@ -128,7 +128,7 @@ void BounceScaleCallback::update(Node *n, float dt)
}
InfiniteGlowCallback::InfiniteGlowCallback(float amplitude) : UpdateCallback(),
amplitude_(amplitude), time_(0.f), initialized_(false)
amplitude_(amplitude), time_(0.f)
{
}

View File

@@ -15,11 +15,11 @@ public:
virtual void update(Node *, float) = 0;
inline bool finished() const { return finished_; }
inline bool enabled() const { return enabled_; }
inline void reset() { initialized_ = false; }
protected:
bool enabled_;
bool finished_;
bool initialized_;
};
class CopyCallback : public UpdateCallback
@@ -35,35 +35,30 @@ class MoveToCallback : public UpdateCallback
{
float duration_;
float progress_;
bool initialized_;
glm::vec3 startingpoint_;
glm::vec3 target_;
public:
MoveToCallback(glm::vec3 target, float duration = 1000.f);
MoveToCallback(glm::vec3 target, float duration = 100.f);
void update(Node *n, float dt);
inline void reset() { initialized_ = false; }
};
class RotateToCallback : public UpdateCallback
{
float duration_;
float progress_;
bool initialized_;
float startingangle_;
float target_;
public:
RotateToCallback(float target, float speed = 1000.f);
RotateToCallback(float target, float duration = 100.f);
void update(Node *n, float dt);
inline void reset() { initialized_ = false; }
};
class BounceScaleCallback : public UpdateCallback
{
bool initialized_;
float duration_;
float scale_;
float progress_;
@@ -78,7 +73,6 @@ class InfiniteGlowCallback : public UpdateCallback
{
float amplitude_;
float time_;
bool initialized_;
glm::vec3 initial_scale_;
public: