Added infinity check for outputting PLY normals

pull/538/head
David Jordan 2015-04-17 23:29:26 -04:00
parent f00101f496
commit e86d40e4e2
1 changed files with 6 additions and 4 deletions

View File

@ -214,6 +214,8 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina
// ------------------------------------------------------------------------------------------------
void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components)
{
static const float inf = std::numeric_limits<float>::infinity();
// If a component (for instance normal vectors) is present in at least one mesh in the scene,
// then default values are written for meshes that do not contain this component.
for (unsigned int i = 0; i < m->mNumVertices; ++i) {
@ -223,11 +225,11 @@ void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components)
m->mVertices[i].z
;
if(components & PLY_EXPORT_HAS_NORMALS) {
if (m->HasNormals() && is_not_qnan(m->mNormals[i].x)) {
if (m->HasNormals() && is_not_qnan(m->mNormals[i].x) && std::absf(m->mNormals[i].x) != inf) {
mOutput <<
" " << m->mNormals[i].x <<
" " << m->mNormals[i].y <<
" " << m->mNormals[i].z;
" " << m->mNormals[i].x <<
" " << m->mNormals[i].y <<
" " << m->mNormals[i].z;
}
else {
mOutput << " 0.0 0.0 0.0";