Error instead of crashing when skin has too many joints;

ModelData is still allowed to load skins with more joints, since
the limitation is in the graphics side of things (Model).

Eventually we will use a buffer for joints to alleviate this.
This commit is contained in:
bjorn 2020-05-02 14:14:06 -06:00
parent f160ed75e9
commit b0289de9a6
1 changed files with 6 additions and 0 deletions

View File

@ -184,6 +184,12 @@ Model* lovrModelCreate(ModelData* data) {
}
}
// Ensure skin bone count doesn't exceed the maximum supported limit
for (uint32_t i = 0; i < data->skinCount; i++) {
uint32_t jointCount = data->skins[i].jointCount;
lovrAssert(jointCount < MAX_BONES, "ModelData skin '%d' has too many joints (%d, max is %d)", i, jointCount, MAX_BONES);
}
model->localTransforms = malloc(sizeof(NodeTransform) * data->nodeCount);
model->globalTransforms = malloc(16 * sizeof(float) * data->nodeCount);
lovrModelResetPose(model);