# 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-9d2fd5bffc1fpull/1/head
parent
649483f97f
commit
32c8ca0a37
|
@ -196,15 +196,15 @@ void PretransformVertices::CollectData( aiScene* pcScene, aiNode* pcNode, unsign
|
||||||
// copy normals, transform them to worldspace
|
// copy normals, transform them to worldspace
|
||||||
for (unsigned int n = 0; n < pcMesh->mNumVertices;++n) {
|
for (unsigned int n = 0; n < pcMesh->mNumVertices;++n) {
|
||||||
pcMeshOut->mNormals[aiCurrent[AI_PTVS_VERTEX]+n] =
|
pcMeshOut->mNormals[aiCurrent[AI_PTVS_VERTEX]+n] =
|
||||||
m * pcMesh->mNormals[n];
|
(m * pcMesh->mNormals[n]).Normalize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (iVFormat & 0x4)
|
if (iVFormat & 0x4)
|
||||||
{
|
{
|
||||||
// copy tangents and bitangents, transform them to worldspace
|
// copy tangents and bitangents, transform them to worldspace
|
||||||
for (unsigned int n = 0; n < pcMesh->mNumVertices;++n) {
|
for (unsigned int n = 0; n < pcMesh->mNumVertices;++n) {
|
||||||
pcMeshOut->mTangents [aiCurrent[AI_PTVS_VERTEX]+n] = m * pcMesh->mTangents[n];
|
pcMeshOut->mTangents [aiCurrent[AI_PTVS_VERTEX]+n] = (m * pcMesh->mTangents[n]).Normalize();
|
||||||
pcMeshOut->mBitangents[aiCurrent[AI_PTVS_VERTEX]+n] = m * pcMesh->mBitangents[n];
|
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()) {
|
if (mesh->HasNormals()) {
|
||||||
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
|
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()) {
|
if (mesh->HasTangentsAndBitangents()) {
|
||||||
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
|
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
|
||||||
mesh->mTangents[i] = m * mesh->mTangents[i];
|
mesh->mTangents[i] = (m * mesh->mTangents[i]).Normalize();
|
||||||
mesh->mBitangents[i] = m * mesh->mBitangents[i];
|
mesh->mBitangents[i] = (m * mesh->mBitangents[i]).Normalize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue