From 198b88ca9b4a4b123b2e9ccdc85ea17eeaea70c6 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 6 May 2003 23:54:17 +0000 Subject: [PATCH] This is step "1" of probably "many" in the process of separating out the scene management code and organizing it within simgear. My strategy is to identify the code I want to move, and break it's direct flightgear dependencies. Then it will be free to move over into the simgear package. - Moved some property specific code into simgear/props/ - Split out the condition code from fgfs/src/Main/fg_props and put it in it's own source file in simgear/props/ - Created a scene subdirectory for scenery, model, and material property related code. - Moved location.[ch]xx into simgear/scene/model/ - The location and condition code had dependencies on flightgear's global state (all the globals-> stuff, the flightgear property tree, etc.) SimGear code can't depend on it so that data has to be passed as parameters to the functions/methods/constructors. - This need to pass data as function parameters had a dramatic cascading effect throughout the FlightGear code. --- src/MultiPlayer/mpplayer.cxx | 5 ++- src/Network/atc610x.cxx | 2 +- src/Network/generic.cxx | 4 +- src/Network/httpd.cxx | 2 +- src/Network/native_ctrls.cxx | 1 - src/Network/props.cxx | 4 +- src/Objects/apt_signs.hxx | 4 -- src/Objects/matlib.hxx | 4 -- src/Objects/newmat.cxx | 6 ++- src/Objects/newmat.hxx | 11 ++---- src/Objects/obj.hxx | 4 -- src/Objects/pt_lights.hxx | 6 +-- src/Scenery/tilemgr.cxx | 5 ++- src/Scenery/tilemgr.hxx | 3 +- src/Sound/fg_fx.cxx | 4 +- src/Sound/fg_sound.cxx | 53 ++++++++++++-------------- src/Sound/fg_sound.hxx | 2 + src/Systems/electrical.hxx | 3 +- src/Systems/pitot.hxx | 3 +- src/Systems/static.hxx | 3 +- src/Systems/vacuum.hxx | 3 +- src/WeatherCM/FGLocalWeatherDatabase.h | 2 +- 22 files changed, 63 insertions(+), 71 deletions(-) diff --git a/src/MultiPlayer/mpplayer.cxx b/src/MultiPlayer/mpplayer.cxx index adfe19e52..a89e373a7 100644 --- a/src/MultiPlayer/mpplayer.cxx +++ b/src/MultiPlayer/mpplayer.cxx @@ -246,7 +246,10 @@ void MPPlayer::LoadModel(void) { m_ModelTrans = new ssgTransform; // Load the model - m_Model = globals->get_model_loader()->load_model(m_sModelName); + m_Model = globals->get_model_loader()->load_model( globals->get_fg_root(), + m_sModelName, + globals->get_props(), + globals->get_sim_time_sec() ); m_Model->clrTraversalMaskBits( SSGTRAV_HOT ); // Add model to transform diff --git a/src/Network/atc610x.cxx b/src/Network/atc610x.cxx index d4450a9ba..570a60330 100644 --- a/src/Network/atc610x.cxx +++ b/src/Network/atc610x.cxx @@ -43,8 +43,8 @@ #include #include #include -#include #include +#include #include
#include
diff --git a/src/Network/generic.cxx b/src/Network/generic.cxx index c8492cd70..d5428b44f 100644 --- a/src/Network/generic.cxx +++ b/src/Network/generic.cxx @@ -25,8 +25,8 @@ #include #include #include -#include -#include +#include +#include #include
#include
diff --git a/src/Network/httpd.cxx b/src/Network/httpd.cxx index 162bf45ec..b020d89f4 100644 --- a/src/Network/httpd.cxx +++ b/src/Network/httpd.cxx @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include
#include
diff --git a/src/Network/native_ctrls.cxx b/src/Network/native_ctrls.cxx index f53dce08f..6a4d858b2 100644 --- a/src/Network/native_ctrls.cxx +++ b/src/Network/native_ctrls.cxx @@ -100,7 +100,6 @@ static void htond (double &x) // Populate the FGNetCtrls structure from the property tree. void FGProps2NetCtrls( FGNetCtrls *net, bool net_byte_order ) { int i; - bool b; SGPropertyNode * node; SGPropertyNode * tempnode; diff --git a/src/Network/props.cxx b/src/Network/props.cxx index eb4e9b0ce..51b293177 100644 --- a/src/Network/props.cxx +++ b/src/Network/props.cxx @@ -31,8 +31,8 @@ #include #include #include -#include -#include +#include +#include #include STL_STRSTREAM diff --git a/src/Objects/apt_signs.hxx b/src/Objects/apt_signs.hxx index 2d7705128..1c0df1c15 100644 --- a/src/Objects/apt_signs.hxx +++ b/src/Objects/apt_signs.hxx @@ -30,10 +30,6 @@ #endif -#ifdef HAVE_CONFIG_H -# include -#endif - #include #include STL_STRING diff --git a/src/Objects/matlib.hxx b/src/Objects/matlib.hxx index 38dd306a2..18ed48a61 100644 --- a/src/Objects/matlib.hxx +++ b/src/Objects/matlib.hxx @@ -29,10 +29,6 @@ # error This library requires C++ #endif -#ifdef HAVE_CONFIG_H -# include -#endif - #include #include STL_STRING // Standard C++ string library diff --git a/src/Objects/newmat.cxx b/src/Objects/newmat.cxx index 06a6d59f3..7e0fe379d 100644 --- a/src/Objects/newmat.cxx +++ b/src/Objects/newmat.cxx @@ -132,7 +132,11 @@ FGNewMat::Object::load_models () const // Load model only on demand if (!_models_loaded) { for (unsigned int i = 0; i < _paths.size(); i++) { - ssgEntity * entity = globals->get_model_loader()->load_model(_paths[i]); + ssgEntity * entity + = globals->get_model_loader()->load_model( globals->get_fg_root(), + _paths[i], + globals->get_props(), + globals->get_sim_time_sec()); if (entity != 0) { // FIXME: this stuff can be handled // in the XML wrapper as well (at least, diff --git a/src/Objects/newmat.hxx b/src/Objects/newmat.hxx index 8f52fa604..65ccfac85 100644 --- a/src/Objects/newmat.hxx +++ b/src/Objects/newmat.hxx @@ -30,17 +30,14 @@ # error This library requires C++ #endif -#ifdef HAVE_CONFIG_H -# include -#endif +#include + +#include STL_STRING // Standard C++ string library #include #include -#include -#include - -#include STL_STRING // Standard C++ string library +#include SG_USING_STD(string); diff --git a/src/Objects/obj.hxx b/src/Objects/obj.hxx index eedbd1ff4..c4842e820 100644 --- a/src/Objects/obj.hxx +++ b/src/Objects/obj.hxx @@ -31,10 +31,6 @@ #endif -#ifdef HAVE_CONFIG_H -# include -#endif - #include #include STL_STRING diff --git a/src/Objects/pt_lights.hxx b/src/Objects/pt_lights.hxx index 7ab4b0211..b78117ea3 100644 --- a/src/Objects/pt_lights.hxx +++ b/src/Objects/pt_lights.hxx @@ -30,14 +30,10 @@ #endif -#ifdef HAVE_CONFIG_H -# include -#endif - #include -#include // STL #include STL_STRING +#include // STL #include #include // plib include diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index c5fd37750..6c0d106ef 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -281,7 +281,10 @@ void FGTileMgr::update_queues() try { ssgEntity *obj_model = - globals->get_model_loader()->load_model(dm->get_model_path()); + globals->get_model_loader()->load_model( globals->get_fg_root(), + dm->get_model_path(), + globals->get_props(), + globals->get_sim_time_sec() ); if ( obj_model != NULL ) { dm->get_obj_trans()->addKid( obj_model ); } diff --git a/src/Scenery/tilemgr.hxx b/src/Scenery/tilemgr.hxx index 1eb97e701..34abff2ce 100644 --- a/src/Scenery/tilemgr.hxx +++ b/src/Scenery/tilemgr.hxx @@ -31,6 +31,7 @@ #include #include +#include #include @@ -41,8 +42,6 @@ # include #endif // ENABLE_THREADS -#include
- #include "FGTileLoader.hxx" #include "hitlist.hxx" #include "newcache.hxx" diff --git a/src/Sound/fg_fx.cxx b/src/Sound/fg_fx.cxx index d13a56f81..e56f39123 100644 --- a/src/Sound/fg_fx.cxx +++ b/src/Sound/fg_fx.cxx @@ -25,13 +25,13 @@ #pragma warning (disable: 4786) #endif -#include -#include #include #include #ifdef __BORLANDC__ # define exception c_exception #endif +#include +#include #include
diff --git a/src/Sound/fg_sound.cxx b/src/Sound/fg_sound.cxx index 867a6e5c8..1d56cd2e0 100644 --- a/src/Sound/fg_sound.cxx +++ b/src/Sound/fg_sound.cxx @@ -31,6 +31,7 @@ #include #include +#include #include
@@ -118,7 +119,7 @@ FGSound::init(SGPropertyNode *node) _property = fgGetNode(node->getStringValue("property", ""), true); SGPropertyNode *condition = node->getChild("condition"); if (condition != NULL) - _condition = fgReadCondition(condition); + _condition = fgReadCondition(globals->get_props(), condition); if (!_property && !_condition) SG_LOG(SG_GENERAL, SG_WARN, @@ -261,38 +262,34 @@ FGSound::update (double dt) // If the state changes to false, stop playing. // if (_property) - curr_value = _property->getDoubleValue(); + curr_value = _property->getDoubleValue(); if ( // Lisp, anyone? - (_condition && !_condition->test()) || - (!_condition && _property && - ( - !curr_value || - ( (_mode == FGSound::IN_TRANSIT) && (curr_value == _prev_value) ) - ) + (_condition && !_condition->test()) || + (!_condition && _property && + ( + !curr_value || + ( (_mode == FGSound::IN_TRANSIT) && (curr_value == _prev_value) ) ) - ) + ) + ) { + if ((_mode != FGSound::IN_TRANSIT) || (_stopping > MAX_TRANSIT_TIME)) { + if (_sample->is_playing()) { + SG_LOG(SG_GENERAL, SG_INFO, "Stopping audio after " << _dt_play + << " sec: " << _name ); - if ((_mode != FGSound::IN_TRANSIT) || (_stopping > MAX_TRANSIT_TIME)) { + _sample->stop( _mgr->get_scheduler() ); + } - if (_sample->is_playing()) { - SG_LOG(SG_GENERAL, SG_INFO, "Stopping audio after " << _dt_play - << " sec: " << _name ); - - _sample->stop( _mgr->get_scheduler() ); - } - - _active = false; - _dt_stop += dt; - _dt_play = 0.0; - - - } else - _stopping += dt; - - return; + _active = false; + _dt_stop += dt; + _dt_play = 0.0; + } else { + _stopping += dt; + } + return; } // @@ -304,9 +301,9 @@ FGSound::update (double dt) if (!_sample->is_playing()) { _dt_stop += dt; _dt_play = 0.0; - - } else + } else { _dt_play += dt; + } return; } diff --git a/src/Sound/fg_sound.hxx b/src/Sound/fg_sound.hxx index d8f71357d..c1aaa5679 100644 --- a/src/Sound/fg_sound.hxx +++ b/src/Sound/fg_sound.hxx @@ -28,6 +28,8 @@ #endif #include +#include + #include
#include
diff --git a/src/Systems/electrical.hxx b/src/Systems/electrical.hxx index f36f92af9..1668c9171 100644 --- a/src/Systems/electrical.hxx +++ b/src/Systems/electrical.hxx @@ -38,7 +38,8 @@ SG_USING_STD(string); SG_USING_STD(vector); -#include +#include + #include
diff --git a/src/Systems/pitot.hxx b/src/Systems/pitot.hxx index 8d0146fc3..0024f2882 100644 --- a/src/Systems/pitot.hxx +++ b/src/Systems/pitot.hxx @@ -11,7 +11,8 @@ # error This library requires C++ #endif -#include +#include + #include
diff --git a/src/Systems/static.hxx b/src/Systems/static.hxx index 0ed405801..df7c65020 100644 --- a/src/Systems/static.hxx +++ b/src/Systems/static.hxx @@ -11,7 +11,8 @@ # error This library requires C++ #endif -#include +#include + #include
diff --git a/src/Systems/vacuum.hxx b/src/Systems/vacuum.hxx index 197b1d1f4..2572c73f9 100644 --- a/src/Systems/vacuum.hxx +++ b/src/Systems/vacuum.hxx @@ -11,7 +11,8 @@ # error This library requires C++ #endif -#include +#include + #include
diff --git a/src/WeatherCM/FGLocalWeatherDatabase.h b/src/WeatherCM/FGLocalWeatherDatabase.h index 60063fa17..5509fd796 100644 --- a/src/WeatherCM/FGLocalWeatherDatabase.h +++ b/src/WeatherCM/FGLocalWeatherDatabase.h @@ -63,7 +63,7 @@ HISTORY #include
#include -#include +#include #include "sphrintp.h"