]> git.mxchange.org Git - flightgear.git/commitdiff
Ensure that all entries in the FGAircraftModel::Animation structure
authordavid <david>
Mon, 25 Mar 2002 22:01:13 +0000 (22:01 +0000)
committerdavid <david>
Mon, 25 Mar 2002 22:01:13 +0000 (22:01 +0000)
are initialized (reported by Melchior Franz).

src/Main/model.cxx

index 21670faf189975be904475ace6d54e4ece4d24d3..c8dc2462c7b75b9eb198e9c6c4b89687b0c8033c 100644 (file)
@@ -103,8 +103,10 @@ FGAircraftModel::init ()
       SG_LOG(SG_INPUT, SG_ALERT, "No object-name given for transformation");
     } else {
       for (unsigned int j = 0; j < name_nodes.size(); j++) {
-       _animations.push_back(read_animation(name_nodes[j]->getStringValue(),
-                                            animation_nodes[i]));
+       Animation animation;
+       read_animation(animation, name_nodes[j]->getStringValue(),
+                      animation_nodes[i]);
+       _animations.push_back(animation);
       }
     }
   }
@@ -226,21 +228,19 @@ FGAircraftModel::update (int dt)
   }
 }
 
-FGAircraftModel::Animation
-FGAircraftModel::read_animation (const string &object_name,
+void
+FGAircraftModel::read_animation (Animation &animation,
+                                const string &object_name,
                                 const SGPropertyNode * node)
 {
-  Animation animation;
-
                                // Find the object to be animated
   ssgEntity * target = find_named_node(_model, object_name);
   if (target != 0) {
     SG_LOG(SG_INPUT, SG_INFO, "  Target object is " << object_name);
   } else {
-    animation.type = Animation::None;
     SG_LOG(SG_INPUT, SG_ALERT, "Object " << object_name
           << " not found in model");
-    return animation;
+    return;
   }
 
                                // Figure out the animation type
@@ -254,11 +254,11 @@ FGAircraftModel::read_animation (const string &object_name,
   } else if (type_name == "none") {
     SG_LOG(SG_INPUT, SG_INFO, "Reading disabled animation");
     animation.type = Animation::None;
-    return animation;
+    return;
   } else {
     animation.type = Animation::None;
     SG_LOG(SG_INPUT, SG_ALERT, "Unknown animation type " << type_name);
-    return animation;
+    return;
   }
 
                                // Splice a transform node into the tree
@@ -299,8 +299,6 @@ FGAircraftModel::read_animation (const string &object_name,
   animation.axis[2] = node->getFloatValue("axis/z", 0);
 
   sgNormalizeVec3(animation.axis);
-
-  return animation;
 }
 
 void
@@ -333,6 +331,32 @@ FGAircraftModel::do_animation (Animation &animation, long elapsed_ms)
   }
 }
 
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of FGAircraftModel::Animation
+////////////////////////////////////////////////////////////////////////
+
+FGAircraftModel::Animation::Animation ()
+  : name(""),
+    type(None),
+    transform(0),
+    prop(0),
+    factor(0),
+    offset(0),
+    position(0),
+    has_min(false),
+    min(0),
+    has_max(false),
+    max(0)
+{
+}
+
+FGAircraftModel::Animation::~Animation ()
+{
+  // pointers are managed elsewhere; these are just references
+}
+
 /* 
  * Transform to rotate an object around its local axis
  * from a relative frame of reference at center -- NHV
@@ -381,6 +405,5 @@ FGAircraftModel::Animation::setRotation()
  transform->setTransform(matrix);
 }
 
-
 // end of model.cxx