@@ -125,13 +125,11 @@ namespace our {
125125 }
126126
127127 our::Mesh* ourMesh = new our::Mesh (vertices, indices);
128+ std::string name = std::to_string (id) + " _" + std::to_string (mesh->mMaterialIndex );
128129
129- aiMaterial* aiMaterial = scene->mMaterials [mesh->mMaterialIndex ];
130- std::string matName = aiMaterial->GetName ().C_Str ();
131- Material* material = AssetLoader<Material>::get (matName + std::to_string (id));
130+ Material* material = AssetLoader<Material>::get (name);
132131 if (!material) {
133- std::cerr << " \033 [31mFailed to load material " << matName << " for mesh " << mesh->mName .C_Str ()
134- << " \033 [0m" << std::endl;
132+ std::cerr << " \033 [31mFailed to load material for mesh " << mesh->mName .C_Str () << " \033 [0m" << std::endl;
135133 material = new Material (); // fallback to default material
136134 }
137135
@@ -144,11 +142,10 @@ namespace our {
144142 void Model::loadMaterialsFromScene (const aiScene* scene) {
145143 for (unsigned int i = 0 ; i < scene->mNumMaterials ; ++i) {
146144 aiMaterial* mat = scene->mMaterials [i];
147- Material* material = loadMaterial (scene, mat);
145+ LitMaterial* material = loadMaterial (scene, mat);
146+ std::string name = std::to_string (id) + " _" + std::to_string (i);
148147 if (material) {
149- aiString matName;
150- mat->Get (AI_MATKEY_NAME , matName);
151- AssetLoader<Material>::add (matName.C_Str () + std::to_string (id), material);
148+ AssetLoader<Material>::add (name, material);
152149 }
153150 }
154151 }
0 commit comments