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:
parent
0e28621051
commit
90622b6873
2 changed files with 20 additions and 30 deletions
|
@ -28,8 +28,6 @@ using std::endl;
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
using FGXMLAutopilot::InputValue;
|
|
||||||
|
|
||||||
const double FGSubmodelMgr::lbs_to_slugs = 0.031080950172;
|
const double FGSubmodelMgr::lbs_to_slugs = 0.031080950172;
|
||||||
|
|
||||||
FGSubmodelMgr::FGSubmodelMgr()
|
FGSubmodelMgr::FGSubmodelMgr()
|
||||||
|
@ -269,10 +267,8 @@ bool FGSubmodelMgr::release(submodel *sm, double dt)
|
||||||
double yaw_offset = 0.0;
|
double yaw_offset = 0.0;
|
||||||
double pitch_offset = 0.0;
|
double pitch_offset = 0.0;
|
||||||
|
|
||||||
if (sm->yaw_node != 0)
|
yaw_offset = sm->yaw_offset->get_value();
|
||||||
yaw_offset = sm->yaw_node->get_value();
|
pitch_offset = sm->pitch_offset->get_value();
|
||||||
if (sm->pitch_node != 0)
|
|
||||||
pitch_offset = sm->pitch_node->get_value();
|
|
||||||
|
|
||||||
transform(sm); // calculate submodel's initial conditions in world-coordinates
|
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 yaw_offset = 0.0;
|
||||||
double pitch_offset = 0.0;
|
double pitch_offset = 0.0;
|
||||||
|
|
||||||
if (sm->yaw_node != 0)
|
yaw_offset = sm->yaw_offset->get_value();
|
||||||
yaw_offset = sm->yaw_node->get_value();
|
pitch_offset = sm->pitch_offset->get_value();
|
||||||
if (sm->pitch_node != 0)
|
|
||||||
pitch_offset = sm->pitch_node->get_value();
|
|
||||||
|
|
||||||
//cout << " name " << name << " id " << id << " sub id" << sub_id << endl;
|
//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->random = entry_node->getBoolValue("random", false);
|
||||||
sm->randomness = entry_node->getDoubleValue("randomness", 0.5);
|
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);
|
SGPropertyNode_ptr prop_root = fgGetNode("/", true);
|
||||||
sm->yaw_node = 0;
|
SGPropertyNode n;
|
||||||
sm->pitch_node = 0;
|
|
||||||
if (a != 0)
|
SGPropertyNode_ptr a = entry_node->getNode("yaw-offset");
|
||||||
sm->yaw_node = new InputValue(*prop_root, *a);
|
sm->yaw_offset = new FGXMLAutopilot::InputValue(*prop_root, a ? *a : n );
|
||||||
if (b != 0)
|
|
||||||
sm->pitch_node = new InputValue(*prop_root, *b);
|
a = entry_node->getNode("pitch-offset");
|
||||||
|
sm->pitch_offset = new FGXMLAutopilot::InputValue(*prop_root, a ? *a : n );
|
||||||
|
|
||||||
if (sm->contents_node != 0)
|
if (sm->contents_node != 0)
|
||||||
sm->contents = sm->contents_node->getDoubleValue();
|
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->random = entry_node->getBoolValue("random", false);
|
||||||
sm->randomness = entry_node->getDoubleValue("randomness", 0.5);
|
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);
|
SGPropertyNode_ptr prop_root = fgGetNode("/", true);
|
||||||
sm->yaw_node = 0;
|
SGPropertyNode n;
|
||||||
sm->pitch_node = 0;
|
|
||||||
if (a != 0)
|
SGPropertyNode_ptr a = entry_node->getNode("yaw-offset");
|
||||||
sm->yaw_node = new InputValue(*prop_root, *a);
|
sm->yaw_offset = new FGXMLAutopilot::InputValue(*prop_root, a ? *a : n );
|
||||||
if (b != 0)
|
|
||||||
sm->pitch_node = new InputValue(*prop_root, *b);
|
a = entry_node->getNode("pitch-offset");
|
||||||
|
sm->pitch_offset = new FGXMLAutopilot::InputValue(*prop_root, a ? *a : n );
|
||||||
|
|
||||||
if (sm->contents_node != 0)
|
if (sm->contents_node != 0)
|
||||||
sm->contents = sm->contents_node->getDoubleValue();
|
sm->contents = sm->contents_node->getDoubleValue();
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using FGXMLAutopilot::InputValue_ptr;
|
|
||||||
|
|
||||||
class FGAIBase;
|
class FGAIBase;
|
||||||
class FGAIManager;
|
class FGAIManager;
|
||||||
|
|
||||||
|
@ -36,8 +34,6 @@ public:
|
||||||
SGPropertyNode_ptr contents_node;
|
SGPropertyNode_ptr contents_node;
|
||||||
SGPropertyNode_ptr submodel_node;
|
SGPropertyNode_ptr submodel_node;
|
||||||
SGPropertyNode_ptr speed_node;
|
SGPropertyNode_ptr speed_node;
|
||||||
InputValue_ptr yaw_node;
|
|
||||||
InputValue_ptr pitch_node;
|
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string model;
|
std::string model;
|
||||||
|
@ -50,6 +46,8 @@ public:
|
||||||
double x_offset;
|
double x_offset;
|
||||||
double y_offset;
|
double y_offset;
|
||||||
double z_offset;
|
double z_offset;
|
||||||
|
FGXMLAutopilot::InputValue_ptr yaw_offset;
|
||||||
|
FGXMLAutopilot::InputValue_ptr pitch_offset;
|
||||||
double drag_area;
|
double drag_area;
|
||||||
double life;
|
double life;
|
||||||
double buoyancy;
|
double buoyancy;
|
||||||
|
|
Loading…
Add table
Reference in a new issue