瀏覽代碼

Fixed loading obj models with no materials (#1984)

pull/1985/head
Tristan Schulz 3 年之前
committed by GitHub
父節點
當前提交
7bf31dd468
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 1 個文件被更改,包括 15 次插入6 次删除
  1. +15
    -6
      src/models.c

+ 15
- 6
src/models.c 查看文件

@ -3560,13 +3560,22 @@ static Model LoadOBJ(const char *fileName)
model.meshMaterial = (int *)RL_CALLOC(model.meshCount, sizeof(int));
// 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)
{
for (int fi = 0; fi< attrib.num_faces; fi++)
{
//tinyobj_vertex_index_t face = attrib.faces[fi];
int idx = attrib.material_ids[fi];
matFaces[idx]++;
}
}
else
{
//tinyobj_vertex_index_t face = attrib.faces[fi];
int idx = attrib.material_ids[fi];
matFaces[idx]++;
matFaces[0] = attrib.num_faces;
}
//--------------------------------------
@ -5606,4 +5615,4 @@ static Model LoadVOX(const char *fileName)
return model;
}
#endif
#endif

Loading…
取消
儲存