From: James Turner Date: Wed, 30 Dec 2015 20:27:54 +0000 (-0600) Subject: Avoid view-manager returning default SGGeod X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9e4e6a6fbfcacf03eef65caf4a3ed02398a08e26;p=flightgear.git Avoid view-manager returning default SGGeod - when switching views, force an update() to ensure view position is valid. Otherwise various subsystems such as AI traffic and the tile manager see a request for a 0,0 location. - when switching to model view, we still generate a 0,0 location initially - to be fixed. --- diff --git a/src/Viewer/viewmgr.cxx b/src/Viewer/viewmgr.cxx index 5e7339b77..3afcc45a4 100644 --- a/src/Viewer/viewmgr.cxx +++ b/src/Viewer/viewmgr.cxx @@ -139,6 +139,14 @@ FGViewMgr::init () do_bind(); } +void +FGViewMgr::postinit() +{ + // force update now so many properties of the current view are valid, + // eg view position and orientation (as exposed via globals) + update(0.0); +} + void FGViewMgr::shutdown() { @@ -732,6 +740,11 @@ FGViewMgr::setView (int newview) current = newview; // copy in view data copyToCurrent(); + + // force an update now, to avoid returning bogus data. + // real fix would to be make all the accessors use the dirty mechanism + // on FGViewer, so update() is a no-op. + update(0.0); } diff --git a/src/Viewer/viewmgr.hxx b/src/Viewer/viewmgr.hxx index 4043c6b08..95dbe4dd9 100644 --- a/src/Viewer/viewmgr.hxx +++ b/src/Viewer/viewmgr.hxx @@ -49,6 +49,7 @@ public: ~FGViewMgr( void ); virtual void init (); + virtual void postinit(); virtual void bind (); virtual void unbind (); virtual void update (double dt); @@ -73,7 +74,7 @@ public: void add_view( FGViewer * v ); - static const char* subsystemName() { return "view-mgr"; } + static const char* subsystemName() { return "view-manager"; } private: void do_bind();