Changed assimp to force regeneration of normals.
parent
bdbad4c64f
commit
c6eda67296
|
@ -106,7 +106,8 @@ void GenFaceNormalsProcess::Execute( aiScene* pScene)
|
||||||
bool GenFaceNormalsProcess::GenMeshFaceNormals (aiMesh* pMesh)
|
bool GenFaceNormalsProcess::GenMeshFaceNormals (aiMesh* pMesh)
|
||||||
{
|
{
|
||||||
if (NULL != pMesh->mNormals) {
|
if (NULL != pMesh->mNormals) {
|
||||||
return false;
|
// return false;
|
||||||
|
delete[] pMesh->mNormals;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the mesh consists of lines and/or points but not of
|
// If the mesh consists of lines and/or points but not of
|
||||||
|
@ -135,8 +136,19 @@ bool GenFaceNormalsProcess::GenMeshFaceNormals (aiMesh* pMesh)
|
||||||
const aiVector3D* pV1 = &pMesh->mVertices[face.mIndices[0]];
|
const aiVector3D* pV1 = &pMesh->mVertices[face.mIndices[0]];
|
||||||
const aiVector3D* pV2 = &pMesh->mVertices[face.mIndices[1]];
|
const aiVector3D* pV2 = &pMesh->mVertices[face.mIndices[1]];
|
||||||
const aiVector3D* pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices-1]];
|
const aiVector3D* pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices-1]];
|
||||||
|
|
||||||
|
auto pV12 = *pV2 - *pV1;
|
||||||
|
auto pV31 = *pV3 - *pV1;
|
||||||
|
|
||||||
const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).Normalize();
|
const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).Normalize();
|
||||||
|
|
||||||
|
if (std::isnan(vNor.x) || std::isnan(vNor.y) || std::isnan(vNor.z)) {
|
||||||
|
for (unsigned int i = 0; i < face.mNumIndices; ++i) {
|
||||||
|
pMesh->mNormals[face.mIndices[i]] = aiVector3D(0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0;i < face.mNumIndices;++i) {
|
for (unsigned int i = 0;i < face.mNumIndices;++i) {
|
||||||
pMesh->mNormals[face.mIndices[i]] = vNor;
|
pMesh->mNormals[face.mIndices[i]] = vNor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,10 @@ void GenVertexNormalsProcess::Execute( aiScene* pScene)
|
||||||
// Executes the post processing step on the given imported data.
|
// Executes the post processing step on the given imported data.
|
||||||
bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int meshIndex)
|
bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int meshIndex)
|
||||||
{
|
{
|
||||||
if (NULL != pMesh->mNormals)
|
if (NULL != pMesh->mNormals) {
|
||||||
return false;
|
delete[] pMesh->mNormals;
|
||||||
|
}
|
||||||
|
// return false;
|
||||||
|
|
||||||
// If the mesh consists of lines and/or points but not of
|
// If the mesh consists of lines and/or points but not of
|
||||||
// triangles or higher-order polygons the normal vectors
|
// triangles or higher-order polygons the normal vectors
|
||||||
|
|
Loading…
Reference in New Issue