Allow materials to not have some properties
[opengl.git] / model.cpp
index a11a0745dd9d4b8d41da1c8a3809fa34384e1037..3c1ecf4830c2ce95989a09bfb4935cfb7d21d767 100644 (file)
--- a/model.cpp
+++ b/model.cpp
@@ -241,6 +241,9 @@ void Model::Node::draw(     const std::vector<Mesh> &meshes,
                for (std::pair<std::string, std::pair<unsigned int, glm::mat4>> pair: mesh.boneMap) {
 
                        std::string nodeName = pair.first;
+
+                       if (animMap->count(nodeName) <= 0) break;
+
                        unsigned int boneId = pair.second.first;
                        // This is actually an inverse-bind matrix
                        // i.e. position of the mesh in bone space
@@ -301,7 +304,7 @@ Model::Model(const aiScene *scene, Program p): program(p) {
        }
 
        // TODO: handle default material inserted at the end by assimp
-       for (unsigned int i = 0; i < scene->mNumMaterials - 1; i++) {
+       for (unsigned int i = 0; i < scene->mNumMaterials; i++) {
                const aiMaterial &material = *scene->mMaterials[i];
                materials.push_back(Material(material, *scene, p.progId));
        }