mirror of https://github.com/bjornbytes/lovr.git
Fix model loading edge case;
This commit is contained in:
parent
2ced7c2c16
commit
6c2679e00f
|
@ -149,7 +149,7 @@ static jsmntok_t* resolveTexture(const char* json, jsmntok_t* token, ModelMateri
|
||||||
ModelData* lovrModelDataInitGltf(ModelData* model, Blob* source, ModelDataIO* io) {
|
ModelData* lovrModelDataInitGltf(ModelData* model, Blob* source, ModelDataIO* io) {
|
||||||
uint8_t* data = source->data;
|
uint8_t* data = source->data;
|
||||||
gltfHeader* header = (gltfHeader*) data;
|
gltfHeader* header = (gltfHeader*) data;
|
||||||
bool glb = header->magic == MAGIC_glTF;
|
bool glb = source->size >= sizeof(gltfHeader) && header->magic == MAGIC_glTF;
|
||||||
const char *json, *binData;
|
const char *json, *binData;
|
||||||
size_t jsonLength;
|
size_t jsonLength;
|
||||||
ptrdiff_t binOffset;
|
ptrdiff_t binOffset;
|
||||||
|
|
|
@ -237,7 +237,8 @@ ModelData* lovrModelDataInitObj(ModelData* model, Blob* source, ModelDataIO* io)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vertexBlob.length == 0 || indexBlob.length == 0) {
|
if (vertexBlob.length == 0 || indexBlob.length == 0) {
|
||||||
return NULL;
|
model = NULL;
|
||||||
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
model->blobCount = 2;
|
model->blobCount = 2;
|
||||||
|
@ -347,6 +348,7 @@ ModelData* lovrModelDataInitObj(ModelData* model, Blob* source, ModelDataIO* io)
|
||||||
.matrix = true
|
.matrix = true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
finish:
|
||||||
arr_free(&groups);
|
arr_free(&groups);
|
||||||
arr_free(&textures);
|
arr_free(&textures);
|
||||||
arr_free(&materials);
|
arr_free(&materials);
|
||||||
|
|
Loading…
Reference in New Issue