1
0
Fork 0

Small refactoring of the submodel patch from onox

Signed-off-by: onox <denkpadje@gmail.com>
Signed-off-by: Erik Hofman <erik@ehofman.com>
This commit is contained in:
Torsten Dreyer 2015-04-30 11:39:00 +02:00 committed by Erik Hofman
parent 0e28621051
commit 90622b6873
2 changed files with 20 additions and 30 deletions

View file

@ -28,8 +28,6 @@ using std::endl;
using std::string;
using std::vector;
using FGXMLAutopilot::InputValue;
const double FGSubmodelMgr::lbs_to_slugs = 0.031080950172;
FGSubmodelMgr::FGSubmodelMgr()
@ -269,10 +267,8 @@ bool FGSubmodelMgr::release(submodel *sm, double dt)
double yaw_offset = 0.0;
double pitch_offset = 0.0;
if (sm->yaw_node != 0)
yaw_offset = sm->yaw_node->get_value();
if (sm->pitch_node != 0)
pitch_offset = sm->pitch_node->get_value();
yaw_offset = sm->yaw_offset->get_value();
pitch_offset = sm->pitch_offset->get_value();
transform(sm); // calculate submodel's initial conditions in world-coordinates
@ -366,10 +362,8 @@ void FGSubmodelMgr::transform(submodel *sm)
double yaw_offset = 0.0;
double pitch_offset = 0.0;
if (sm->yaw_node != 0)
yaw_offset = sm->yaw_node->get_value();
if (sm->pitch_node != 0)
pitch_offset = sm->pitch_node->get_value();
yaw_offset = sm->yaw_offset->get_value();
pitch_offset = sm->pitch_offset->get_value();
//cout << " name " << name << " id " << id << " sub id" << sub_id << endl;
@ -586,15 +580,14 @@ void FGSubmodelMgr::setData(int id, const string& path, bool serviceable)
sm->random = entry_node->getBoolValue("random", false);
sm->randomness = entry_node->getDoubleValue("randomness", 0.5);
SGPropertyNode_ptr a = entry_node->getNode("yaw-offset");
SGPropertyNode_ptr b = entry_node->getNode("pitch-offset");
SGPropertyNode_ptr prop_root = fgGetNode("/", true);
sm->yaw_node = 0;
sm->pitch_node = 0;
if (a != 0)
sm->yaw_node = new InputValue(*prop_root, *a);
if (b != 0)
sm->pitch_node = new InputValue(*prop_root, *b);
SGPropertyNode n;
SGPropertyNode_ptr a = entry_node->getNode("yaw-offset");
sm->yaw_offset = new FGXMLAutopilot::InputValue(*prop_root, a ? *a : n );
a = entry_node->getNode("pitch-offset");
sm->pitch_offset = new FGXMLAutopilot::InputValue(*prop_root, a ? *a : n );
if (sm->contents_node != 0)
sm->contents = sm->contents_node->getDoubleValue();
@ -699,15 +692,14 @@ void FGSubmodelMgr::setSubData(int id, const string& path, bool serviceable)
sm->random = entry_node->getBoolValue("random", false);
sm->randomness = entry_node->getDoubleValue("randomness", 0.5);
SGPropertyNode_ptr a = entry_node->getNode("yaw-offset");
SGPropertyNode_ptr b = entry_node->getNode("pitch-offset");
SGPropertyNode_ptr prop_root = fgGetNode("/", true);
sm->yaw_node = 0;
sm->pitch_node = 0;
if (a != 0)
sm->yaw_node = new InputValue(*prop_root, *a);
if (b != 0)
sm->pitch_node = new InputValue(*prop_root, *b);
SGPropertyNode n;
SGPropertyNode_ptr a = entry_node->getNode("yaw-offset");
sm->yaw_offset = new FGXMLAutopilot::InputValue(*prop_root, a ? *a : n );
a = entry_node->getNode("pitch-offset");
sm->pitch_offset = new FGXMLAutopilot::InputValue(*prop_root, a ? *a : n );
if (sm->contents_node != 0)
sm->contents = sm->contents_node->getDoubleValue();

View file

@ -20,8 +20,6 @@
#include <vector>
#include <string>
using FGXMLAutopilot::InputValue_ptr;
class FGAIBase;
class FGAIManager;
@ -36,8 +34,6 @@ public:
SGPropertyNode_ptr contents_node;
SGPropertyNode_ptr submodel_node;
SGPropertyNode_ptr speed_node;
InputValue_ptr yaw_node;
InputValue_ptr pitch_node;
std::string name;
std::string model;
@ -50,6 +46,8 @@ public:
double x_offset;
double y_offset;
double z_offset;
FGXMLAutopilot::InputValue_ptr yaw_offset;
FGXMLAutopilot::InputValue_ptr pitch_offset;
double drag_area;
double life;
double buoyancy;