Fix bug with mesh divisors;

This commit is contained in:
bjorn 2019-02-05 15:57:22 -08:00
parent 0d81745282
commit 6f20126020
2 changed files with 7 additions and 3 deletions

View File

@ -46,6 +46,7 @@ typedef struct {
Material* material;
map_attribute_t attributes;
MeshAttribute layout[MAX_ATTRIBUTES];
uint16_t divisors[MAX_ATTRIBUTES];
GPU_MESH_FIELDS
} Mesh;

View File

@ -504,7 +504,9 @@ static void lovrGpuBindMesh(Mesh* mesh, Shader* shader, int divisorMultiplier) {
lovrBufferFlush(current.buffer);
}
if (!memcmp(&previous, &current, sizeof(MeshAttribute))) {
uint16_t divisor = current.divisor * divisorMultiplier;
if (!memcmp(&previous, &current, sizeof(MeshAttribute)) && mesh->divisors[i] == divisor) {
continue;
}
@ -518,8 +520,9 @@ static void lovrGpuBindMesh(Mesh* mesh, Shader* shader, int divisorMultiplier) {
}
}
if (previous.divisor != current.divisor) {
glVertexAttribDivisor(i, current.divisor * divisorMultiplier);
if (mesh->divisors[i] != divisor) {
glVertexAttribDivisor(i, divisor);
mesh->divisors[i] = divisor;
}
bool changed =