Added ability to replace callback objects via lua scripts to allow one to override callbacks.

Added fallback for osgGA::Widget::Extents.
This commit is contained in:
Robert Osfield
2014-03-07 11:09:25 +00:00
parent 9319350176
commit 9b299dc4b9
4 changed files with 43 additions and 23 deletions

View File

@@ -11,7 +11,6 @@ struct SwitchGetValue : public osgDB::MethodObject
if (inputParameters.empty()) return false;
osg::Object* indexObject = inputParameters[0].get();
OSG_NOTICE<<"SwitchGetValue "<<indexObject->className()<<std::endl;
unsigned int index = 0;
osg::DoubleValueObject* dvo = dynamic_cast<osg::DoubleValueObject*>(indexObject);
@@ -37,7 +36,6 @@ struct SwitchSetValue : public osgDB::MethodObject
if (inputParameters.size()<2) return false;
osg::Object* indexObject = inputParameters[0].get();
OSG_NOTICE<<"SwitchSetValue "<<indexObject->className()<<std::endl;
unsigned int index = 0;
osg::DoubleValueObject* dvo = dynamic_cast<osg::DoubleValueObject*>(indexObject);
@@ -49,17 +47,31 @@ struct SwitchSetValue : public osgDB::MethodObject
}
bool enabled = false;
indexObject = inputParameters[1].get();
dvo = dynamic_cast<osg::DoubleValueObject*>(indexObject);
if (dvo) enabled = dvo->getValue()!=0.0;
osg::Object* valueObject = inputParameters[1].get();
if (!valueObject) return false;
dvo = dynamic_cast<osg::DoubleValueObject*>(valueObject);
if (dvo)
{
enabled = dvo->getValue()!=0.0;
}
else
{
osg::UIntValueObject* uivo = dynamic_cast<osg::UIntValueObject*>(indexObject);
if (uivo) enabled = uivo->getValue()!=0;
osg::UIntValueObject* uivo = dynamic_cast<osg::UIntValueObject*>(valueObject);
if (uivo)
{
enabled = uivo->getValue()!=0;
}
else
{
osg::BoolValueObject* bo = dynamic_cast<osg::BoolValueObject*>(valueObject);
if (bo)
{
enabled = bo->getValue();
}
}
}
OSG_NOTICE<<"switch->setValue("<<index<<", "<<enabled<<")"<<std::endl;
osg::Switch* sw = reinterpret_cast<osg::Switch*>(objectPtr);
sw->setValue(index, enabled);