diff --git a/projects/VC90/FlightGear/FlightGear.vcproj b/projects/VC90/FlightGear/FlightGear.vcproj
index e97cba54f..6db57814d 100644
--- a/projects/VC90/FlightGear/FlightGear.vcproj
+++ b/projects/VC90/FlightGear/FlightGear.vcproj
@@ -2055,14 +2055,6 @@
RelativePath="..\..\..\src\FDM\JSBSim\FGJSBBase.h"
>
-
-
-
-
diff --git a/src/AIModel/submodel.cxx b/src/AIModel/submodel.cxx
index 29b658603..a25212198 100644
--- a/src/AIModel/submodel.cxx
+++ b/src/AIModel/submodel.cxx
@@ -43,6 +43,11 @@ FGSubmodelMgr::~FGSubmodelMgr()
{
}
+FGAIManager* FGSubmodelMgr::aiManager()
+{
+ return (FGAIManager*)globals->get_subsystem("ai_model");
+}
+
void FGSubmodelMgr::init()
{
index = 0;
@@ -74,8 +79,6 @@ void FGSubmodelMgr::init()
_contrail_trigger = fgGetNode("ai/submodels/contrails", true);
_contrail_trigger->setBoolValue(false);
- ai = (FGAIManager*)globals->get_subsystem("ai_model");
-
load();
}
@@ -116,9 +119,9 @@ void FGSubmodelMgr::update(double dt)
_expiry = false;
// check if the submodel hit an object or terrain
- sm_list = ai->get_ai_list();
- sm_list_iterator sm_list_itr = sm_list.begin();
- sm_list_iterator end = sm_list.end();
+ FGAIManager::ai_list_type sm_list(aiManager()->get_ai_list());
+ FGAIManager::ai_list_iterator sm_list_itr = sm_list.begin(),
+ end = sm_list.end();
for (; sm_list_itr != end; ++sm_list_itr) {
FGAIBase::object_type object_type =(*sm_list_itr)->getType();
@@ -300,7 +303,8 @@ bool FGSubmodelMgr::release(submodel *sm, double dt)
ballist->setParentNodes(_selected_ac);
ballist->setContentsNode(sm->contents_node);
ballist->setWeight(sm->weight);
- ai->attach(ballist);
+
+ aiManager()->attach(ballist);
if (sm->count > 0)
sm->count--;
@@ -383,8 +387,6 @@ void FGSubmodelMgr::transform(submodel *sm)
} else {
// set the data for a submodel tied to an AI Object
//cout << " set the data for a submodel tied to an AI Object " << id << endl;
- sm_list_iterator sm_list_itr = sm_list.begin();
- sm_list_iterator end = sm_list.end();
setParentNode(id);
}
@@ -477,15 +479,15 @@ void FGSubmodelMgr::loadAI()
{
SG_LOG(SG_GENERAL, SG_DEBUG, "Submodels: Loading AI submodels ");
- sm_list = ai->get_ai_list();
+ FGAIManager::ai_list_type sm_list(aiManager()->get_ai_list());
if (sm_list.empty()) {
SG_LOG(SG_GENERAL, SG_ALERT, "Submodels: Unable to read AI submodel list");
return;
}
- sm_list_iterator sm_list_itr = sm_list.begin();
- sm_list_iterator end = sm_list.end();
+ FGAIManager::ai_list_iterator sm_list_itr = sm_list.begin(),
+ end = sm_list.end();
while (sm_list_itr != end) {
string path = (*sm_list_itr)->_getSMPath();
diff --git a/src/AIModel/submodel.hxx b/src/AIModel/submodel.hxx
index 2abff45ce..71ba8693d 100644
--- a/src/AIModel/submodel.hxx
+++ b/src/AIModel/submodel.hxx
@@ -13,17 +13,13 @@
#include
#include
-#include
+#include
+
#include
#include
-#include
-
-using std::vector;
-using std::string;
-using std::list;
-
class FGAIBase;
+class FGAIManager;
class FGSubmodelMgr : public SGSubsystem, public SGPropertyChangeListener
{
@@ -37,8 +33,8 @@ public:
SGPropertyNode_ptr submodel_node;
SGPropertyNode_ptr speed_node;
- string name;
- string model;
+ std::string name;
+ std::string model;
double speed;
bool slaved;
bool repeat;
@@ -68,13 +64,13 @@ public:
bool collision;
bool expiry;
bool impact;
- string impact_report;
+ std::string impact_report;
double fuse_range;
- string submodel;
+ std::string submodel;
int sub_id;
bool force_stabilised;
bool ext_force;
- string force_path;
+ std::string force_path;
} submodel;
typedef struct {
@@ -112,7 +108,7 @@ public:
private:
- typedef vector submodel_vector_type;
+ typedef std::vector submodel_vector_type;
typedef submodel_vector_type::iterator submodel_vector_iterator;
submodel_vector_type submodels;
@@ -186,22 +182,17 @@ private:
SGPropertyNode_ptr _path_node;
SGPropertyNode_ptr _selected_ac;
-
- FGAIManager* ai;
IC_struct IC;
-
- // A list of pointers to AI objects
- typedef list > sm_list_type;
- typedef sm_list_type::iterator sm_list_iterator;
- typedef sm_list_type::const_iterator sm_list_const_iterator;
-
- sm_list_type sm_list;
-
-
+
+ /**
+ * Helper to retrieve the AI manager, if it currently exists
+ */
+ FGAIManager* aiManager();
+
void loadAI();
void loadSubmodels();
- void setData(int id, string& path, bool serviceable);
- void setSubData(int id, string& path, bool serviceable);
+ void setData(int id, std::string& path, bool serviceable);
+ void setSubData(int id, std::string& path, bool serviceable);
void valueChanged (SGPropertyNode *);
void transform(submodel *);
void setParentNode(int parent_id);
diff --git a/src/FDM/JSBSim/FGFDMExec.cpp b/src/FDM/JSBSim/FGFDMExec.cpp
index 6a12cec2b..616dd6ea6 100644
--- a/src/FDM/JSBSim/FGFDMExec.cpp
+++ b/src/FDM/JSBSim/FGFDMExec.cpp
@@ -96,7 +96,7 @@ void checkTied ( FGPropertyManager *node )
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Constructors
-FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root)
+FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root), delete_root(false)
{
FDMctr = new unsigned int;
*FDMctr = 0;
@@ -104,7 +104,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root)
root_overload = (root != NULL);
}
-FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), FDMctr(fdmctr)
+FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root), delete_root(false), FDMctr(fdmctr)
{
Initialize();
root_overload = (root != NULL);
@@ -152,6 +152,7 @@ void FGFDMExec::Initialize()
if (Root == 0) { // Then this is the root FDM
Root = new FGPropertyManager; // Create the property manager
+ delete_root = true;
FDMctr = new unsigned int; // Create and initialize the child FDM counter
(*FDMctr) = 0;
@@ -198,7 +199,8 @@ FGFDMExec::~FGFDMExec()
if(FDMctr != 0 && !root_overload) {
if(Root != 0) {
- delete Root;
+ if (delete_root)
+ delete Root;
Root = 0;
}
if (IdFDM == 0) { // Meaning this is no child FDM
diff --git a/src/FDM/JSBSim/FGFDMExec.h b/src/FDM/JSBSim/FGFDMExec.h
index 9d53cd1b5..38921ac7c 100644
--- a/src/FDM/JSBSim/FGFDMExec.h
+++ b/src/FDM/JSBSim/FGFDMExec.h
@@ -556,6 +556,7 @@ private:
FGTrim* Trim;
FGPropertyManager* Root;
+ bool delete_root;
FGPropertyManager* instance;
// The FDM counter is used to give each child FDM an unique ID. The root FDM has the ID 0
diff --git a/src/Instrumentation/HUD/HUD.hxx b/src/Instrumentation/HUD/HUD.hxx
index 3ef9d7ee7..3408e54c5 100644
--- a/src/Instrumentation/HUD/HUD.hxx
+++ b/src/Instrumentation/HUD/HUD.hxx
@@ -599,7 +599,6 @@ private:
double _default_heading;
GLint _view[4];
FGRunway* _runway;
- FGViewer* _cockpit_view;
unsigned short _stipple_out; // stipple pattern of the outline of the runway
unsigned short _stipple_center; // stipple pattern of the center line of the runway
bool _draw_arrow; // draw arrow when runway is not visible in HUD
diff --git a/src/Instrumentation/HUD/HUD_runway.cxx b/src/Instrumentation/HUD/HUD_runway.cxx
index fcf4f1127..ae6ebba65 100644
--- a/src/Instrumentation/HUD/HUD_runway.cxx
+++ b/src/Instrumentation/HUD/HUD_runway.cxx
@@ -49,7 +49,6 @@ HUD::Runway::Runway(HUD *hud, const SGPropertyNode *node, float x, float y) :
_scale_dist(node->getDoubleValue("scale-dist-nm")),
_default_pitch(fgGetDouble("/sim/view[0]/config/pitch-pitch-deg", 0.0)),
_default_heading(fgGetDouble("/sim/view[0]/config/pitch-heading-deg", 0.0)),
- _cockpit_view(globals->get_viewmgr()->get_view(0)),
_stipple_out(node->getIntValue("outer_stipple", 0xFFFF)),
_stipple_center(node->getIntValue("center-stipple", 0xFFFF)),
_draw_arrow(_arrow_scale > 0 ? true : false),
@@ -69,7 +68,6 @@ HUD::Runway::Runway(HUD *hud, const SGPropertyNode *node, float x, float y) :
_top = _center_y + (_h / 2) + _y;
}
-
void HUD::Runway::draw()
{
_runway = get_active_runway();
@@ -87,8 +85,10 @@ void HUD::Runway::draw()
double po = curr_view->getPitchOffset_deg();
double ho = curr_view->getHeadingOffset_deg();
- double yaw = -(_cockpit_view->getHeadingOffset_deg() - _default_heading) * SG_DEGREES_TO_RADIANS;
- double pitch = (_cockpit_view->getPitchOffset_deg() - _default_pitch) * SG_DEGREES_TO_RADIANS;
+ FGViewer* cockpitView = globals->get_viewmgr()->get_view(0);
+
+ double yaw = -(cockpitView->getHeadingOffset_deg() - _default_heading) * SG_DEGREES_TO_RADIANS;
+ double pitch = (cockpitView->getPitchOffset_deg() - _default_pitch) * SG_DEGREES_TO_RADIANS;
//double roll = fgGetDouble("/sim/view[0]/config/roll-offset-deg",0.0) //TODO: adjust for default roll offset
double sPitch = sin(pitch), cPitch = cos(pitch),
sYaw = sin(yaw), cYaw = cos(yaw);
diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx
index 74551bc91..4fa1a7dc0 100644
--- a/src/Main/fg_commands.cxx
+++ b/src/Main/fg_commands.cxx
@@ -392,9 +392,11 @@ static bool
do_panel_load (const SGPropertyNode * arg)
{
string panel_path =
- arg->getStringValue("path",
- fgGetString("/sim/panel/path",
- "Panels/Default/default.xml"));
+ arg->getStringValue("path", fgGetString("/sim/panel/path"));
+ if (panel_path.empty()) {
+ return false;
+ }
+
FGPanel * new_panel = fgReadPanel(panel_path);
if (new_panel == 0) {
SG_LOG(SG_INPUT, SG_ALERT,
diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx
index f154ab658..b3af6a617 100644
--- a/src/Main/fg_init.cxx
+++ b/src/Main/fg_init.cxx
@@ -1414,20 +1414,20 @@ bool fgInitSubsystems() {
// Add a new 2D panel.
////////////////////////////////////////////////////////////////////
- string panel_path = fgGetString("/sim/panel/path",
- "Panels/Default/default.xml");
-
- globals->set_current_panel( fgReadPanel(panel_path) );
- if (globals->get_current_panel() == 0) {
+ string panel_path(fgGetString("/sim/panel/path"));
+ if (!panel_path.empty()) {
+ FGPanel* p = fgReadPanel(panel_path);
+ if (p) {
+ globals->set_current_panel(p);
+ p->init();
+ p->bind();
+ SG_LOG( SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path );
+ } else {
SG_LOG( SG_INPUT, SG_ALERT,
"Error reading new panel from " << panel_path );
- } else {
- SG_LOG( SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path );
- globals->get_current_panel()->init();
- globals->get_current_panel()->bind();
+ }
}
-
////////////////////////////////////////////////////////////////////
// Initialize the controls subsystem.
////////////////////////////////////////////////////////////////////
diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx
index 33f36ecc8..db6eef28c 100644
--- a/src/Main/globals.cxx
+++ b/src/Main/globals.cxx
@@ -167,6 +167,7 @@ FGGlobals::~FGGlobals()
// shut down all subsystems, make sure we take down the
// AIModels system first.
SGSubsystem* ai = subsystem_mgr->remove("ai_model");
+ ai->unbind();
delete ai;
subsystem_mgr->unbind();
diff --git a/src/Main/viewer.cxx b/src/Main/viewer.cxx
index ab5f6aa44..05816f8bc 100644
--- a/src/Main/viewer.cxx
+++ b/src/Main/viewer.cxx
@@ -651,6 +651,8 @@ FGViewer::update (double dt)
}
}
recalc();
- _cameraGroup->update(toOsg(_absolute_view_pos), toOsg(mViewOrientation));
- _cameraGroup->setCameraParameters(get_v_fov(), get_aspect_ratio());
+ if( fgGetBool( "/sim/rendering/draw-otw", true ) ) {
+ _cameraGroup->update(toOsg(_absolute_view_pos), toOsg(mViewOrientation));
+ _cameraGroup->setCameraParameters(get_v_fov(), get_aspect_ratio());
+ }
}