Hi Miha,
Thanks for spotting and resolving this bug. I have done a quick review of
the proposed serializer but at this point haven't done a close enough
review to figure out the consequences for backwards compatibility of this
change. Any thoughts on this?
To resolve the bug I have merged your other changes with a small tweak and
comparing the bit mask result against !=0 rather than the repeating the
enum. This little tweak reduces the amount of code and should make it less
likely a copy and paste style bug might creep in at a later date.
The changes that I went for are:
$ svn diff
Index: src/osgWrappers/serializers/osg/Camera.cpp
===================================================================
--- src/osgWrappers/serializers/osg/Camera.cpp (revision 14710)
+++ src/osgWrappers/serializers/osg/Camera.cpp (working copy)
@@ -143,10 +143,10 @@
else
{
std::string maskString;
- if ( mask==GL_COLOR_BUFFER_BIT ) maskString +=
std::string("COLOR|");
- if ( mask==GL_DEPTH_BUFFER_BIT ) maskString +=
std::string("DEPTH|");
- if ( mask==GL_ACCUM_BUFFER_BIT ) maskString +=
std::string("ACCUM|");
- if ( mask==GL_STENCIL_BUFFER_BIT ) maskString +=
std::string("STENCIL|");
+ if ( (mask & GL_COLOR_BUFFER_BIT)!=0 ) maskString +=
std::string("COLOR|");
+ if ( (mask & GL_DEPTH_BUFFER_BIT)!=0 ) maskString +=
std::string("DEPTH|");
+ if ( (mask & GL_ACCUM_BUFFER_BIT)!=0 ) maskString +=
std::string("ACCUM|");
+ if ( (mask & GL_STENCIL_BUFFER_BIT)!=0 ) maskString +=
std::string("STENCIL|");
if ( !maskString.size() ) maskString = std::string("NONE|");
os << maskString.substr(0, maskString.size()-1) << std::endl;
}
Index: src/osgWrappers/serializers/osgText/TextBase.cpp
===================================================================
--- src/osgWrappers/serializers/osgText/TextBase.cpp (revision 14710)
+++ src/osgWrappers/serializers/osgText/TextBase.cpp (working copy)
@@ -159,10 +159,10 @@
else
{
std::string maskString;
- if ( mask==osgText::TextBase::TEXT ) maskString +=
std::string("TEXT|");
- if ( mask==osgText::TextBase::BOUNDINGBOX ) maskString +=
std::string("BOUND|");
- if ( mask==osgText::TextBase::FILLEDBOUNDINGBOX ) maskString +=
std::string("FILLED|");
- if ( mask==osgText::TextBase::ALIGNMENT ) maskString +=
std::string("ALIGNMENT|");
+ if ( (mask&osgText::TextBase::TEXT)!=0 ) maskString +=
std::string("TEXT|");
+ if ( (mask&osgText::TextBase::BOUNDINGBOX)!=0 ) maskString +=
std::string("BOUND|");
+ if ( (mask&osgText::TextBase::FILLEDBOUNDINGBOX)!=0 ) maskString
+= std::string("FILLED|");
+ if ( (mask&osgText::TextBase::ALIGNMENT)!=0 ) maskString +=
std::string("ALIGNMENT|");
if ( !maskString.size() ) maskString = std::string("NONE|");
os << maskString.substr(0, maskString.size()-1) << std::endl;
}
Cheers,
Robert.
On 22 February 2015 at 21:53, Miha Ravšelj <[email protected]> wrote:
> Hello,
>
> I have been testing I/O operation on osgText::Text and I discovered that
> writing to osgt format does not work correctly due to invalid bit-wise
> comparison.
>
> I checked all the serializers for similar user serializers and found that
> also osg::Camera has same bug in writeClearMask. I didn't found any other
> serializer but if there are any that you are aware of (beside TextBase and
> Camera) they should be checked as well.
>
> The attached code in openscenegraph.zip resolves this issue in both
> serializers.
>
> I have also attached BitFlagsSerializer.h as a proposal for serializing
> bit flags . If there are multiple bitflags that are serialized inside OSG
> then I believe it is better if system serializer is added and used instead
> of producing same or similar code in user serializer(s).
>
> Miha
>
> _______________________________________________
> osg-submissions mailing list
> [email protected]
>
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>
>
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org