[osg-users] [Questio nabout StateSet.cpp] truncated attribute override value?

Robert Osfield robert.osfield at gmail.com
Thu Sep 10 09:22:30 PDT 2015


Hi Julien,

I don't recall the why and wherefores of this particular bit of code in
StateSet.cpp (i.e. line 1662 and associated code) but it's a loooong time
since I wrote it ;-)

My best guess right now is that the ON/OFF for StateAttribute doesn't
affect anything, a StateAttribute isn't like a GL Mode that can be switched
on/off. All you can do with a StateAttribute is call it or not, and if you
don't want to call it you remove it from the StateSet.  This means all
StateAttribute attached to StateSet are implicitly ON if you wanted to
think it about a mode but in the end it's not a mode so it's probably best
not to try and treat it like one.

In the case of the StateSet API we reuse the OverrideValue as a bit mask so
it's used for the mode ON/OFF and the OVERRIDE and PROTECTED switches.  The
ON/OFF is only relevant to store for the Mode which StateAttribute and
Uniform's only the OVERRIDE and PROTECTED are significant to store.

Does this make sense?
Robert.


On 9 September 2015 at 18:45, Julien Valentin <julienvalentin51 at gmail.com>
wrote:

> Hi,
> Iwould like to introspect StateSet in order to know which override value
> is activated for a particular stateset.
> I parse AttributeList for this
>
> Code:
> for( osg::StateSet::AttributeList::const_iterator
> it=ss->getAttributeList().begin();it!=ss->getAttributeList().end() ; it++)
> {
>             if((*it).second.first ==stateattribute)
>             {
>                 if( (*it).second.second & osg::StateAttribute::ON)
>                 return(1);
>                 else return(0);
> }
>
>
>
> but according to StateSet.cpp l.1662
>
> Code:
> attributeList[attribute->getTypeMemberPair()] =
> RefAttributePair(attribute,value&(StateAttribute::OVERRIDE|StateAttribute::PROTECTED));
>
>
>
> the ON OFF bit is removed from the given user value. So I can't determine
> if an osg::Attribute is ON or OFF but only if it's OVERRIDE or PROTECTED
> I would like to know if there's a known reason behind this logic & and
> further if you know a mean to retrieve the ON/OFF bit.
>
> Thank you!
>
> Cheers,
> Julien
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65081#65081
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150910/90f6ae47/attachment-0003.htm>


More information about the osg-users mailing list