From 653449a6a24374a7bdc4fdc85642b6ba4d09ccab Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 11 Feb 2010 11:06:12 +0000 Subject: [PATCH] Fixed the rotation of normals --- src/osg/GLBeginEndAdapter.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/osg/GLBeginEndAdapter.cpp b/src/osg/GLBeginEndAdapter.cpp index 583e95fd9..32f2f51c9 100644 --- a/src/osg/GLBeginEndAdapter.cpp +++ b/src/osg/GLBeginEndAdapter.cpp @@ -210,6 +210,9 @@ void GLBeginEndAdapter::End() const osg::Matrixd& matrix = _matrixStack.back(); if (_mode==APPLY_LOCAL_MATRICES_TO_VERTICES) { + osg::Matrix inverse; + inverse.invert(matrix); + for(Vec3Array::iterator itr = _vertices->begin(); itr != _vertices->end(); ++itr) @@ -223,13 +226,13 @@ void GLBeginEndAdapter::End() itr != _normals->end(); ++itr) { - *itr = osg::Matrixd::transform3x3(matrix, *itr); + *itr = osg::Matrixd::transform3x3(inverse, *itr); (*itr).normalize(); } } else { - _overallNormal = osg::Matrixd::transform3x3(matrix, _overallNormal); + _overallNormal = osg::Matrixd::transform3x3(inverse, _overallNormal); _overallNormal.normalize(); } }