1
0
Fork 0

Move the property expression code back to simgear.

This commit is contained in:
Tim Moore 2009-11-03 12:41:00 +01:00
parent c4e62cc69f
commit 3abe700dc8

View file

@ -33,9 +33,6 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/scene/tgdb/userdata.hxx>
#include <simgear/scene/material/Effect.hxx>
#include <simgear/scene/material/EffectGeode.hxx>
#include <simgear/scene/material/Technique.hxx>
#include <simgear/scene/material/matlib.hxx>
#include <simgear/scene/util/SGNodeMasks.hxx>
#include <simgear/scene/util/SGSceneUserData.hxx>
@ -253,47 +250,3 @@ SceneryPager* FGScenery::getPagerSingleton()
return pager.get();
}
// Effect initialization stuff
class PropertyExpression : public SGExpression<bool>
{
public:
PropertyExpression(SGPropertyNode* pnode) : _pnode(pnode) {}
void eval(bool& value, const expression::Binding*) const
{
value = _pnode->getValue<bool>();
}
protected:
SGPropertyNode_ptr _pnode;
};
class EffectPropertyListener : public SGPropertyChangeListener
{
public:
EffectPropertyListener(Technique* tniq) : _tniq(tniq) {}
void valueChanged(SGPropertyNode* node)
{
_tniq->refreshValidity();
}
protected:
osg::ref_ptr<Technique> _tniq;
};
Expression* propertyExpressionParser(const SGPropertyNode* exp,
expression::Parser* parser)
{
SGPropertyNode_ptr pnode = fgGetNode(exp->getStringValue(), true);
PropertyExpression* pexp = new PropertyExpression(pnode);
TechniquePredParser* predParser
= dynamic_cast<TechniquePredParser*>(parser);
if (predParser)
pnode->addChangeListener(new EffectPropertyListener(predParser
->getTechnique()));
return pexp;
}
expression::ExpParserRegistrar propertyRegistrar("property",
propertyExpressionParser);