REVIEWED: ProcessMaterialsOBJ()
available when required
This commit is contained in:
parent
78ae3b38a6
commit
5b3c5e1a16
1 changed files with 13 additions and 11 deletions
|
@ -166,6 +166,9 @@ static Model LoadVOX(const char *filename); // Load VOX mesh data
|
|||
static Model LoadM3D(const char *filename); // Load M3D mesh data
|
||||
static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, unsigned int *animCount); // Load M3D animation data
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_OBJ) || defined(SUPPORT_FILEFORMAT_MTL)
|
||||
static void ProcessMaterialsOBJ(Material *rayMaterials, tinyobj_material_t *materials, int materialCount); // Process obj materials
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition
|
||||
|
@ -1862,10 +1865,9 @@ bool ExportMesh(Mesh mesh, const char *fileName)
|
|||
return success;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_FILEFORMAT_MTL)
|
||||
#if defined(SUPPORT_FILEFORMAT_OBJ) || defined(SUPPORT_FILEFORMAT_MTL)
|
||||
// Process obj materials
|
||||
|
||||
static void ProcessOBJMaterials(Material* rayMaterials, tinyobj_material_t* materials, int materialCount)
|
||||
static void ProcessMaterialsOBJ(Material *rayMaterials, tinyobj_material_t *materials, int materialCount)
|
||||
{
|
||||
// Init model materials
|
||||
for (unsigned int m = 0; m < materialCount; m++)
|
||||
|
@ -1914,8 +1916,8 @@ Material *LoadMaterials(const char *fileName, int *materialCount)
|
|||
int result = tinyobj_parse_mtl_file(&mats, &count, fileName);
|
||||
if (result != TINYOBJ_SUCCESS) TRACELOG(LOG_WARNING, "MATERIAL: [%s] Failed to parse materials file", fileName);
|
||||
|
||||
materials = MemAlloc(sizeof(Material) * count);
|
||||
ProcessOBJMaterials(materials, mats, count);
|
||||
materials = MemAlloc(count*sizeof(Material));
|
||||
ProcessMaterialsOBJ(materials, mats, count);
|
||||
|
||||
tinyobj_materials_free(mats, count);
|
||||
}
|
||||
|
@ -3951,7 +3953,7 @@ static Model LoadOBJ(const char *fileName)
|
|||
// Count the faces for each material
|
||||
int *matFaces = RL_CALLOC(model.meshCount, sizeof(int));
|
||||
|
||||
// iff no materials are present use all faces on one mesh
|
||||
// if no materials are present use all faces on one mesh
|
||||
if (materialCount > 0)
|
||||
{
|
||||
for (unsigned int fi = 0; fi < attrib.num_faces; fi++)
|
||||
|
@ -4027,7 +4029,7 @@ static Model LoadOBJ(const char *fileName)
|
|||
}
|
||||
|
||||
// Init model materials
|
||||
ProcessOBJMaterials(model.materials, materials, materialCount);
|
||||
ProcessMaterialsOBJ(model.materials, materials, materialCount);
|
||||
|
||||
tinyobj_attrib_free(&attrib);
|
||||
tinyobj_shapes_free(meshes, meshCount);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue