From: fredb Date: Sat, 10 Apr 2010 11:15:32 +0000 (+0000) Subject: Add a new node "float-property" to be used in float comparision in effect predicates X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f19e83dcf10d5fced3d799c884a4654d7ada6548;p=simgear.git Add a new node "float-property" to be used in float comparision in effect predicates --- diff --git a/simgear/scene/material/Effect.cxx b/simgear/scene/material/Effect.cxx index 3b5728ac..33ceacda 100644 --- a/simgear/scene/material/Effect.cxx +++ b/simgear/scene/material/Effect.cxx @@ -1279,14 +1279,15 @@ osgDB::RegisterDotOsgWrapperProxy effectProxy } // Property expressions for technique predicates -class PropertyExpression : public SGExpression +template +class PropertyExpression : public SGExpression { public: PropertyExpression(SGPropertyNode* pnode) : _pnode(pnode) {} - void eval(bool& value, const expression::Binding*) const + void eval(T& value, const expression::Binding*) const { - value = _pnode->getValue(); + value = _pnode->getValue(); } protected: SGPropertyNode_ptr _pnode; @@ -1305,12 +1306,13 @@ protected: osg::ref_ptr _tniq; }; +template Expression* propertyExpressionParser(const SGPropertyNode* exp, expression::Parser* parser) { SGPropertyNode_ptr pnode = getPropertyRoot()->getNode(exp->getStringValue(), true); - PropertyExpression* pexp = new PropertyExpression(pnode); + PropertyExpression* pexp = new PropertyExpression(pnode); TechniquePredParser* predParser = dynamic_cast(parser); if (predParser) @@ -1320,6 +1322,9 @@ Expression* propertyExpressionParser(const SGPropertyNode* exp, } expression::ExpParserRegistrar propertyRegistrar("property", - propertyExpressionParser); + propertyExpressionParser); + +expression::ExpParserRegistrar propvalueRegistrar("float-property", + propertyExpressionParser); }