From 89cf88f2a9fb8f3484026f64fa5864daa650c91e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 9 Feb 2012 14:11:36 +0000 Subject: [PATCH] From Chris Denham, "This is a submission to fix a problem with use of mode GL_RESCALE_NORMAL for geometries below a scaling transform which is not equal in X, Y & Z components. In this case, the 'slow' method of mode GL_NORMALIZE should be used to perform the normalization. I have attached a correction to daeRTransforms.cpp based on trunk at [12892] which corrects this problem. This is the changed section: Code: if (scale.x() == scale.y() && scale.y() == scale.z()) { // This mode may be quicker than GL_NORMALIZE, but ONLY works if x, y & z components of scale are the same. ss->setMode(GL_RESCALE_NORMAL, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); } else { // This mode may be slower than GL_RESCALE_NORMAL, but does work if x, y & z components of scale are not the same. ss->setMode(GL_NORMALIZE, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); }" --- src/osgPlugins/dae/daeRTransforms.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/osgPlugins/dae/daeRTransforms.cpp b/src/osgPlugins/dae/daeRTransforms.cpp index 33ffefe06..a656c50dc 100644 --- a/src/osgPlugins/dae/daeRTransforms.cpp +++ b/src/osgPlugins/dae/daeRTransforms.cpp @@ -223,7 +223,16 @@ osg::Transform* daeReader::processOsgMatrixTransform(domNode *node, bool isBone) if ((scale.x() != 1) || (scale.y() != 1) || (scale.z() != 1)) { osg::StateSet* ss = resultNode->getOrCreateStateSet(); - ss->setMode(GL_RESCALE_NORMAL, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); + if (scale.x() == scale.y() && scale.y() == scale.z()) + { + // This mode may be quicker than GL_NORMALIZE, but ONLY works if x, y & z components of scale are the same. + ss->setMode(GL_RESCALE_NORMAL, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); + } + else + { + // This mode may be slower than GL_RESCALE_NORMAL, but does work if x, y & z components of scale are not the same. + ss->setMode(GL_NORMALIZE, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE); + } } return resultNode;