1
0
Fork 0

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.
This commit is contained in:
curt 2003-05-06 23:54:17 +00:00
parent 2119db35c3
commit 198b88ca9b
22 changed files with 63 additions and 71 deletions

View file

@ -246,7 +246,10 @@ void MPPlayer::LoadModel(void) {
m_ModelTrans = new ssgTransform; m_ModelTrans = new ssgTransform;
// Load the model // 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 ); m_Model->clrTraversalMaskBits( SSGTRAV_HOT );
// Add model to transform // Add model to transform

View file

@ -43,8 +43,8 @@
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/io/iochannel.hxx> #include <simgear/io/iochannel.hxx>
#include <simgear/math/sg_types.hxx> #include <simgear/math/sg_types.hxx>
#include <simgear/misc/props.hxx>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>

View file

@ -25,8 +25,8 @@
#include <simgear/io/iochannel.hxx> #include <simgear/io/iochannel.hxx>
#include <simgear/misc/exception.hxx> #include <simgear/misc/exception.hxx>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
#include <simgear/misc/props.hxx> #include <simgear/props/props.hxx>
#include <simgear/misc/props_io.hxx> #include <simgear/props/props_io.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>

View file

@ -40,7 +40,7 @@
#include <simgear/io/iochannel.hxx> #include <simgear/io/iochannel.hxx>
#include <simgear/math/sg_types.hxx> #include <simgear/math/sg_types.hxx>
#include <simgear/misc/commands.hxx> #include <simgear/misc/commands.hxx>
#include <simgear/misc/props.hxx> #include <simgear/props/props.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>

View file

@ -100,7 +100,6 @@ static void htond (double &x)
// Populate the FGNetCtrls structure from the property tree. // Populate the FGNetCtrls structure from the property tree.
void FGProps2NetCtrls( FGNetCtrls *net, bool net_byte_order ) { void FGProps2NetCtrls( FGNetCtrls *net, bool net_byte_order ) {
int i; int i;
bool b;
SGPropertyNode * node; SGPropertyNode * node;
SGPropertyNode * tempnode; SGPropertyNode * tempnode;

View file

@ -31,8 +31,8 @@
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/misc/commands.hxx> #include <simgear/misc/commands.hxx>
#include <simgear/misc/strutils.hxx> #include <simgear/misc/strutils.hxx>
#include <simgear/misc/props.hxx> #include <simgear/props/props.hxx>
#include <simgear/misc/props_io.hxx> #include <simgear/props/props_io.hxx>
#include STL_STRSTREAM #include STL_STRSTREAM

View file

@ -30,10 +30,6 @@
#endif #endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include STL_STRING #include STL_STRING

View file

@ -29,10 +29,6 @@
# error This library requires C++ # error This library requires C++
#endif #endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include STL_STRING // Standard C++ string library #include STL_STRING // Standard C++ string library

View file

@ -132,7 +132,11 @@ FGNewMat::Object::load_models () const
// Load model only on demand // Load model only on demand
if (!_models_loaded) { if (!_models_loaded) {
for (unsigned int i = 0; i < _paths.size(); i++) { 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) { if (entity != 0) {
// FIXME: this stuff can be handled // FIXME: this stuff can be handled
// in the XML wrapper as well (at least, // in the XML wrapper as well (at least,

View file

@ -30,17 +30,14 @@
# error This library requires C++ # error This library requires C++
#endif #endif
#ifdef HAVE_CONFIG_H #include <simgear/compiler.h>
# include <config.h>
#endif #include STL_STRING // Standard C++ string library
#include <plib/sg.h> #include <plib/sg.h>
#include <plib/ssg.h> #include <plib/ssg.h>
#include <simgear/compiler.h> #include <simgear/props/props.hxx>
#include <simgear/misc/props.hxx>
#include STL_STRING // Standard C++ string library
SG_USING_STD(string); SG_USING_STD(string);

View file

@ -31,10 +31,6 @@
#endif #endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include STL_STRING #include STL_STRING

View file

@ -30,14 +30,10 @@
#endif #endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <vector> // STL
#include STL_STRING #include STL_STRING
#include <vector> // STL
#include <plib/sg.h> #include <plib/sg.h>
#include <plib/ssg.h> // plib include #include <plib/ssg.h> // plib include

View file

@ -281,7 +281,10 @@ void FGTileMgr::update_queues()
try try
{ {
ssgEntity *obj_model = 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 ) { if ( obj_model != NULL ) {
dm->get_obj_trans()->addKid( obj_model ); dm->get_obj_trans()->addKid( obj_model );
} }

View file

@ -31,6 +31,7 @@
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/math/point3d.hxx> #include <simgear/math/point3d.hxx>
#include <simgear/scene/model/location.hxx>
#include <queue> #include <queue>
@ -41,8 +42,6 @@
# include <simgear/threads/SGQueue.hxx> # include <simgear/threads/SGQueue.hxx>
#endif // ENABLE_THREADS #endif // ENABLE_THREADS
#include <Main/location.hxx>
#include "FGTileLoader.hxx" #include "FGTileLoader.hxx"
#include "hitlist.hxx" #include "hitlist.hxx"
#include "newcache.hxx" #include "newcache.hxx"

View file

@ -25,13 +25,13 @@
#pragma warning (disable: 4786) #pragma warning (disable: 4786)
#endif #endif
#include <simgear/misc/props.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/misc/exception.hxx> #include <simgear/misc/exception.hxx>
#ifdef __BORLANDC__ #ifdef __BORLANDC__
# define exception c_exception # define exception c_exception
#endif #endif
#include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>

View file

@ -31,6 +31,7 @@
#include <string.h> #include <string.h>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/props/condition.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
@ -118,7 +119,7 @@ FGSound::init(SGPropertyNode *node)
_property = fgGetNode(node->getStringValue("property", ""), true); _property = fgGetNode(node->getStringValue("property", ""), true);
SGPropertyNode *condition = node->getChild("condition"); SGPropertyNode *condition = node->getChild("condition");
if (condition != NULL) if (condition != NULL)
_condition = fgReadCondition(condition); _condition = fgReadCondition(globals->get_props(), condition);
if (!_property && !_condition) if (!_property && !_condition)
SG_LOG(SG_GENERAL, SG_WARN, SG_LOG(SG_GENERAL, SG_WARN,
@ -261,38 +262,34 @@ FGSound::update (double dt)
// If the state changes to false, stop playing. // If the state changes to false, stop playing.
// //
if (_property) if (_property)
curr_value = _property->getDoubleValue(); curr_value = _property->getDoubleValue();
if ( // Lisp, anyone? if ( // Lisp, anyone?
(_condition && !_condition->test()) || (_condition && !_condition->test()) ||
(!_condition && _property && (!_condition && _property &&
( (
!curr_value || !curr_value ||
( (_mode == FGSound::IN_TRANSIT) && (curr_value == _prev_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()) { _active = false;
SG_LOG(SG_GENERAL, SG_INFO, "Stopping audio after " << _dt_play _dt_stop += dt;
<< " sec: " << _name ); _dt_play = 0.0;
} else {
_sample->stop( _mgr->get_scheduler() ); _stopping += dt;
} }
_active = false;
_dt_stop += dt;
_dt_play = 0.0;
} else
_stopping += dt;
return;
return;
} }
// //
@ -304,9 +301,9 @@ FGSound::update (double dt)
if (!_sample->is_playing()) { if (!_sample->is_playing()) {
_dt_stop += dt; _dt_stop += dt;
_dt_play = 0.0; _dt_play = 0.0;
} else {
} else
_dt_play += dt; _dt_play += dt;
}
return; return;
} }

View file

@ -28,6 +28,8 @@
#endif #endif
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/props/condition.hxx>
#include <Main/fgfs.hxx> #include <Main/fgfs.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>

View file

@ -38,7 +38,8 @@
SG_USING_STD(string); SG_USING_STD(string);
SG_USING_STD(vector); SG_USING_STD(vector);
#include <simgear/misc/props.hxx> #include <simgear/props/props.hxx>
#include <Main/fgfs.hxx> #include <Main/fgfs.hxx>

View file

@ -11,7 +11,8 @@
# error This library requires C++ # error This library requires C++
#endif #endif
#include <simgear/misc/props.hxx> #include <simgear/props/props.hxx>
#include <Main/fgfs.hxx> #include <Main/fgfs.hxx>

View file

@ -11,7 +11,8 @@
# error This library requires C++ # error This library requires C++
#endif #endif
#include <simgear/misc/props.hxx> #include <simgear/props/props.hxx>
#include <Main/fgfs.hxx> #include <Main/fgfs.hxx>

View file

@ -11,7 +11,8 @@
# error This library requires C++ # error This library requires C++
#endif #endif
#include <simgear/misc/props.hxx> #include <simgear/props/props.hxx>
#include <Main/fgfs.hxx> #include <Main/fgfs.hxx>

View file

@ -63,7 +63,7 @@ HISTORY
#include <Main/fgfs.hxx> #include <Main/fgfs.hxx>
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/misc/props.hxx> #include <simgear/props/props.hxx>
#include "sphrintp.h" #include "sphrintp.h"