mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 21:41:50 +00:00
commit
b7641541cb
2 changed files with 4 additions and 6 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
#include "Clock.hpp"
|
#include "Clock.hpp"
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace util;
|
using namespace util;
|
||||||
|
|
@ -20,10 +19,8 @@ int Clock::update(float delta) {
|
||||||
tickTimer -= parts * delay / tickParts;
|
tickTimer -= parts * delay / tickParts;
|
||||||
tickTimer = std::min<float>(tickTimer, delay);
|
tickTimer = std::min<float>(tickTimer, delay);
|
||||||
}
|
}
|
||||||
currentTickPart += parts;
|
lastPartsStart = currentTickPart;
|
||||||
if (currentTickPart >= tickParts) {
|
currentTickPart = (currentTickPart + parts) % tickParts;
|
||||||
currentTickPart %= tickParts;
|
|
||||||
}
|
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,5 +37,5 @@ int Clock::getTickId() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int Clock::convertPart(int index) 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;
|
float tickTimer = 0.0f;
|
||||||
int tickId = 0;
|
int tickId = 0;
|
||||||
int currentTickPart = 0;
|
int currentTickPart = 0;
|
||||||
|
int lastPartsStart = 0;
|
||||||
public:
|
public:
|
||||||
Clock(int tickRate, int tickParts);
|
Clock(int tickRate, int tickParts);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue