From 3fbbe3134a71c4072a54ed3a0d098912cc5f0cef Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Sat, 20 Aug 2011 08:54:47 +0200 Subject: [PATCH] new global function for aircraft position add a new function to get the aircraft's position instead of reading /position/* properties --- src/Main/globals.cxx | 13 +++++++++++++ src/Main/globals.hxx | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 99f1709da..40afef14c 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -362,6 +363,18 @@ FGGlobals::get_event_mgr () const return event_mgr; } +const SGGeod & +FGGlobals::get_aircraft_position() const +{ + if( acmodel != NULL ) { + SGModelPlacement * mp = acmodel->get3DModel(); + if( mp != NULL ) + return mp->getPosition(); + } + throw sg_exception("Can't get aircraft position", "FGGlobals::get_aircraft_position()" ); +} + + // Save the current state as the initial state. void diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index e241b6297..d2027d333 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -265,6 +265,8 @@ public: acmodel = model; } + const SGGeod & get_aircraft_position() const; + inline FGModelMgr *get_model_mgr () { return model_mgr; } inline void set_model_mgr (FGModelMgr * mgr) -- 2.39.5