]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/SGScaleTransform.cxx
Work around apparent OSG 3.2.0 normal binding bug.
[simgear.git] / simgear / scene / model / SGScaleTransform.cxx
index ab9d6215742674e8a9dfde02438927d36bd5b620..0fe7443d5553e9bf0f38170053bbb2d99084b4f3 100644 (file)
@@ -27,6 +27,8 @@
 #include <osgDB/Input>
 #include <osgDB/Output>
 
+#include <simgear/scene/util/OsgMath.hxx>
+
 #include "SGScaleTransform.hxx"
 
 SGScaleTransform::SGScaleTransform() :
@@ -35,6 +37,11 @@ SGScaleTransform::SGScaleTransform() :
   _boundScale(1)
 {
   setReferenceFrame(RELATIVE_RF);
+  // see osg::Transform doc: If the transformation matrix scales the subgraph
+  // then the normals of the underlying geometry will need to be renormalized
+  // to be unit vectors once more.
+  osg::StateSet* stateset = getOrCreateStateSet();
+  stateset->setMode(GL_NORMALIZE, osg::StateAttribute::ON);
 }
 
 SGScaleTransform::SGScaleTransform(const SGScaleTransform& scale,