From e82d7d5a6407cdd439de7194a3242c9a1ebd0029 Mon Sep 17 00:00:00 2001 From: david <david> Date: Mon, 25 Mar 2002 22:01:13 +0000 Subject: [PATCH] Ensure that all entries in the FGAircraftModel::Animation structure are initialized (reported by Melchior Franz). --- src/Main/model.cxx | 49 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/src/Main/model.cxx b/src/Main/model.cxx index 21670faf1..c8dc2462c 100644 --- a/src/Main/model.cxx +++ b/src/Main/model.cxx @@ -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) } } + + +//////////////////////////////////////////////////////////////////////// +// 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