mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 12:31:51 +00:00
Merge branch 'main' into animation
This commit is contained in:
commit
49e7f2c631
89 changed files with 1050 additions and 687 deletions
|
|
@ -1,6 +1,5 @@
|
|||
#include "Clock.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace util;
|
||||
|
|
@ -20,10 +19,8 @@ int Clock::update(float delta) {
|
|||
tickTimer -= parts * delay / tickParts;
|
||||
tickTimer = std::min<float>(tickTimer, delay);
|
||||
}
|
||||
currentTickPart += parts;
|
||||
if (currentTickPart >= tickParts) {
|
||||
currentTickPart %= tickParts;
|
||||
}
|
||||
lastPartsStart = currentTickPart;
|
||||
currentTickPart = (currentTickPart + parts) % tickParts;
|
||||
return parts;
|
||||
}
|
||||
|
||||
|
|
@ -40,5 +37,5 @@ int Clock::getTickId() const {
|
|||
}
|
||||
|
||||
int Clock::convertPart(int index) const {
|
||||
return (tickParts - currentTickPart) % tickParts + index;
|
||||
return (lastPartsStart + index) % tickParts;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ namespace util {
|
|||
float tickTimer = 0.0f;
|
||||
int tickId = 0;
|
||||
int currentTickPart = 0;
|
||||
int lastPartsStart = 0;
|
||||
public:
|
||||
Clock(int tickRate, int tickParts);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#include <optional>
|
||||
#include <condition_variable>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <queue>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
|
|
|||
|
|
@ -3,31 +3,26 @@
|
|||
#include <glm/glm.hpp>
|
||||
|
||||
namespace util {
|
||||
template<class T>
|
||||
struct pow {
|
||||
constexpr T operator()(T a, T b) const {
|
||||
return glm::pow(a, b);
|
||||
}
|
||||
template<class T, T (*F)(T, T)>
|
||||
struct binary_op {
|
||||
constexpr T operator()(T a, T b) const { return F(a, b); }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct min {
|
||||
constexpr T operator()(T a, T b) const {
|
||||
return glm::min(a, b);
|
||||
}
|
||||
template<class T> using pow = binary_op<T, glm::pow>;
|
||||
template<class T> using min = binary_op<T, glm::min>;
|
||||
template<class T> using max = binary_op<T, glm::max>;
|
||||
|
||||
|
||||
template<class T, T (*F)(T)>
|
||||
struct unary_op {
|
||||
constexpr T operator()(T a) const { return F(a); }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct max {
|
||||
constexpr T operator()(T a, T b) const {
|
||||
return glm::max(a, b);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct abs {
|
||||
constexpr T operator()(T a) const {
|
||||
return glm::abs(a);
|
||||
}
|
||||
};
|
||||
template<typename T> using abs = unary_op<T, glm::abs>;
|
||||
template<typename T> using floor = unary_op<T, glm::floor>;
|
||||
template<typename T> using round = unary_op<T, glm::round>;
|
||||
template<typename T> using ceil = unary_op<T, glm::ceil>;
|
||||
template<typename T> using sin = unary_op<T, glm::sin>;
|
||||
template<typename T> using cos = unary_op<T, glm::cos>;
|
||||
template<typename T> using tan = unary_op<T, glm::tan>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue