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:
parent
2119db35c3
commit
198b88ca9b
22 changed files with 63 additions and 71 deletions
|
@ -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
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/io/iochannel.hxx>
|
||||
#include <simgear/math/sg_types.hxx>
|
||||
#include <simgear/misc/props.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
#include <simgear/io/iochannel.hxx>
|
||||
#include <simgear/misc/exception.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/misc/props.hxx>
|
||||
#include <simgear/misc/props_io.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
|
||||
#include <Main/globals.hxx>
|
||||
#include <Main/fg_props.hxx>
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <simgear/io/iochannel.hxx>
|
||||
#include <simgear/math/sg_types.hxx>
|
||||
#include <simgear/misc/commands.hxx>
|
||||
#include <simgear/misc/props.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/commands.hxx>
|
||||
#include <simgear/misc/strutils.hxx>
|
||||
#include <simgear/misc/props.hxx>
|
||||
#include <simgear/misc/props_io.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
|
||||
#include STL_STRSTREAM
|
||||
|
||||
|
|
|
@ -30,10 +30,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include STL_STRING
|
||||
|
|
|
@ -29,10 +29,6 @@
|
|||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include STL_STRING // Standard C++ string library
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -30,17 +30,14 @@
|
|||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include STL_STRING // Standard C++ string library
|
||||
|
||||
#include <plib/sg.h>
|
||||
#include <plib/ssg.h>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/misc/props.hxx>
|
||||
|
||||
#include STL_STRING // Standard C++ string library
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
SG_USING_STD(string);
|
||||
|
||||
|
|
|
@ -31,10 +31,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include STL_STRING
|
||||
|
|
|
@ -30,14 +30,10 @@
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <vector> // STL
|
||||
#include STL_STRING
|
||||
#include <vector> // STL
|
||||
|
||||
#include <plib/sg.h>
|
||||
#include <plib/ssg.h> // plib include
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/math/point3d.hxx>
|
||||
#include <simgear/scene/model/location.hxx>
|
||||
|
||||
#include <queue>
|
||||
|
||||
|
@ -41,8 +42,6 @@
|
|||
# include <simgear/threads/SGQueue.hxx>
|
||||
#endif // ENABLE_THREADS
|
||||
|
||||
#include <Main/location.hxx>
|
||||
|
||||
#include "FGTileLoader.hxx"
|
||||
#include "hitlist.hxx"
|
||||
#include "newcache.hxx"
|
||||
|
|
|
@ -25,13 +25,13 @@
|
|||
#pragma warning (disable: 4786)
|
||||
#endif
|
||||
|
||||
#include <simgear/misc/props.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/exception.hxx>
|
||||
#ifdef __BORLANDC__
|
||||
# define exception c_exception
|
||||
#endif
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fg_props.hxx>
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/props/condition.hxx>
|
||||
|
||||
#include <Main/fg_props.hxx>
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#endif
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/props/condition.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
SG_USING_STD(string);
|
||||
SG_USING_STD(vector);
|
||||
|
||||
#include <simgear/misc/props.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <simgear/misc/props.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <simgear/misc/props.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <simgear/misc/props.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/fgfs.hxx>
|
||||
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ HISTORY
|
|||
#include <Main/fgfs.hxx>
|
||||
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/misc/props.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include "sphrintp.h"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue