ObjExporter: cleanup code. Fix bug writing normal: normals would not be transformed by world transform.

pull/363/head
Alexander Gessler 2014-06-17 14:15:48 +02:00
parent 247f5cee3a
commit 244f981f6a
1 changed files with 11 additions and 12 deletions

View File

@ -258,14 +258,12 @@ void ObjExporter :: WriteGeometryFile()
}
}
// ------------------------------------------------------------------------------------------------
int ObjExporter::vecIndexMap::getIndex(const aiVector3D& vec)
{
vecIndexMap::dataType::iterator vertIt = vecMap.find(vec);
if(vertIt != vecMap.end()){// vertex already exists, so reference it
// vertex already exists, so reference it
if(vertIt != vecMap.end()){
return vertIt->second;
}
vecMap[vec] = mNextIndex;
@ -274,6 +272,7 @@ int ObjExporter::vecIndexMap::getIndex(const aiVector3D& vec)
return ret;
}
// ------------------------------------------------------------------------------------------------
void ObjExporter::vecIndexMap::getVectors( std::vector<aiVector3D>& vecs )
{
vecs.resize(vecMap.size());
@ -282,7 +281,6 @@ void ObjExporter::vecIndexMap::getVectors( std::vector<aiVector3D>& vecs )
}
}
// ------------------------------------------------------------------------------------------------
void ObjExporter :: AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat)
{
@ -317,7 +315,8 @@ void ObjExporter :: AddMesh(const aiString& name, const aiMesh* m, const aiMatri
face.indices[a].vp = vpMap.getIndex(vert);
if (m->mNormals) {
face.indices[a].vn = vnMap.getIndex(m->mNormals[idx]);
aiVector3D norm = aiMatrix3x3(mat) * m->mNormals[idx];
face.indices[a].vn = vnMap.getIndex(norm);
}
else{
face.indices[a].vn = 0;