]> git.mxchange.org Git - simgear.git/commitdiff
Fix bug where two references to a png object mask used against
authorStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Fri, 6 Jul 2012 20:38:15 +0000 (21:38 +0100)
committerStuart Buchanan <stuart_d_buchanan@yahoo.co.uk>
Fri, 6 Jul 2012 20:38:15 +0000 (21:38 +0100)
a dds terrain texture resulted in the object mask being flipped twice,
having no overall effect!

simgear/scene/material/mat.cxx

index cc22600a8e80661c0746d35bfa7300d3ea7f9c6c..6152cc554fdf0cd1f26273e4db92046a3ebf2a9d 100644 (file)
@@ -238,8 +238,11 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
                     if (dds[i] != dds_mask) {
                         // Texture format does not match mask format. This is relevant for
                         // the object mask, as DDS textures have an origin at the bottom
-                        // left rather than top left, therefore we flip the object mask
-                        // vertically.
+                        // left rather than top left. Therefore we flip a copy of the image
+                        // (otherwise a second reference to the object mask would flip it
+                        // back!).                
+                        SG_LOG(SG_GENERAL, SG_DEBUG, "Flipping object mask" << omname);  
+                        image = (osg::Image* ) image->clone(osg::CopyOp::SHALLOW_COPY);
                         image->flipVertical();
                     }