]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/model/animation.cxx
model.[ch]xx:
[simgear.git] / simgear / scene / model / animation.cxx
index 9a4c84c8595470f759bbdd3e603da16df497b47f..faec6334f9751a4319eea14c6caeaa61d2cb0c00 100644 (file)
@@ -1,8 +1,11 @@
-/ ron.cxx - classes to manage model animation.
+// animation.cxx - classes to manage model animation.
 // Written by David Megginson, started 2002.
 //
 // This file is in the Public Domain, and comes with no warranty.
 
+#ifdef HAVE_CONFIG_H
+#  include <simgear_config.h>
+#endif
 
 #include <string.h>             // for strcmp()
 #include <math.h>
@@ -1121,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),
@@ -1189,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)
@@ -1227,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);