Fix forgot to save bone ids

This commit is contained in:
MrScautHD 2023-11-18 12:02:50 +01:00
parent 74d773f6c8
commit 72fc3e70db

View File

@ -5156,49 +5156,49 @@ static Model LoadGLTF(const char *fileName)
if ((attribute->component_type == cgltf_component_type_r_8u) && (attribute->type == cgltf_type_vec4)) if ((attribute->component_type == cgltf_component_type_r_8u) && (attribute->type == cgltf_type_vec4))
{ {
// Handle 8-bit unsigned byte, vec4 format // Handle 8-bit unsigned byte, vec4 format
RL_CALLOC(model.meshes[meshIndex].vertexCount * 4, sizeof(unsigned char)); model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount * 4, sizeof(unsigned char));
LOAD_ATTRIBUTE(attribute, 4, unsigned char, model.meshes[meshIndex].customAttribute) LOAD_ATTRIBUTE(attribute, 4, unsigned char, model.meshes[meshIndex].customAttribute)
} }
else if ((attribute->component_type == cgltf_component_type_r_8s) && (attribute->type == cgltf_type_scalar)) else if ((attribute->component_type == cgltf_component_type_r_8s) && (attribute->type == cgltf_type_scalar))
{ {
// Handle 8-bit signed byte, scalar format // Handle 8-bit signed byte, scalar format
RL_CALLOC(model.meshes[meshIndex].vertexCount, sizeof(char)); model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount, sizeof(char));
LOAD_ATTRIBUTE(attribute, 1, char, model.meshes[meshIndex].customScalarAttribute) LOAD_ATTRIBUTE(attribute, 1, char, model.meshes[meshIndex].customScalarAttribute)
} }
else if ((attribute->component_type == cgltf_component_type_r_16u) && (attribute->type == cgltf_type_vec2)) else if ((attribute->component_type == cgltf_component_type_r_16u) && (attribute->type == cgltf_type_vec2))
{ {
// Handle 16-bit unsigned short, vec2 format // Handle 16-bit unsigned short, vec2 format
RL_CALLOC(model.meshes[meshIndex].vertexCount * 2, sizeof(unsigned short)); model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount * 2, sizeof(unsigned short));
LOAD_ATTRIBUTE(attribute, 2, unsigned short, model.meshes[meshIndex].customAttribute) LOAD_ATTRIBUTE(attribute, 2, unsigned short, model.meshes[meshIndex].customAttribute)
} }
else if ((attribute->component_type == cgltf_component_type_r_16s) && (attribute->type == cgltf_type_vec3)) else if ((attribute->component_type == cgltf_component_type_r_16s) && (attribute->type == cgltf_type_vec3))
{ {
// Handle 16-bit signed short, vec3 format // Handle 16-bit signed short, vec3 format
RL_CALLOC(model.meshes[meshIndex].vertexCount * 3, sizeof(short)); model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount * 3, sizeof(short));
LOAD_ATTRIBUTE(attribute, 3, short, model.meshes[meshIndex].customAttribute) LOAD_ATTRIBUTE(attribute, 3, short, model.meshes[meshIndex].customAttribute)
} }
else if ((attribute->component_type == cgltf_component_type_r_32u) && (attribute->type == cgltf_type_vec4)) else if ((attribute->component_type == cgltf_component_type_r_32u) && (attribute->type == cgltf_type_vec4))
{ {
// Handle 32-bit unsigned int, vec4 format // Handle 32-bit unsigned int, vec4 format
RL_CALLOC(model.meshes[meshIndex].vertexCount * 4, sizeof(unsigned int)); model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount * 4, sizeof(unsigned int));
LOAD_ATTRIBUTE(attribute, 4, unsigned int, model.meshes[meshIndex].customAttribute) LOAD_ATTRIBUTE(attribute, 4, unsigned int, model.meshes[meshIndex].customAttribute)
} }
else if ((attribute->component_type == cgltf_component_type_r_32s) && (attribute->type == cgltf_type_scalar)) else if ((attribute->component_type == cgltf_component_type_r_32s) && (attribute->type == cgltf_type_scalar))
{ {
// Handle 32-bit signed int, scalar format // Handle 32-bit signed int, scalar format
RL_CALLOC(model.meshes[meshIndex].vertexCount, sizeof(int)); model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount, sizeof(int));
LOAD_ATTRIBUTE(attribute, 1, int, model.meshes[meshIndex].customScalarAttribute) LOAD_ATTRIBUTE(attribute, 1, int, model.meshes[meshIndex].customScalarAttribute)
} }
else if ((attribute->component_type == cgltf_component_type_r_32f) && (attribute->type == cgltf_type_vec2)) else if ((attribute->component_type == cgltf_component_type_r_32f) && (attribute->type == cgltf_type_vec2))
{ {
// Handle 32-bit float, vec2 format // Handle 32-bit float, vec2 format
RL_CALLOC(model.meshes[meshIndex].vertexCount * 2, sizeof(float)); model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount * 2, sizeof(float));
LOAD_ATTRIBUTE(attribute, 2, float, model.meshes[meshIndex].customAttribute) LOAD_ATTRIBUTE(attribute, 2, float, model.meshes[meshIndex].customAttribute)
} }
else if ((attribute->component_type == cgltf_component_type_r_64f) && (attribute->type == cgltf_type_vec3)) else if ((attribute->component_type == cgltf_component_type_r_64f) && (attribute->type == cgltf_type_vec3))
{ {
// Handle 64-bit double, vec3 format // Handle 64-bit double, vec3 format
RL_CALLOC(model.meshes[meshIndex].vertexCount * 3, sizeof(double)); model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount * 3, sizeof(double));
LOAD_ATTRIBUTE(attribute, 3, double, model.meshes[meshIndex].customAttribute) LOAD_ATTRIBUTE(attribute, 3, double, model.meshes[meshIndex].customAttribute)
} }
else TRACELOG(LOG_WARNING, "MODEL: [%s] Joint attribute data format not supported", fileName); else TRACELOG(LOG_WARNING, "MODEL: [%s] Joint attribute data format not supported", fileName);