Skip to content

Commit 7119a76

Browse files
gregoire-dlcbentejac
authored andcommitted
[mesh] Mesh: Fix mesh loading with material(s) but without texture files
1 parent 4db3059 commit 7119a76

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/aliceVision/mesh/Mesh.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,15 +2617,16 @@ void Mesh::load(const std::string& filepath, bool mergeCoincidentVerts, Material
26172617
const std::unordered_set<int> materialIds = std::unordered_set<int>(_trisMtlIds.begin(), _trisMtlIds.end());
26182618
nmtls = static_cast<int>(materialIds.size());
26192619

2620-
// store textures per atlas
2621-
if (material != nullptr)
2620+
// get material related properties
2621+
if (material != nullptr && scene->mNumMaterials > 1)
26222622
{
26232623
// get material properties from the first material as they are shared across all others
26242624
scene->mMaterials[1]->Get(AI_MATKEY_COLOR_AMBIENT, material->ambient);
26252625
scene->mMaterials[1]->Get(AI_MATKEY_COLOR_DIFFUSE, material->diffuse);
26262626
scene->mMaterials[1]->Get(AI_MATKEY_COLOR_SPECULAR, material->specular);
26272627
scene->mMaterials[1]->Get(AI_MATKEY_SHININESS, material->shininess);
26282628

2629+
// get textures from the next materials
26292630
for (int id : materialIds)
26302631
{
26312632
aiString diffuse;
@@ -2654,10 +2655,13 @@ void Mesh::load(const std::string& filepath, bool mergeCoincidentVerts, Material
26542655
}
26552656
}
26562657

2657-
ALICEVISION_LOG_DEBUG("Vertices: " << pts.size());
2658-
ALICEVISION_LOG_DEBUG("Triangles: " << tris.size());
2659-
ALICEVISION_LOG_DEBUG("UVs: " << uvCoords.size());
2660-
ALICEVISION_LOG_DEBUG("Num Materials: " + std::to_string(nmtls));
2658+
// log mesh information
2659+
ALICEVISION_LOG_DEBUG("Mesh information:" << std::endl
2660+
<< "\t- # vertices: " << pts.size() << std::endl
2661+
<< "\t- # triangles: " << tris.size() << std::endl
2662+
<< "\t- # UVs: " << uvCoords.size() << std::endl
2663+
<< "\t- # normals: " << normals.size() << std::endl
2664+
<< "\t- # materials: " << nmtls);
26612665
}
26622666

26632667
bool Mesh::getEdgeNeighTrisInterval(Pixel& itr, Pixel& edge, StaticVector<Voxel>& edgesXStat, StaticVector<Voxel>& edgesXYStat)

0 commit comments

Comments
 (0)