diff --git a/src/osgGA/Widget.cpp b/src/osgGA/Widget.cpp index e8f22769f..140f95862 100644 --- a/src/osgGA/Widget.cpp +++ b/src/osgGA/Widget.cpp @@ -306,5 +306,6 @@ void Widget::createGraphicsImplementation() osg::BoundingSphere Widget::computeBound() const { - return osg::BoundingSphere(_extents); + if (_extents.valid()) return osg::BoundingSphere(_extents); + else return osg::Group::computeBound(); } diff --git a/src/osgPlugins/lua/LuaScriptEngine.cpp b/src/osgPlugins/lua/LuaScriptEngine.cpp index 496d1dcad..fd2c59954 100644 --- a/src/osgPlugins/lua/LuaScriptEngine.cpp +++ b/src/osgPlugins/lua/LuaScriptEngine.cpp @@ -2004,7 +2004,7 @@ public: PushStackValueVisitor(const LuaScriptEngine* lse) : _lse(lse) { _lua = const_cast(lse)->getLuaState(); } - virtual void apply(bool value) { lua_pushboolean(_lua, value ? 0 : 1); } + virtual void apply(bool value) { lua_pushboolean(_lua, value ? 1 : 0); } virtual void apply(char value) { lua_pushnumber(_lua, value); } virtual void apply(unsigned char value) { lua_pushnumber(_lua, value); } virtual void apply(short value) { lua_pushnumber(_lua, value); } @@ -2993,15 +2993,30 @@ int LuaScriptEngine::setPropertyFromStack(osg::Object* object, const std::string if (lua_type(_lua,-1)==LUA_TFUNCTION) { int ref = luaL_ref(_lua, LUA_REGISTRYINDEX); - osg::ref_ptr lco = new LuaCallbackObject(propertyName, this, ref); - object->getOrCreateUserDataContainer()->addUserObject(lco.get()); + + osg::UserDataContainer* udc = object->getOrCreateUserDataContainer(); + unsigned int objectIndex = udc->getUserObjectIndex(propertyName); + if (objectIndex < udc->getNumUserObjects()) + { + udc->setUserObject(objectIndex, lco.get()); + } + else + { + udc->addUserObject(lco.get()); + } + return 0; } type = LuaScriptEngine::getType(-1); } + return setPropertyFromStack(object, propertyName, type); +} + +int LuaScriptEngine::setPropertyFromStack(osg::Object* object, const std::string& propertyName, osgDB::BaseSerializer::Type type) const +{ switch(type) { case(osgDB::BaseSerializer::RW_BOOL): @@ -3266,11 +3281,6 @@ int LuaScriptEngine::setPropertyFromStack(osg::Object* object, const std::string } break; } - case(osgDB::BaseSerializer::RW_LIST): - { - OSG_NOTICE<<"Need to implement RW_LIST support"<className()<(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 "<className()<(indexObject); @@ -49,17 +47,31 @@ struct SwitchSetValue : public osgDB::MethodObject } bool enabled = false; - indexObject = inputParameters[1].get(); - dvo = dynamic_cast(indexObject); - if (dvo) enabled = dvo->getValue()!=0.0; + 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(indexObject); - if (uivo) enabled = uivo->getValue()!=0; + 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_NOTICE<<"switch->setValue("<(objectPtr); sw->setValue(index, enabled);