Fix animation update

Fixes #1022
This commit is contained in:
Sascha Willems 2023-04-07 12:58:11 +02:00
parent 0ab683e827
commit aa3c00a784

View file

@ -731,19 +731,14 @@ public:
updateUniformBuffers(); updateUniformBuffers();
} }
void updateUniformBuffers(bool viewchanged = true) void updateUniformBuffers()
{ {
if (viewchanged) uboVS.projection = camera.matrices.perspective;
{ uboVS.modelView = camera.matrices.view;
uboVS.projection = camera.matrices.perspective; uboVS.viewPos = camera.viewPos;
uboVS.modelView = camera.matrices.view; uboVS.depth += frameTimer * 0.15f;
uboVS.viewPos = camera.viewPos; if (uboVS.depth > 1.0f) {
} uboVS.depth = uboVS.depth - 1.0f;
else
{
uboVS.depth += frameTimer * 0.15f;
if (uboVS.depth > 1.0f)
uboVS.depth = uboVS.depth - 1.0f;
} }
memcpy(uniformBufferVS.mapped, &uboVS, sizeof(uboVS)); memcpy(uniformBufferVS.mapped, &uboVS, sizeof(uboVS));
} }
@ -768,13 +763,9 @@ public:
if (!prepared) if (!prepared)
return; return;
draw(); draw();
if (!paused || camera.updated) if (!paused) {
updateUniformBuffers(camera.updated); updateUniformBuffers();
} }
virtual void viewChanged()
{
updateUniformBuffers(true);
} }
virtual void OnUpdateUIOverlay(vks::UIOverlay *overlay) virtual void OnUpdateUIOverlay(vks::UIOverlay *overlay)