title: Why does assimp fail to generate tangents?
body: <p>I'm using Assimp to load in a model to render in OpenGL (the model is a .obj of the stanford bunny, with only vertex position information, no texture coordinates or normals).  I set the postprocessing flags so that Assimp will generate smooth normals and calculate tangents/bitangents.  However, while I can access the array of normals fine, I get a segfault when I try to access the array of tangents.</p>
  
  <p>Here's the code I use to read the file, and all of my postprocess flags:</p>
  
  <pre><code>const aiScene* scene = importer.ReadFile(filename,
      aiProcess_JoinIdenticalVertices |
      aiProcess_Triangulate |
      aiProcess_GenSmoothNormals |
      aiProcess_CalcTangentSpace |
      //aiProcess_RemoveComponent (remove colors) |
      aiProcess_LimitBoneWeights |
      aiProcess_ImproveCacheLocality |
      aiProcess_RemoveRedundantMaterials |
      aiProcess_GenUVCoords |
      aiProcess_SortByPType |
      aiProcess_FindDegenerates |
      aiProcess_FindInvalidData |
      aiProcess_FindInstances |
      aiProcess_ValidateDataStructure |
      aiProcess_OptimizeMeshes |
      aiProcess_OptimizeGraph |
      aiProcess_Debone |
      0);
  </code></pre>
  
  <p>And here's where I crash:</p>
  
  <pre><code>vert.normal.x = mesh-&gt;mNormals[j].x; // This runs fine
  vert.normal.y = mesh-&gt;mNormals[j].y;
  vert.normal.z = mesh-&gt;mNormals[j].z;
  
  vert.tangent.x = mesh-&gt;mTangents[j].x; // I crash here
  vert.tangent.y = mesh-&gt;mTangents[j].y;
  vert.tangent.z = mesh-&gt;mTangents[j].z;
  </code></pre>
  
  <p>Evidently, it's failing to create the tangents, even though I tell it to.</p>
  
  <p>I tried to use <code>importer.ApplyPostProcessing()</code> to calculate the tangents after the file is read and the other steps are complete, so that it has normals to calculate the tangents with, but I get the same result.</p>