mirror of https://github.com/bjornbytes/lovr.git
Fix lovr.graphics.newModel when model has unused meshes;
Prefer n^2 loop over a weird sentinel value that wasn't always getting written over.
This commit is contained in:
parent
aa12263a29
commit
06811dcb1a
|
@ -95,17 +95,19 @@ void lovrModelDataAllocate(ModelData* model) {
|
|||
|
||||
void lovrModelDataFinalize(ModelData* model) {
|
||||
for (uint32_t i = 0; i < model->primitiveCount; i++) {
|
||||
model->primitives[i].skin = 0xaaaaaaaa;
|
||||
model->primitives[i].skin = ~0u;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < model->nodeCount; i++) {
|
||||
ModelNode* node = &model->nodes[i];
|
||||
for (uint32_t j = 0, index = node->primitiveIndex; j < node->primitiveCount; j++, index++) {
|
||||
if (model->primitives[index].skin != 0xaaaaaaaa) {
|
||||
lovrCheck(model->primitives[index].skin == node->skin, "Model has a mesh used with multiple skins, which is not supported");
|
||||
} else {
|
||||
model->primitives[index].skin = node->skin;
|
||||
}
|
||||
|
||||
for (uint32_t j = 0; j < model->nodeCount; j++) {
|
||||
if (i == j || node->primitiveIndex != model->nodes[j].primitiveIndex) continue;
|
||||
lovrCheck(node->skin == model->nodes[j].skin, "Model has a mesh used with multiple different skins, which is not supported");
|
||||
}
|
||||
|
||||
for (uint32_t j = node->primitiveIndex; j < node->primitiveIndex + node->primitiveCount; j++) {
|
||||
model->primitives[j].skin = node->skin;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue