GenVertexNormal bugfix. Angle limit wasn't correct.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@119 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
aramis_acg
2008-08-28 23:49:20 +00:00
parent cae8563764
commit ad4cc033d8
7 changed files with 36 additions and 17 deletions

View File

@@ -56,6 +56,7 @@ using namespace Assimp;
// Constructor to be privately used by Importer
GenVertexNormalsProcess::GenVertexNormalsProcess()
{
this->configMaxAngle = AI_DEG_TO_RAD(175.f);
}
// ------------------------------------------------------------------------------------------------
@@ -76,8 +77,8 @@ bool GenVertexNormalsProcess::IsActive( unsigned int pFlags) const
void GenVertexNormalsProcess::SetupProperties(const Importer* pImp)
{
// get the current value of the property
this->configMaxAngle = pImp->GetPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,180.f);
this->configMaxAngle = std::max(std::min(this->configMaxAngle,180.0f),0.0f);
this->configMaxAngle = pImp->GetPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,175.f);
this->configMaxAngle = std::max(std::min(this->configMaxAngle,175.0f),0.0f);
this->configMaxAngle = AI_DEG_TO_RAD(this->configMaxAngle);
}
// ------------------------------------------------------------------------------------------------
@@ -145,7 +146,7 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh)
SpatialSort vertexFinder( pMesh->mVertices, pMesh->mNumVertices, sizeof( aiVector3D));
std::vector<unsigned int> verticesFound;
const float fLimit = this->configMaxAngle;
const float fLimit = cosf(this->configMaxAngle);
aiVector3D* pcNew = new aiVector3D[pMesh->mNumVertices];
for (unsigned int i = 0; i < pMesh->mNumVertices;++i)
@@ -162,7 +163,7 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh)
unsigned int vidx = verticesFound[a];
// check whether the angle between the two normals is not too large
if (acosf(pMesh->mNormals[vidx] * pMesh->mNormals[i]) > fLimit)
if (pMesh->mNormals[vidx] * pMesh->mNormals[i] < fLimit)
continue;
pcNor += pMesh->mNormals[vidx];