From e86d40e4e2fb91dbdb898938830783f76e8ee00f Mon Sep 17 00:00:00 2001 From: David Jordan Date: Fri, 17 Apr 2015 23:29:26 -0400 Subject: [PATCH] Added infinity check for outputting PLY normals --- code/PlyExporter.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/PlyExporter.cpp b/code/PlyExporter.cpp index 32cb61058..6f86c6b8e 100644 --- a/code/PlyExporter.cpp +++ b/code/PlyExporter.cpp @@ -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::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";