Fix circular/modulo arithmetic (Refs #93)

This commit is contained in:
saschawillems 2017-04-16 10:40:26 +02:00
parent 1912101fe8
commit 8fbfb7c22b

View file

@ -450,17 +450,9 @@ public:
#endif
}
void changeMatCapIndex(uint32_t delta)
void changeMatCapIndex(int32_t delta)
{
uboVS.texIndex += delta;
if (uboVS.texIndex < 0)
{
uboVS.texIndex = textures.matCapArray.layerCount-1;
}
if (uboVS.texIndex >= textures.matCapArray.layerCount)
{
uboVS.texIndex = 0;
}
uboVS.texIndex = (uboVS.texIndex + delta + textures.matCapArray.layerCount) % textures.matCapArray.layerCount;
updateUniformBuffers();
}