diff --git a/src/osgWrappers/serializers/osg/Array.cpp b/src/osgWrappers/serializers/osg/Array.cpp index 2358114ef..60ad2eac9 100644 --- a/src/osgWrappers/serializers/osg/Array.cpp +++ b/src/osgWrappers/serializers/osg/Array.cpp @@ -16,13 +16,9 @@ struct ResizeArray : public osgDB::MethodObject osg::Object* indexObject = inputParameters[0].get(); unsigned int index = 0; - osg::DoubleValueObject* dvo = dynamic_cast(indexObject); - if (dvo) index = static_cast(dvo->getValue()); - else - { - osg::UIntValueObject* uivo = dynamic_cast(indexObject); - if (uivo) index = uivo->getValue(); - } + osg::ValueObject* indexObject = inputParameters[0]->asValueObject(); + if (indexObject) indexObject->getScalarValue(index); + osg::Array* array = reinterpret_cast(objectPtr); array->resizeArray(index); diff --git a/src/osgWrappers/serializers/osg/Geode.cpp b/src/osgWrappers/serializers/osg/Geode.cpp index 252de6b0f..83d8e27eb 100644 --- a/src/osgWrappers/serializers/osg/Geode.cpp +++ b/src/osgWrappers/serializers/osg/Geode.cpp @@ -54,12 +54,12 @@ struct GeodeGetDrawable : public osgDB::MethodObject { if (inputParameters.empty()) return false; - osg::Object* indexObject = inputParameters[0].get(); - osg::UIntValueObject* uivo = dynamic_cast(indexObject); - if (!uivo) return false; + unsigned int index = 0; + osg::ValueObject* indexObject = inputParameters[0]->asValueObject(); + if (indexObject) indexObject->getScalarValue(index); osg::Geode* geode = reinterpret_cast(objectPtr); - outputParameters.push_back(geode->getDrawable(uivo->getValue())); + outputParameters.push_back(geode->getDrawable(index)); return true; } @@ -72,17 +72,9 @@ struct GeodeSetDrawable : public osgDB::MethodObject { if (inputParameters.size()<2) return false; - osg::Object* indexObject = inputParameters[0].get(); - OSG_NOTICE<<"GeodeSetChild "<className()<(indexObject); - if (dvo) index = static_cast(dvo->getValue()); - else - { - osg::UIntValueObject* uivo = dynamic_cast(indexObject); - if (uivo) index = uivo->getValue(); - } + osg::ValueObject* indexObject = inputParameters[0]->asValueObject(); + if (indexObject) indexObject->getScalarValue(index); osg::Drawable* child = dynamic_cast(inputParameters[1].get()); if (!child) return false; diff --git a/src/osgWrappers/serializers/osg/Group.cpp b/src/osgWrappers/serializers/osg/Group.cpp index 2ce8640a2..4f7922eeb 100644 --- a/src/osgWrappers/serializers/osg/Group.cpp +++ b/src/osgWrappers/serializers/osg/Group.cpp @@ -50,16 +50,10 @@ struct GroupGetChild : public osgDB::MethodObject { if (inputParameters.empty()) return false; - osg::Object* indexObject = inputParameters[0].get(); - unsigned int index = 0; - osg::DoubleValueObject* dvo = dynamic_cast(indexObject); - if (dvo) index = static_cast(dvo->getValue()); - else - { - osg::UIntValueObject* uivo = dynamic_cast(indexObject); - if (uivo) index = uivo->getValue(); - } + osg::ValueObject* indexObject = inputParameters[0]->asValueObject(); + if (indexObject) indexObject->getScalarValue(index); + osg::Group* group = reinterpret_cast(objectPtr); outputParameters.push_back(group->getChild(index)); @@ -73,17 +67,9 @@ struct GroupSetChild : public osgDB::MethodObject { if (inputParameters.size()<2) return false; - osg::Object* indexObject = inputParameters[0].get(); - OSG_NOTICE<<"GroupSetChild "<className()<(indexObject); - if (dvo) index = static_cast(dvo->getValue()); - else - { - osg::UIntValueObject* uivo = dynamic_cast(indexObject); - if (uivo) index = uivo->getValue(); - } + osg::ValueObject* indexObject = inputParameters[0]->asValueObject(); + if (indexObject) indexObject->getScalarValue(index); osg::Node* child = dynamic_cast(inputParameters[1].get()); if (!child) return false; diff --git a/src/osgWrappers/serializers/osg/PrimitiveSet.cpp b/src/osgWrappers/serializers/osg/PrimitiveSet.cpp index 3de41c3bc..525bc89a5 100644 --- a/src/osgWrappers/serializers/osg/PrimitiveSet.cpp +++ b/src/osgWrappers/serializers/osg/PrimitiveSet.cpp @@ -121,16 +121,10 @@ struct ResizeDrawElements : public osgDB::MethodObject { if (inputParameters.empty()) return false; - osg::Object* indexObject = inputParameters[0].get(); - unsigned int index = 0; - osg::DoubleValueObject* dvo = dynamic_cast(indexObject); - if (dvo) index = static_cast(dvo->getValue()); - else - { - osg::UIntValueObject* uivo = dynamic_cast(indexObject); - if (uivo) index = uivo->getValue(); - } + osg::ValueObject* indexObject = inputParameters[0]->asValueObject(); + if (indexObject) indexObject->getScalarValue(index); + osg::DrawElements* de = reinterpret_cast(objectPtr); de->resizeElements(index); diff --git a/src/osgWrappers/serializers/osg/Switch.cpp b/src/osgWrappers/serializers/osg/Switch.cpp index 3d0108f88..68a6e605e 100644 --- a/src/osgWrappers/serializers/osg/Switch.cpp +++ b/src/osgWrappers/serializers/osg/Switch.cpp @@ -10,16 +10,9 @@ struct SwitchGetValue : public osgDB::MethodObject { if (inputParameters.empty()) return false; - osg::Object* indexObject = inputParameters[0].get(); - unsigned int index = 0; - osg::DoubleValueObject* dvo = dynamic_cast(indexObject); - if (dvo) index = static_cast(dvo->getValue()); - else - { - osg::UIntValueObject* uivo = dynamic_cast(indexObject); - if (uivo) index = uivo->getValue(); - } + osg::ValueObject* indexObject = inputParameters[0]->asValueObject(); + if (indexObject) indexObject->getScalarValue(index); osg::Switch* sw = reinterpret_cast(objectPtr); outputParameters.push_back(new osg::BoolValueObject("return", sw->getValue(index))); @@ -35,42 +28,13 @@ struct SwitchSetValue : public osgDB::MethodObject { if (inputParameters.size()<2) return false; - osg::Object* indexObject = inputParameters[0].get(); - unsigned int index = 0; - osg::DoubleValueObject* dvo = dynamic_cast(indexObject); - if (dvo) index = static_cast(dvo->getValue()); - else - { - osg::UIntValueObject* uivo = dynamic_cast(indexObject); - if (uivo) index = uivo->getValue(); - } + osg::ValueObject* indexObject = inputParameters[0]->asValueObject(); + if (indexObject) indexObject->getScalarValue(index); bool enabled = false; - osg::Object* valueObject = inputParameters[1].get(); - if (!valueObject) return false; - - dvo = dynamic_cast(valueObject); - if (dvo) - { - enabled = dvo->getValue()!=0.0; - } - else - { - osg::UIntValueObject* uivo = dynamic_cast(valueObject); - if (uivo) - { - enabled = uivo->getValue()!=0; - } - else - { - osg::BoolValueObject* bo = dynamic_cast(valueObject); - if (bo) - { - enabled = bo->getValue(); - } - } - } + osg::ValueObject* valueObject = inputParameters[1]->asValueObject(); + if (valueObject) valueObject->getScalarValue(enabled); osg::Switch* sw = reinterpret_cast(objectPtr); sw->setValue(index, enabled);