Fixed compilation warning

This commit is contained in:
Antoine Pilote
2025-04-24 12:25:45 -04:00
parent e8c4af6e5c
commit a82e3dec04
7 changed files with 6 additions and 6 deletions

View File

@@ -0,0 +1,3 @@
#include "AnimatedValue.h"
std::vector<IAnimatedValue*> IAnimatedValue::Instances;

View File

@@ -0,0 +1,62 @@
#pragma once
#include <Nuake/Core/Maths.h>
#include <vector>
class IAnimatedValue
{
public:
static std::vector<IAnimatedValue*> Instances;
static void UpdateAll (float ts)
{
for (auto& instance : Instances)
{
instance->Update(ts);
}
}
virtual void Update(float ts) = 0;
};
template<typename T>
class AnimatedValue : public IAnimatedValue
{
public:
T Value;
T TargetValue;
float Speed = 20.0f;
AnimatedValue(T value = T(), T targetValue = T())
: Value(value), TargetValue(targetValue)
{
IAnimatedValue::Instances.push_back(this);
}
~AnimatedValue()
{
auto it = std::remove(Instances.begin(), Instances.end(), this);
IAnimatedValue::Instances.erase(it, Instances.end());
}
virtual void Update(float ts) override
{
Value = glm::mix(Value, TargetValue, glm::clamp(Speed * ts, 0.0f, 1.0f));
}
void SetValue(T value)
{
Value = value;
TargetValue = value;
}
operator T() const
{
return Value;
}
AnimatedValue<T>& operator =(T value)
{
TargetValue = value;
return *this;
}
};

View File

@@ -65,7 +65,7 @@
#include "../Events/EditorRequests.h"
#include "../../../../Nuake/Thirdparty/glfw/include/GLFW/glfw3.h"
#include "../../../AnimatedValue.h"
#include "../misc/AnimatedValue.h"
namespace Nuake {

View File

@@ -6,7 +6,7 @@
#include "IEditorWidget.h"
#include "../../../../../AnimatedValue.h"
#include "../../../misc/AnimatedValue.h"
namespace Nuake
{

View File

@@ -2,7 +2,7 @@
#include "IEditorWidget.h"
#include "../../EditorSelectionPanel.h"
#include "../../../../../AnimatedValue.h"
#include "../../../misc/AnimatedValue.h"
class EditorContext;

View File

@@ -3,7 +3,7 @@
#include "IEditorWidget.h"
#include <imgui/ImGuizmo.h>
#include "../../../../../AnimatedValue.h"
#include "../../../misc/AnimatedValue.h"
class EditorContext;