From 8aefce45246f7ace18e284dd550f21a67b6af4f2 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 16 Oct 2001 15:03:10 +0000 Subject: [PATCH] Fixed then normal smoothing function in the .3ds loader and the osgUtil::SmoothingVisitor so that unused normals at left at 0,0,0 insead of being normalized, which results in (nan,nan,nan). --- src/osgPlugins/lib3ds/ReaderWriter3DS.cpp | 4 +++- src/osgUtil/SmoothingVisitor.cpp | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/osgPlugins/lib3ds/ReaderWriter3DS.cpp b/src/osgPlugins/lib3ds/ReaderWriter3DS.cpp index 0c086a78c..c2dfbeb47 100644 --- a/src/osgPlugins/lib3ds/ReaderWriter3DS.cpp +++ b/src/osgPlugins/lib3ds/ReaderWriter3DS.cpp @@ -391,7 +391,9 @@ osg::GeoSet* ReaderWriter3DS::createGeoSet(Lib3dsMesh *m,FaceList& faceList) // normalize the normal list to unit length normals. for (i=0; isetNormals(osg_normals,osg_indices); diff --git a/src/osgUtil/SmoothingVisitor.cpp b/src/osgUtil/SmoothingVisitor.cpp index e43e6b135..87f476a7e 100644 --- a/src/osgUtil/SmoothingVisitor.cpp +++ b/src/osgUtil/SmoothingVisitor.cpp @@ -119,7 +119,8 @@ void SmoothingVisitor::smooth(osg::GeoSet& gset) for(j = 0; j < ncoords; j++ ) { - norms[j].normalize(); + float len = norms[j].length(); + if (len) norms[j]/=len; } gset.setNormalBinding(osg::GeoSet::BIND_PERVERTEX);