pull/541/head
Kim Kulling 2015-04-18 19:17:19 +02:00
commit 68ca2ca427
1 changed files with 9 additions and 5 deletions

View File

@ -44,11 +44,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "PlyExporter.h"
#include <boost/scoped_ptr.hpp>
#include <cmath>
#include "Exceptional.h"
#include "../include/assimp/scene.h"
#include "../include/assimp/version.h"
#include "../include/assimp/IOSystem.hpp"
#include "../include/assimp/Exporter.hpp"
#include "../include/assimp/Exporter.hpp"
#include "qnan.h"
using namespace Assimp;
@ -213,6 +215,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) {
@ -222,11 +226,11 @@ void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components)
m->mVertices[i].z
;
if(components & PLY_EXPORT_HAS_NORMALS) {
if (m->HasNormals()) {
if (m->HasNormals() && is_not_qnan(m->mNormals[i].x) && std::fabs(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";