]> git.mxchange.org Git - flightgear.git/commitdiff
Timed animations now working again.
authorcurt <curt>
Thu, 8 May 2003 15:56:31 +0000 (15:56 +0000)
committercurt <curt>
Thu, 8 May 2003 15:56:31 +0000 (15:56 +0000)
src/Main/main.cxx
src/Model/model.cxx
src/Model/model.hxx

index 2595903e42cfd5ce29fc19f9a09c71ab4a656d8d..089b645231658c83214a0f42461322cfaa49ac23 100644 (file)
@@ -497,6 +497,7 @@ void fgRenderFrame() {
         }
         // Keep resetting sim time while the sim is initializing
         globals->set_sim_time_sec( 0.0 );
+        Animation::set_sim_time_sec( 0.0 );
     } else {
         // idle_state is now 1000 meaning we've finished all our
         // initializations and are running the main loop, so this will
@@ -1024,6 +1025,7 @@ static void fgMainLoop( void ) {
         delta_time_sec = 0;
     last_time_stamp = current_time_stamp;
     globals->inc_sim_time_sec( delta_time_sec );
+    Animation::set_sim_time_sec( globals->get_sim_time_sec() );
 
     static long remainder = 0;
     long elapsed;
@@ -1038,6 +1040,7 @@ static void fgMainLoop( void ) {
     SGTime *t = globals->get_time_params();
 
     sglog().setLogLevels( SG_ALL, (sgDebugPriority)fgGetInt("/sim/log-level") );
+    sglog().setLogLevels( SG_ALL, SG_INFO );
 
     FGLocation * acmodel_location = 0;
     if(cur_fdm_state->getACModel() != 0) {
index 310782a361d5bcf9c01f822a9d66a56f6177b99b..4dc0163a22571e4c9268a0a44ec280c9f3167455 100644 (file)
@@ -349,6 +349,9 @@ fgLoad3DModel( const string &fg_root, const string &path,
 // Implementation of Animation
 ////////////////////////////////////////////////////////////////////////
 
+// Initialize the static data member
+double Animation::sim_time_sec = 0.0;
+
 Animation::Animation (SGPropertyNode_ptr props, ssgBranch * branch)
     : _branch(branch)
 {
@@ -365,7 +368,7 @@ Animation::init ()
 }
 
 void
-Animation::update ()
+Animation::update()
 {
 }
 
@@ -440,7 +443,7 @@ SelectAnimation::~SelectAnimation ()
 }
 
 void
-SelectAnimation::update ()
+SelectAnimation::update()
 {
   if (_condition != 0 && _condition->test()) 
       ((ssgSelector *)_branch)->select(0xffff);
@@ -461,7 +464,7 @@ SpinAnimation::SpinAnimation( SGPropertyNode *prop_root,
     _prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)),
     _factor(props->getDoubleValue("factor", 1.0)),
     _position_deg(props->getDoubleValue("starting-position-deg", 0)),
-    _last_time_sec( sim_time_sec /* globals->get_sim_time_sec() */ )
+    _last_time_sec( sim_time_sec )
 {
     _center[0] = props->getFloatValue("center/x-m", 0);
     _center[1] = props->getFloatValue("center/y-m", 0);
@@ -477,7 +480,7 @@ SpinAnimation::~SpinAnimation ()
 }
 
 void
-SpinAnimation::update( double sim_time_sec )
+SpinAnimation::update()
 {
   double dt = sim_time_sec - _last_time_sec;
   _last_time_sec = sim_time_sec;
@@ -511,7 +514,7 @@ TimedAnimation::~TimedAnimation ()
 }
 
 void
-TimedAnimation::update( double sim_time_sec )
+TimedAnimation::update()
 {
     if ((sim_time_sec - _last_time_sec) >= _duration_sec) {
         _last_time_sec = sim_time_sec;
@@ -602,7 +605,7 @@ TranslateAnimation::~TranslateAnimation ()
 }
 
 void
-TranslateAnimation::update ()
+TranslateAnimation::update()
 {
   if (_table == 0) {
     _position_m = (_prop->getDoubleValue() + _offset_m) * _factor;
index e3cbe1d56840722ccee2bbed014eefef46c7ed02..858b7c811a15e4ea19e49bc9ea8c0b02d74b2cf2 100644 (file)
@@ -53,8 +53,7 @@ class FGLocation;
  * instead, they should use the FGModelLoader declared in loader.hxx.
  */
 ssgBranch * fgLoad3DModel( const string& fg_root, const string &path,
-                           SGPropertyNode *prop_root,
-                           double sim_time_sec );
+                           SGPropertyNode *prop_root, double sim_time_sec );
 
 
 \f
@@ -86,10 +85,18 @@ public:
   /**
    * Update the animation.
    */
-  virtual void update ();
+  virtual void update();
+
+  /**
+   * Set the value of sim_time_sec.  This needs to be called every
+   * frame in order for the time based animations to work correctly.
+   */
+  static void set_sim_time_sec( double val ) { sim_time_sec = val; }
 
 protected:
 
+  static double sim_time_sec;
+
   ssgBranch * _branch;
 
 };
@@ -137,7 +144,7 @@ public:
   SelectAnimation( SGPropertyNode *prop_root,
                    SGPropertyNode_ptr props );
   virtual ~SelectAnimation ();
-  virtual void update ();
+  virtual void update();
 private:
   FGCondition * _condition;
 };
@@ -155,7 +162,7 @@ public:
                  SGPropertyNode_ptr props,
                  double sim_time_sec );
   virtual ~SpinAnimation ();
-  virtual void update( double sim_time_sec );
+  virtual void update();
 private:
   SGPropertyNode_ptr _prop;
   double _factor;
@@ -175,7 +182,7 @@ class TimedAnimation : public Animation
 public:
     TimedAnimation (SGPropertyNode_ptr props);
     virtual ~TimedAnimation ();
-    virtual void update( double sim_time_sec );
+    virtual void update();
 private:
     double _duration_sec;
     double _last_time_sec;
@@ -219,7 +226,7 @@ public:
   TranslateAnimation( SGPropertyNode *prop_root,
                       SGPropertyNode_ptr props );
   virtual ~TranslateAnimation ();
-  virtual void update ();
+  virtual void update();
 private:
   SGPropertyNode_ptr _prop;
   double _offset_m;