]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/animation.cxx
model.[ch]xx:
[simgear.git] / simgear / scene / model / animation.cxx
index 3a9367696484df6e2aef26b322419d7f3e7274f5..faec6334f9751a4319eea14c6caeaa61d2cb0c00 100644 (file)
@@ -1124,6 +1124,7 @@ SGMaterialAnimation::SGMaterialAnimation( SGPropertyNode *prop_root,
         SGPropertyNode_ptr props, const SGPath &texture_path)
     : SGAnimation(props, new ssgBranch),
     _prop_root(prop_root),
+    _last_condition(false),
     _prop_base(""),
     _texture_base(texture_path),
     _cached_material(0),
@@ -1192,6 +1193,8 @@ SGMaterialAnimation::SGMaterialAnimation( SGPropertyNode *prop_root,
     _thresh_prop = n ? _prop_root->getNode(path(n->getStringValue()), true) : 0;
     n = props->getChild("texture-prop");
     _tex_prop = n ? _prop_root->getNode(path(n->getStringValue()), true) : 0;
+
+    _static_update = _update;
 }
 
 void SGMaterialAnimation::initColorGroup(SGPropertyNode_ptr group, ColorSpec *col, int flag)
@@ -1230,8 +1233,15 @@ void SGMaterialAnimation::init()
 
 int SGMaterialAnimation::update()
 {
-    if (_condition && !_condition->test())
-        return 2;
+    if (_condition) {
+        bool cond = _condition->test();
+        if (cond && !_last_condition)
+            _update |= _static_update;
+
+        _last_condition = cond;
+        if (!cond)
+            return 2;
+    }
 
     if (_read & DIFFUSE)
         updateColorGroup(&_diff, DIFFUSE);