mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
Block animation speed fix
This commit is contained in:
parent
b80e36f008
commit
bdc21df5c7
1 changed files with 9 additions and 5 deletions
|
|
@ -25,13 +25,17 @@ void TextureAnimator::update(float delta) {
|
|||
|
||||
frameBuffer->bind();
|
||||
for (auto& elem : animations) {
|
||||
if (changedTextures.find(elem.dstTexture->id) == changedTextures.end()) changedTextures.insert(elem.dstTexture->id);
|
||||
elem.timer -= delta;
|
||||
Frame& frame = elem.frames[elem.currentFrame];
|
||||
if (elem.timer <= 0) {
|
||||
elem.timer = frame.duration;
|
||||
elem.timer += delta;
|
||||
size_t frameNum = elem.currentFrame;
|
||||
Frame frame = elem.frames[elem.currentFrame];
|
||||
while (elem.timer >= frame.duration) {
|
||||
elem.timer -= frame.duration;
|
||||
elem.currentFrame++;
|
||||
if (elem.currentFrame >= elem.frames.size()) elem.currentFrame = 0;
|
||||
frame = elem.frames[elem.currentFrame];
|
||||
}
|
||||
if (frameNum != elem.currentFrame){
|
||||
if (changedTextures.find(elem.dstTexture->id) == changedTextures.end()) changedTextures.insert(elem.dstTexture->id);
|
||||
|
||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, elem.srcTexture->id, 0);
|
||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, elem.dstTexture->id, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue