mirror of https://github.com/raysan5/raylib
Fixed loading obj models with no materials (#1984)
This commit is contained in:
parent
1a6adc5f74
commit
7bf31dd468
21
src/models.c
21
src/models.c
|
@ -3560,13 +3560,22 @@ static Model LoadOBJ(const char *fileName)
|
||||||
model.meshMaterial = (int *)RL_CALLOC(model.meshCount, sizeof(int));
|
model.meshMaterial = (int *)RL_CALLOC(model.meshCount, sizeof(int));
|
||||||
|
|
||||||
// Count the faces for each material
|
// Count the faces for each material
|
||||||
int *matFaces = RL_CALLOC(materialCount, sizeof(int));
|
int *matFaces = RL_CALLOC(model.meshCount, sizeof(int));
|
||||||
|
|
||||||
for (int fi = 0; fi< attrib.num_faces; fi++)
|
// iff no materials are present use all faces on one mesh
|
||||||
|
if (materialCount > 0)
|
||||||
{
|
{
|
||||||
//tinyobj_vertex_index_t face = attrib.faces[fi];
|
for (int fi = 0; fi< attrib.num_faces; fi++)
|
||||||
int idx = attrib.material_ids[fi];
|
{
|
||||||
matFaces[idx]++;
|
//tinyobj_vertex_index_t face = attrib.faces[fi];
|
||||||
|
int idx = attrib.material_ids[fi];
|
||||||
|
matFaces[idx]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
matFaces[0] = attrib.num_faces;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
|
@ -5606,4 +5615,4 @@ static Model LoadVOX(const char *fileName)
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue