Add support for u8 bone indicies when loading glTF
This commit is contained in:
parent
209445ccde
commit
6c67ef3da0
21
src/models.c
21
src/models.c
|
|
@ -3894,6 +3894,27 @@ static Model LoadGLTF(const char *fileName)
|
||||||
}
|
}
|
||||||
RL_FREE(bones);
|
RL_FREE(bones);
|
||||||
}
|
}
|
||||||
|
else if (acc->component_type == cgltf_component_type_r_8u)
|
||||||
|
{
|
||||||
|
model.meshes[primitiveIndex].boneIds = RL_MALLOC(sizeof(int) * acc->count * 4);
|
||||||
|
unsigned char* bones = RL_MALLOC(sizeof(unsigned char) * acc->count * 4);
|
||||||
|
|
||||||
|
LOAD_ACCESSOR(unsigned char, 4, acc, bones);
|
||||||
|
for (unsigned int a = 0; a < acc->count * 4; a++)
|
||||||
|
{
|
||||||
|
cgltf_node* skinJoint = data->skins->joints[bones[a]];
|
||||||
|
|
||||||
|
for (unsigned int k = 0; k < data->nodes_count; k++)
|
||||||
|
{
|
||||||
|
if (&(data->nodes[k]) == skinJoint)
|
||||||
|
{
|
||||||
|
model.meshes[primitiveIndex].boneIds[a] = k;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RL_FREE(bones);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: Support other size of bone index?
|
// TODO: Support other size of bone index?
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user