mirror of
https://github.com/raysan5/raylib.git
synced 2025-10-09 03:16:27 +00:00
Fixed loading obj models with no materials (#1984)
This commit is contained in:
11
src/models.c
11
src/models.c
@@ -3560,8 +3560,11 @@ 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));
|
||||||
|
|
||||||
|
// iff no materials are present use all faces on one mesh
|
||||||
|
if (materialCount > 0)
|
||||||
|
{
|
||||||
for (int fi = 0; fi< attrib.num_faces; fi++)
|
for (int fi = 0; fi< attrib.num_faces; fi++)
|
||||||
{
|
{
|
||||||
//tinyobj_vertex_index_t face = attrib.faces[fi];
|
//tinyobj_vertex_index_t face = attrib.faces[fi];
|
||||||
@@ -3569,6 +3572,12 @@ static Model LoadOBJ(const char *fileName)
|
|||||||
matFaces[idx]++;
|
matFaces[idx]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
matFaces[0] = attrib.num_faces;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------
|
//--------------------------------------
|
||||||
// Create the material meshes
|
// Create the material meshes
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user