From db329cf943421b1940c62550029c0ccb5beba400 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 28 Sep 2011 11:52:27 +0000 Subject: [PATCH] Added catch for NaN vertices that were being generated by osgText, these NaN vertices were causing glu tesselation functions to crash. --- src/osgUtil/Tessellator.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/osgUtil/Tessellator.cpp b/src/osgUtil/Tessellator.cpp index c060157b3..e09060d9d 100644 --- a/src/osgUtil/Tessellator.cpp +++ b/src/osgUtil/Tessellator.cpp @@ -14,6 +14,7 @@ #include #include +#include #include using namespace osg; @@ -63,12 +64,19 @@ void Tessellator::addVertex(osg::Vec3* vertex) { if (_tobj) { - Vec3d* data = new Vec3d; - _coordData.push_back(data); - (*data)._v[0]=(*vertex)[0]; - (*data)._v[1]=(*vertex)[1]; - (*data)._v[2]=(*vertex)[2]; - gluTessVertex(_tobj,data->_v,vertex); + if (vertex && vertex->valid()) + { + Vec3d* data = new Vec3d; + _coordData.push_back(data); + (*data)._v[0]=(*vertex)[0]; + (*data)._v[1]=(*vertex)[1]; + (*data)._v[2]=(*vertex)[2]; + gluTessVertex(_tobj,data->_v,vertex); + } + else + { + OSG_INFO<<"Tessellator::addVertex("<<*vertex<<") detected NaN, ignoring vertex."<