X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=simgear%2Fscene%2Fmodel%2FSGMaterialAnimation.cxx;h=6b5887a102b23f965fa7c9afdc4ab12e95ea4ab7;hb=4787ac64ff9326896c15416d17ff8a7d70b5070b;hp=61181aeb22c2ba70464dbd11808316a16c91d6e4;hpb=fef625ce27ac50cf301cc150401e26a8f02acc5e;p=simgear.git diff --git a/simgear/scene/model/SGMaterialAnimation.cxx b/simgear/scene/model/SGMaterialAnimation.cxx index 61181aeb..6b5887a1 100644 --- a/simgear/scene/model/SGMaterialAnimation.cxx +++ b/simgear/scene/model/SGMaterialAnimation.cxx @@ -27,6 +27,7 @@ #include #include #include +#include using namespace std; using namespace simgear; @@ -340,9 +341,7 @@ public: class UpdateCallback : public osg::NodeCallback { public: UpdateCallback(const osgDB::FilePathList& texturePathList, - const SGCondition* condition, const SGPropertyNode* configNode, SGPropertyNode* modelRoot) : - _condition(condition), _materialProps(configNode, modelRoot), _texturePathList(texturePathList), _prevState(false) @@ -360,7 +359,7 @@ public: virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) { osg::StateSet* stateSet = node->getStateSet(); - if ((!_condition || _condition->test()) && stateSet) { + if (stateSet) { if (_textureProp) { std::string textureName = _textureProp->getStringValue(); if (_textureName != textureName) { @@ -400,7 +399,6 @@ public: traverse(node, nv); } private: - SGSharedPtr _condition; SGSharedPtr _textureProp; SGSharedPtr _thresholdProp; std::string _textureName; @@ -557,13 +555,23 @@ SGMaterialAnimation::createAnimationGroup(osg::Group& parent) || getConfig()->hasChild("threshold-prop") || getCondition()) { stateSet->setDataVariance(osg::Object::DYNAMIC); group->setUpdateCallback(new UpdateCallback(texturePathList, - getCondition(), getConfig(), inputRoot)); } else { stateSet->setDataVariance(osg::Object::STATIC); } - parent.addChild(group); - return group; + if (getCondition()) { + ConditionNode* cn = new ConditionNode; + cn->setCondition(getCondition()); + osg::Group* modelGroup = new osg::Group; + group->addChild(modelGroup); + cn->addChild(group); + cn->addChild(modelGroup); + parent.addChild(cn); + return modelGroup; + } else { + parent.addChild(group); + return group; + } } void