diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 39268b0c9..65ee5edb8 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -81,9 +81,16 @@ void Image::deallocateData() int Image::compare(const Image& rhs) const { - if (getFileName()rhs.getFileName()) return 1; - + // if at least one filename is empty, then need to test buffer + // pointers because images could have been created on the fly + // and therefore we can't rely on file names to get an accurate + // comparison + if (getFileName().empty() || rhs.getFileName().empty()) + { + if (_datarhs._data) return 1; + } + // need to test against image contents here... COMPARE_StateAttribute_Parameter(_s) COMPARE_StateAttribute_Parameter(_t) @@ -91,14 +98,15 @@ int Image::compare(const Image& rhs) const COMPARE_StateAttribute_Parameter(_pixelFormat) COMPARE_StateAttribute_Parameter(_dataType) COMPARE_StateAttribute_Parameter(_packing) + COMPARE_StateAttribute_Parameter(_mipmapData) COMPARE_StateAttribute_Parameter(_modifiedCount) - if (_datarhs._data) return 1; - - if (_mipmapDatarhs._mipmapData) return 1; - + // same buffer + same parameters = same image + if (_data == rhs._data) return 0; + + // slowest comparison at the bottom! + COMPARE_StateAttribute_Parameter(getFileName()) + return 0; } diff --git a/src/osg/Texture2D.cpp b/src/osg/Texture2D.cpp index edb4ad5d0..4afe001be 100644 --- a/src/osg/Texture2D.cpp +++ b/src/osg/Texture2D.cpp @@ -81,8 +81,14 @@ int Texture2D::compare(const StateAttribute& sa) const // compare each paramter in turn against the rhs. #if 1 - COMPARE_StateAttribute_Parameter(_textureWidth) - COMPARE_StateAttribute_Parameter(_textureHeight) + if (_textureWidth != 0 && rhs._textureWidth != 0) + { + COMPARE_StateAttribute_Parameter(_textureWidth) + } + if (_textureHeight != 0 && rhs._textureHeight != 0) + { + COMPARE_StateAttribute_Parameter(_textureHeight) + } #endif COMPARE_StateAttribute_Parameter(_subloadCallback)