1
0
Fork 0

Merge branch 'next' of git://gitorious.org/fg/flightgear into next

This commit is contained in:
Erik Hofman 2010-10-29 09:10:59 +02:00
commit e7ed88af92
11 changed files with 60 additions and 68 deletions

View file

@ -2055,14 +2055,6 @@
RelativePath="..\..\..\src\FDM\JSBSim\FGJSBBase.h"
>
</File>
<File
RelativePath="..\..\..\src\FDM\JSBSim\FGState.cpp"
>
</File>
<File
RelativePath="..\..\..\src\FDM\JSBSim\FGState.h"
>
</File>
<File
RelativePath="..\..\..\src\FDM\JSBSim\JSBSim.cxx"
>

View file

@ -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();

View file

@ -13,17 +13,13 @@
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
#include <AIModel/AIBase.hxx>
#include <simgear/math/SGMath.hxx>
#include <vector>
#include <string>
#include <Main/fg_props.hxx>
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*> submodel_vector_type;
typedef std::vector <submodel*> 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 <SGSharedPtr<FGAIBase> > 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);

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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,

View file

@ -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.
////////////////////////////////////////////////////////////////////

View file

@ -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();

View file

@ -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());
}
}