# PretransformVertices step now (re-)normalizes normals and tangents after applying transformations on them. See [https://sourceforge.net/projects/assimp/forums/forum/817653/topic/4378272?message=9501683].

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@912 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2011-03-03 11:36:22 +00:00
parent 649483f97f
commit 32c8ca0a37
1 changed files with 6 additions and 6 deletions

View File

@ -196,15 +196,15 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
// copy normals, transform them to worldspace
for (unsigned int n = 0; n < pcMesh->mNumVertices;++n) {
pcMeshOut->mNormals[aiCurrent[AI_PTVS_VERTEX]+n] =
m * pcMesh->mNormals[n];
(m * pcMesh->mNormals[n]).Normalize();
}
}
if (iVFormat & 0x4)
{
// copy tangents and bitangents, transform them to worldspace
for (unsigned int n = 0; n < pcMesh->mNumVertices;++n) {
pcMeshOut->mTangents [aiCurrent[AI_PTVS_VERTEX]+n] = m * pcMesh->mTangents[n];
pcMeshOut->mBitangents[aiCurrent[AI_PTVS_VERTEX]+n] = m * pcMesh->mBitangents[n];
pcMeshOut->mTangents [aiCurrent[AI_PTVS_VERTEX]+n] = (m * pcMesh->mTangents[n]).Normalize();
pcMeshOut->mBitangents[aiCurrent[AI_PTVS_VERTEX]+n] = (m * pcMesh->mBitangents[n]).Normalize();
}
}
}
@ -334,13 +334,13 @@ void PretransformVertices::ApplyTransform(aiMesh* mesh, const aiMatrix4x4& mat)
if (mesh->HasNormals()) {
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
mesh->mNormals[i] = m * mesh->mNormals[i];
mesh->mNormals[i] = (m * mesh->mNormals[i]).Normalize();
}
}
if (mesh->HasTangentsAndBitangents()) {
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
mesh->mTangents[i] = m * mesh->mTangents[i];
mesh->mBitangents[i] = m * mesh->mBitangents[i];
mesh->mTangents[i] = (m * mesh->mTangents[i]).Normalize();
mesh->mBitangents[i] = (m * mesh->mBitangents[i]).Normalize();
}
}
}