Added templte methods and implementations for Vec2,3,4 for b,ub,s,us,i and ui.

This commit is contained in:
Robert Osfield
2016-07-04 13:37:29 +01:00
parent 82ab389fd6
commit 1fe2d6d31f
2 changed files with 203 additions and 250 deletions

View File

@@ -101,8 +101,33 @@ class LuaScriptEngine : public osg::ScriptEngine
osgDB::ClassInterface& getClassInterface() const { return _ci; }
int pushDataToStack(SerializerScratchPad* ssp) const;
template<typename T>
bool pushValueToStack(SerializerScratchPad* ssp) const
{
T value;
if (ssp->get(value))
{
pushValue(value);
return true;
}
return false;
}
int getDataFromStack(SerializerScratchPad* ssp, osgDB::BaseSerializer::Type type, int pos) const;
template<typename T>
bool getDataFromStack(SerializerScratchPad* ssp, int pos) const
{
T value;
if (getValue(pos, value))
{
ssp->set(value);
return true;
}
return false;
}
int pushPropertyToStack(osg::Object* object, const std::string& propertyName) const;
int setPropertyFromStack(osg::Object* object, const std::string& propertyName) const;
int setPropertyFromStack(osg::Object* object, const std::string& propertyName, osgDB::BaseSerializer::Type type) const;
@@ -126,6 +151,9 @@ class LuaScriptEngine : public osg::ScriptEngine
bool getboundingbox(int pos) const;
bool getboundingsphere(int pos) const;
template<typename T>
bool getVec2(int pos, T& value) const
{
@@ -212,6 +240,27 @@ class LuaScriptEngine : public osg::ScriptEngine
return false;
}
template<typename T>
osg::Object* getValueObject(int pos) const
{
T value;
if (getValue(pos, value)) return new osg::TemplateValueObject<T>("", value);
else return 0;
}
template<typename T>
bool getPropertyAndPushValue(const osg::Object* object, const std::string& propertyName) const
{
T value;
if (_ci.getProperty(object, propertyName, value))
{
pushValue(value);
return true;
}
return false;
}
void pushValue(osgDB::BaseSerializer::Type type, const void* ptr) const;