GenVertexNormal bugfix. Angle limit wasn't correct.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@119 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
cae8563764
commit
ad4cc033d8
|
@ -64,7 +64,7 @@ using namespace Assimp;
|
|||
// Constructor to be privately used by Importer
|
||||
CalcTangentsProcess::CalcTangentsProcess()
|
||||
{
|
||||
// nothing to do here
|
||||
this->configMaxAngle = AI_DEG_TO_RAD(45.f);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -87,7 +87,7 @@ void CalcTangentsProcess::SetupProperties(const Importer* pImp)
|
|||
{
|
||||
// get the current value of the property
|
||||
this->configMaxAngle = pImp->GetPropertyFloat(AI_CONFIG_PP_CT_MAX_SMOOTHING_ANGLE,45.f);
|
||||
this->configMaxAngle = std::max(std::min(this->configMaxAngle,180.0f),0.0f);
|
||||
this->configMaxAngle = std::max(std::min(this->configMaxAngle,45.0f),0.0f);
|
||||
this->configMaxAngle = AI_DEG_TO_RAD(this->configMaxAngle);
|
||||
}
|
||||
|
||||
|
@ -205,6 +205,8 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh)
|
|||
SpatialSort vertexFinder( meshPos, pMesh->mNumVertices, sizeof( aiVector3D));
|
||||
std::vector<unsigned int> verticesFound;
|
||||
|
||||
const float fLimit = cosf(this->configMaxAngle);
|
||||
|
||||
// in the second pass we now smooth out all tangents and bitangents at the same local position
|
||||
// if they are not too far off.
|
||||
std::vector<bool> vertexDone( pMesh->mNumVertices, false);
|
||||
|
@ -231,9 +233,9 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh)
|
|||
continue;
|
||||
if( meshNorm[idx] * origNorm < angleEpsilon)
|
||||
continue;
|
||||
if( acosf( meshTang[idx] * origTang) > this->configMaxAngle)
|
||||
if( meshTang[idx] * origTang < fLimit)
|
||||
continue;
|
||||
if( acosf( meshBitang[idx] * origBitang) > this->configMaxAngle)
|
||||
if( meshBitang[idx] * origBitang < fLimit)
|
||||
continue;
|
||||
|
||||
// it's similar enough -> add it to the smoothing group
|
||||
|
|
|
@ -85,6 +85,13 @@ public:
|
|||
*/
|
||||
void SetupProperties(const Importer* pImp);
|
||||
|
||||
|
||||
// setter for configMaxAngle
|
||||
inline void SetMaxSmoothAngle(float f)
|
||||
{
|
||||
configMaxAngle =f;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
|
|
@ -53,15 +53,16 @@ using namespace Assimp;
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
GenFaceNormalsProcess::GenFaceNormalsProcess()
|
||||
{
|
||||
}
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
GenFaceNormalsProcess::~GenFaceNormalsProcess()
|
||||
{
|
||||
{
|
||||
// nothing to do here
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the processing step is present in the given flag field.
|
||||
|
@ -110,6 +111,7 @@ bool GenFaceNormalsProcess::GenMeshFaceNormals (aiMesh* pMesh)
|
|||
aiVector3D pDelta1 = *pV2 - *pV1;
|
||||
aiVector3D pDelta2 = *pV3 - *pV1;
|
||||
aiVector3D vNor = pDelta1 ^ pDelta2;
|
||||
vNor.Normalize();
|
||||
|
||||
//if (face.mIndices[1] > face.mIndices[2])
|
||||
// vNor *= -1.0f;
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -89,6 +89,13 @@ public:
|
|||
*/
|
||||
void Execute( aiScene* pScene);
|
||||
|
||||
|
||||
// setter for configMaxAngle
|
||||
inline void SetMaxSmoothAngle(float f)
|
||||
{
|
||||
configMaxAngle =f;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
|
|
@ -123,10 +123,10 @@ void ComputeNormalsWithSmoothingsGroups(MeshWithSmoothingGroups<T>& sMesh)
|
|||
a != poResult.end();++a)
|
||||
{
|
||||
vNormals += sMesh.mNormals[(*a)];
|
||||
fDiv += 1.0f;
|
||||
//fDiv += 1.0f;
|
||||
}
|
||||
vNormals.x /= fDiv;vNormals.y /= fDiv;vNormals.z /= fDiv;
|
||||
//vNormals.Normalize();
|
||||
//vNormals.x /= fDiv;vNormals.y /= fDiv;vNormals.z /= fDiv;
|
||||
vNormals.Normalize();
|
||||
avNormals[(*i).mIndices[c]] = vNormals;
|
||||
//poResult.clear();
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*
|
||||
* This applies to the CalcTangentSpace-Step. The angle is specified
|
||||
* in degrees , so 180 is PI. The default value is
|
||||
* 45 degrees. The maximum value is 180.
|
||||
* 45 degrees. The maximum value is 175.
|
||||
* Property type: float.
|
||||
*/
|
||||
#define AI_CONFIG_PP_CT_MAX_SMOOTHING_ANGLE "pp.ct.max_smoothing"
|
||||
|
@ -139,7 +139,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*
|
||||
* This applies to the GenSmoothNormals-Step. The angle is specified
|
||||
* in degrees, so 180 is PI. The default value is
|
||||
* 180 degrees (all vertex normals are smoothed). The maximum value is 180
|
||||
* 180 degrees (all vertex normals are smoothed). The maximum value is 175
|
||||
* Property type: float.
|
||||
*/
|
||||
#define AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE "pp.gsn.max_smoothing"
|
||||
|
|
Loading…
Reference in New Issue