Fixed handling of OverrideValue
This commit is contained in:
parent
2b67196418
commit
c6e72ee00b
@ -5,24 +5,19 @@
|
|||||||
|
|
||||||
static int readValue( osgDB::InputStream& is )
|
static int readValue( osgDB::InputStream& is )
|
||||||
{
|
{
|
||||||
int value = osg::StateAttribute::INHERIT;
|
int value = 0;
|
||||||
if ( is.isBinary() )
|
if ( is.isBinary() )
|
||||||
is >> value;
|
is >> value;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string enumValue;
|
std::string enumValue;
|
||||||
is >> enumValue;
|
is >> enumValue;
|
||||||
if ( enumValue=="OFF" ) value = osg::StateAttribute::OFF;
|
|
||||||
else if ( enumValue=="ON" ) value = osg::StateAttribute::ON;
|
if (enumValue.find("OFF")!=std::string::npos) value = osg::StateAttribute::OFF;
|
||||||
else if ( enumValue=="INHERIT" ) value = osg::StateAttribute::INHERIT;
|
if (enumValue.find("ON")!=std::string::npos) value = osg::StateAttribute::ON;
|
||||||
else if ( enumValue=="OFF|OVERRIDE" )
|
if (enumValue.find("OVERRIDE")!=std::string::npos) value = value | osg::StateAttribute::OVERRIDE;
|
||||||
value = osg::StateAttribute::OFF|osg::StateAttribute::OVERRIDE;
|
if (enumValue.find("PROTECTED")!=std::string::npos) value = value | osg::StateAttribute::PROTECTED;
|
||||||
else if ( enumValue=="OFF|PROTECTED" )
|
if (enumValue.find("INHERIT")!=std::string::npos) value = value | osg::StateAttribute::INHERIT;
|
||||||
value = osg::StateAttribute::OFF|osg::StateAttribute::PROTECTED;
|
|
||||||
else if ( enumValue=="ON|OVERRIDE" )
|
|
||||||
value = osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE;
|
|
||||||
else if ( enumValue=="ON|PROTECTED" )
|
|
||||||
value = osg::StateAttribute::ON|osg::StateAttribute::PROTECTED;
|
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -67,18 +62,13 @@ static void writeValue( osgDB::OutputStream& os, int value )
|
|||||||
os << value;
|
os << value;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( value==osg::StateAttribute::OFF ) os << std::string("OFF");
|
std::string valueString;
|
||||||
else if ( value==osg::StateAttribute::ON ) os << std::string("ON");
|
if ((value&osg::StateAttribute::ON)!=0) { if (!valueString.empty()) valueString.append("|"); valueString.append("ON"); }
|
||||||
else if ( value==osg::StateAttribute::INHERIT ) os << std::string("INHERIT");
|
if ((value&osg::StateAttribute::OVERRIDE)!=0) { if (!valueString.empty()) valueString.append("|"); valueString.append("OVERRIDE"); }
|
||||||
else if ( value==osg::StateAttribute::OFF+osg::StateAttribute::OVERRIDE )
|
if ((value&osg::StateAttribute::PROTECTED)!=0) { if (!valueString.empty()) valueString.append("|"); valueString.append("PROTECTED"); }
|
||||||
os << std::string("OFF|OVERRIDE");
|
if ((value&osg::StateAttribute::INHERIT)!=0) { if (!valueString.empty()) valueString.append("|"); valueString.append("INHERIT"); }
|
||||||
else if ( value==osg::StateAttribute::OFF+osg::StateAttribute::PROTECTED )
|
if (!valueString.empty()) os << valueString;
|
||||||
os << std::string("OFF|PROTECTED");
|
else os << "OFF";
|
||||||
else if ( value==osg::StateAttribute::ON+osg::StateAttribute::OVERRIDE )
|
|
||||||
os << std::string("ON|OVERRIDE");
|
|
||||||
else if ( value==osg::StateAttribute::ON+osg::StateAttribute::PROTECTED )
|
|
||||||
os << std::string("ON|PROTECTED");
|
|
||||||
else os << std::string("INHERIT");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user