mirror of
https://github.com/openharmony/third_party_meshoptimizer.git
synced 2026-07-19 20:03:59 -04:00
Merge pull request #641 from zeux/obj-mtl
gltfpack: Warn when some materials could not be loaded from the .obj/.mtl
This commit is contained in:
Vendored
+6
@@ -65,6 +65,9 @@ typedef struct
|
||||
float d; /* Disolve (alpha) */
|
||||
int illum; /* Illumination model */
|
||||
|
||||
/* Set for materials that don't come from the associated mtllib */
|
||||
int fallback;
|
||||
|
||||
/* Texture maps */
|
||||
fastObjTexture map_Ka;
|
||||
fastObjTexture map_Kd;
|
||||
@@ -872,6 +875,8 @@ fastObjMaterial mtl_default(void)
|
||||
mtl.d = 1.0;
|
||||
mtl.illum = 1;
|
||||
|
||||
mtl.fallback = 0;
|
||||
|
||||
mtl.map_Ka = map_default();
|
||||
mtl.map_Kd = map_default();
|
||||
mtl.map_Ks = map_default();
|
||||
@@ -919,6 +924,7 @@ const char* parse_usemtl(fastObjData* data, const char* ptr)
|
||||
{
|
||||
fastObjMaterial new_mtl = mtl_default();
|
||||
new_mtl.name = string_copy(s, e);
|
||||
new_mtl.fallback = 1;
|
||||
array_push(data->mesh->materials, new_mtl);
|
||||
}
|
||||
|
||||
|
||||
@@ -282,6 +282,13 @@ cgltf_data* parseObj(const char* path, std::vector<Mesh>& meshes, const char** e
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int fallback_materials = 0;
|
||||
for (unsigned int mi = 0; mi < obj->material_count; ++mi)
|
||||
fallback_materials += obj->materials[mi].fallback;
|
||||
|
||||
if (fallback_materials)
|
||||
fprintf(stderr, "Warning: %d/%d materials could not be loaded from mtllib\n", fallback_materials, obj->material_count);
|
||||
|
||||
cgltf_data* data = (cgltf_data*)calloc(1, sizeof(cgltf_data));
|
||||
data->memory.free_func = defaultFree;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user