]> git.mxchange.org Git - simgear.git/commitdiff
Add a new node "float-property" to be used in float comparision in effect predicates
authorfredb <fredb>
Sat, 10 Apr 2010 11:15:32 +0000 (11:15 +0000)
committerTim Moore <timoore33@gmail.com>
Mon, 12 Apr 2010 05:25:13 +0000 (07:25 +0200)
simgear/scene/material/Effect.cxx

index 3b5728ac0fa2236cf41e87609f9372e1bfdb747f..33ceacdae2c94b4eba791b02c226f98ce1564ac3 100644 (file)
@@ -1279,14 +1279,15 @@ osgDB::RegisterDotOsgWrapperProxy effectProxy
 }
 
 // Property expressions for technique predicates
-class PropertyExpression : public SGExpression<bool>
+template<typename T>
+class PropertyExpression : public SGExpression<T>
 {
 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<bool>();
+        value = _pnode->getValue<T>();
     }
 protected:
     SGPropertyNode_ptr _pnode;
@@ -1305,12 +1306,13 @@ protected:
     osg::ref_ptr<Technique> _tniq;
 };
 
+template<typename T>
 Expression* propertyExpressionParser(const SGPropertyNode* exp,
                                      expression::Parser* parser)
 {
     SGPropertyNode_ptr pnode = getPropertyRoot()->getNode(exp->getStringValue(),
                                                           true);
-    PropertyExpression* pexp = new PropertyExpression(pnode);
+    PropertyExpression<T>* pexp = new PropertyExpression<T>(pnode);
     TechniquePredParser* predParser
         = dynamic_cast<TechniquePredParser*>(parser);
     if (predParser)
@@ -1320,6 +1322,9 @@ Expression* propertyExpressionParser(const SGPropertyNode* exp,
 }
 
 expression::ExpParserRegistrar propertyRegistrar("property",
-                                                 propertyExpressionParser);
+                                                 propertyExpressionParser<bool>);
+
+expression::ExpParserRegistrar propvalueRegistrar("float-property",
+                                                 propertyExpressionParser<float>);
 
 }