From 2119db35c3f596268e2ee21d3cd8c359a85cd1ed Mon Sep 17 00:00:00 2001 From: curt <curt> Date: Tue, 6 May 2003 23:46:24 +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/ATC/AIEntity.cxx | 2 +- src/ATC/AILocalTraffic.cxx | 9 +- src/ATC/ATCdisplay.cxx | 2 +- src/Aircraft/aircraft.cxx | 6 +- src/Autopilot/newauto.hxx | 2 +- src/Cockpit/cockpit.cxx | 2 +- src/Cockpit/hud.cxx | 5 +- src/Cockpit/panel.hxx | 2 +- src/Cockpit/panel_io.cxx | 7 +- src/Controls/controls.hxx | 2 +- src/FDM/JSBSim/FGPropertyManager.cpp | 2 +- src/FDM/JSBSim/FGPropertyManager.h | 2 +- src/FDM/JSBSim/JSBSim.hxx | 2 +- src/FDM/LaRCsim.cxx | 5 +- src/FDM/YASim/FGFDM.hpp | 2 +- src/FDM/YASim/Makefile.am | 2 +- src/FDM/YASim/YASim.cxx | 5 +- src/FDM/YASim/yasim-test.cpp | 2 +- src/FDM/flight.cxx | 2 +- src/GUI/dialog.hxx | 2 +- src/GUI/gui.cxx | 4 +- src/GUI/new_gui.hxx | 2 +- src/GUI/prop_picker.cxx | 10 +- src/GUI/prop_picker.hxx | 2 +- src/Input/input.cxx | 4 +- src/Input/input.hxx | 3 +- src/Instrumentation/airspeed_indicator.hxx | 3 +- src/Instrumentation/altimeter.hxx | 2 +- src/Instrumentation/attitude_indicator.hxx | 3 +- src/Instrumentation/dme.hxx | 3 +- src/Instrumentation/gps.hxx | 3 +- src/Instrumentation/heading_indicator.hxx | 3 +- src/Instrumentation/mag_compass.hxx | 3 +- src/Instrumentation/slip_skid_ball.hxx | 3 +- src/Instrumentation/turn_indicator.hxx | 3 +- .../vertical_speed_indicator.hxx | 3 +- src/Main/Makefile.am | 7 +- src/Main/fg_commands.cxx | 12 +- src/Main/fg_commands.hxx | 2 +- src/Main/fg_init.cxx | 20 +- src/Main/fg_props.cxx | 394 ------------------ src/Main/fg_props.hxx | 161 +------ src/Main/fgfs.hxx | 2 +- src/Main/logger.hxx | 2 +- src/Main/main.cxx | 22 +- src/Main/viewer.cxx | 15 +- src/Main/viewer.hxx | 3 +- src/Model/acmodel.cxx | 12 +- src/Model/loader.cxx | 11 +- src/Model/loader.hxx | 8 +- src/Model/model.cxx | 82 ++-- src/Model/model.hxx | 32 +- src/Model/modelmgr.cxx | 7 +- src/Model/panelnode.cxx | 11 +- 54 files changed, 214 insertions(+), 708 deletions(-) diff --git a/src/ATC/AIEntity.cxx b/src/ATC/AIEntity.cxx index 126d03778..88945a1ef 100644 --- a/src/ATC/AIEntity.cxx +++ b/src/ATC/AIEntity.cxx @@ -54,5 +54,5 @@ void FGAIEntity::RegisterTransmission(int code) { void FGAIEntity::Transform() { aip.setPosition(pos.lon(), pos.lat(), pos.elev() * SG_METER_TO_FEET); aip.setOrientation(roll, pitch, hdg); - aip.update(); + aip.update( globals->get_scenery()->get_center() ); } diff --git a/src/ATC/AILocalTraffic.cxx b/src/ATC/AILocalTraffic.cxx index 17b642121..e6667699b 100644 --- a/src/ATC/AILocalTraffic.cxx +++ b/src/ATC/AILocalTraffic.cxx @@ -23,9 +23,10 @@ # include <config.h> #endif +#include <simgear/scene/model/location.hxx> + #include <Airports/runways.hxx> #include <Main/globals.hxx> -#include <Main/location.hxx> #include <Scenery/scenery.hxx> #include <Scenery/tilemgr.hxx> #include <simgear/math/point3d.hxx> @@ -156,7 +157,8 @@ bool FGAILocalTraffic::Init(string ICAO, OperatingState initialState, PatternLeg string planepath = "Aircraft/c172/Models/c172-dpm.ac"; SGPath path = globals->get_fg_root(); path.append(planepath); - aip.init(planepath.c_str()); + aip.init( path.str(), planepath.c_str(), globals->get_props(), + globals->get_sim_time_sec() ); aip.setVisible(false); // This will be set to true once a valid ground elevation has been determined globals->get_scenery()->get_scene_graph()->addKid(aip.getSceneGraph()); @@ -1117,7 +1119,8 @@ void FGAILocalTraffic::DoGroundElev() { double visibility_meters = fgGetDouble("/environment/visibility-m"); //globals->get_tile_mgr()->prep_ssg_nodes( acmodel_location, globals->get_tile_mgr()->prep_ssg_nodes( aip.getFGLocation(), visibility_meters ); - globals->get_tile_mgr()->update( aip.getFGLocation(), visibility_meters, (aip.getFGLocation())->get_absolute_view_pos() ); + Point3D scenery_center = globals->get_scenery()->get_center(); + globals->get_tile_mgr()->update( aip.getFGLocation(), visibility_meters, (aip.getFGLocation())->get_absolute_view_pos( scenery_center ) ); // save results of update in FGLocation for fdm... //if ( globals->get_scenery()->get_cur_elev() > -9990 ) { diff --git a/src/ATC/ATCdisplay.cxx b/src/ATC/ATCdisplay.cxx index 85bb9245e..4f75c489e 100644 --- a/src/ATC/ATCdisplay.cxx +++ b/src/ATC/ATCdisplay.cxx @@ -22,7 +22,7 @@ # include <config.h> #endif -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include <Include/general.hxx> #include <Main/fg_props.hxx> diff --git a/src/Aircraft/aircraft.cxx b/src/Aircraft/aircraft.cxx index 9b667c8f7..681dd48e8 100644 --- a/src/Aircraft/aircraft.cxx +++ b/src/Aircraft/aircraft.cxx @@ -90,7 +90,7 @@ void fgAircraftOutputCurrent(fgAIRCRAFT *a) { // Show available aircraft types void fgReadAircraft(void) { - SGPropertyNode *aircraft_types = fgGetNode("/sim/aircraft-types", true); + // SGPropertyNode *aircraft_types = fgGetNode("/sim/aircraft-types", true); SGPath path( globals->get_fg_root() ); path.append("Aircraft"); @@ -127,10 +127,8 @@ void fgReadAircraft(void) { SGPropertyNode *desc = node->getNode("description"); if (desc) { -#endif - SGPropertyNode *aircraft = + SGPropertyNode *aircraft = aircraft_types->getChild(dire->d_name, 0, true); -#if 0 aircraft->setStringValue(strdup(desc->getStringValue())); } diff --git a/src/Autopilot/newauto.hxx b/src/Autopilot/newauto.hxx index 37dd3dd94..de1d39bbb 100644 --- a/src/Autopilot/newauto.hxx +++ b/src/Autopilot/newauto.hxx @@ -27,7 +27,7 @@ #define _NEWAUTO_HXX -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include <simgear/route/waypoint.hxx> #include <Main/fgfs.hxx> diff --git a/src/Cockpit/cockpit.cxx b/src/Cockpit/cockpit.cxx index 0415b86a8..3dd91cae2 100644 --- a/src/Cockpit/cockpit.cxx +++ b/src/Cockpit/cockpit.cxx @@ -38,7 +38,7 @@ #include <simgear/constants.h> #include <simgear/debug/logstream.hxx> #include <simgear/math/polar3d.hxx> -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include <simgear/timing/sg_time.hxx> #include <Aircraft/aircraft.hxx> diff --git a/src/Cockpit/hud.cxx b/src/Cockpit/hud.cxx index d9654f231..4f7ddfded 100644 --- a/src/Cockpit/hud.cxx +++ b/src/Cockpit/hud.cxx @@ -47,10 +47,8 @@ #include <simgear/constants.h> #include <simgear/debug/logstream.hxx> -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include <simgear/misc/sg_path.hxx> -//#include <simgear/math/fg_random.h> -//#include <simgear/math/polar3d.hxx> #include <Aircraft/aircraft.hxx> #include <Autopilot/newauto.hxx> @@ -61,7 +59,6 @@ #include <NetworkOLK/network.h> #endif #include <Scenery/scenery.hxx> -//#include <Time/fg_timer.hxx> #if defined ( __sun__ ) || defined ( __sgi ) extern "C" { diff --git a/src/Cockpit/panel.hxx b/src/Cockpit/panel.hxx index 00125ea6d..fc2afda00 100644 --- a/src/Cockpit/panel.hxx +++ b/src/Cockpit/panel.hxx @@ -41,7 +41,7 @@ #include <plib/ssg.h> #include <simgear/math/interpolater.hxx> -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include <simgear/timing/timestamp.hxx> #include <cmath> diff --git a/src/Cockpit/panel_io.cxx b/src/Cockpit/panel_io.cxx index f7721a982..88fe30c4a 100644 --- a/src/Cockpit/panel_io.cxx +++ b/src/Cockpit/panel_io.cxx @@ -31,9 +31,9 @@ #include <simgear/compiler.h> #include <simgear/misc/exception.hxx> -#include <simgear/misc/sg_path.hxx> #include <simgear/debug/logstream.hxx> -#include <simgear/misc/props.hxx> +#include <simgear/misc/sg_path.hxx> +#include <simgear/props/props.hxx> #include STL_IOSTREAM #include STL_FSTREAM @@ -137,7 +137,8 @@ readConditions (FGConditional * component, const SGPropertyNode * node) const SGPropertyNode * conditionNode = node->getChild("condition"); if (conditionNode != 0) // The top level is implicitly AND - component->setCondition(fgReadCondition(conditionNode)); + component->setCondition(fgReadCondition(globals->get_props(), + conditionNode) ); } diff --git a/src/Controls/controls.hxx b/src/Controls/controls.hxx index 4175f421e..2e467a5ae 100644 --- a/src/Controls/controls.hxx +++ b/src/Controls/controls.hxx @@ -24,7 +24,7 @@ #ifndef _CONTROLS_HXX #define _CONTROLS_HXX -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include <Main/fgfs.hxx> #include <Main/globals.hxx> diff --git a/src/FDM/JSBSim/FGPropertyManager.cpp b/src/FDM/JSBSim/FGPropertyManager.cpp index d0f810ab8..ae942e7d4 100644 --- a/src/FDM/JSBSim/FGPropertyManager.cpp +++ b/src/FDM/JSBSim/FGPropertyManager.cpp @@ -28,7 +28,7 @@ INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include "FGPropertyManager.h" /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FDM/JSBSim/FGPropertyManager.h b/src/FDM/JSBSim/FGPropertyManager.h index 57e090daf..8e4d818a2 100644 --- a/src/FDM/JSBSim/FGPropertyManager.h +++ b/src/FDM/JSBSim/FGPropertyManager.h @@ -36,7 +36,7 @@ INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ #include <string> -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DEFINITIONS diff --git a/src/FDM/JSBSim/JSBSim.hxx b/src/FDM/JSBSim/JSBSim.hxx index 04a10b299..2d83588ec 100644 --- a/src/FDM/JSBSim/JSBSim.hxx +++ b/src/FDM/JSBSim/JSBSim.hxx @@ -53,7 +53,7 @@ DEFINITIONS FORWARD DECLARATIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include <FDM/JSBSim/FGFDMExec.h> diff --git a/src/FDM/LaRCsim.cxx b/src/FDM/LaRCsim.cxx index 6a0764616..c4c0eb48f 100644 --- a/src/FDM/LaRCsim.cxx +++ b/src/FDM/LaRCsim.cxx @@ -24,19 +24,18 @@ #include <simgear/constants.h> #include <simgear/debug/logstream.hxx> +#include <simgear/scene/model/location.hxx> - -#include <Main/fg_props.hxx> #include <Aircraft/aircraft.hxx> #include <Controls/controls.hxx> #include <Model/model.hxx> -#include <Main/location.hxx> #include <FDM/flight.hxx> #include <FDM/LaRCsim/ls_cockpit.h> #include <FDM/LaRCsim/ls_generic.h> #include <FDM/LaRCsim/ls_interface.h> #include <FDM/LaRCsimIC.hxx> #include <FDM/UIUCModel/uiuc_aircraft.h> +#include <Main/fg_props.hxx> #include <Model/acmodel.hxx> #include "IO360.hxx" diff --git a/src/FDM/YASim/FGFDM.hpp b/src/FDM/YASim/FGFDM.hpp index f67afe9f4..cd91e50d4 100644 --- a/src/FDM/YASim/FGFDM.hpp +++ b/src/FDM/YASim/FGFDM.hpp @@ -2,7 +2,7 @@ #define _FGFDM_HPP #include <simgear/xml/easyxml.hxx> -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include "Airplane.hpp" #include "Vector.hpp" diff --git a/src/FDM/YASim/Makefile.am b/src/FDM/YASim/Makefile.am index d8b62c4fc..f74548c99 100644 --- a/src/FDM/YASim/Makefile.am +++ b/src/FDM/YASim/Makefile.am @@ -55,6 +55,6 @@ yasim_SOURCES = yasim-test.cpp \ Vector.hpp \ Wing.cpp Wing.hpp -yasim_LDADD = -lsgxml -lsgmisc -lsgdebug +yasim_LDADD = -lsgxml -lsgprops -lsgmisc -lsgdebug INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src diff --git a/src/FDM/YASim/YASim.cxx b/src/FDM/YASim/YASim.cxx index f7f634165..f1cbe429e 100644 --- a/src/FDM/YASim/YASim.cxx +++ b/src/FDM/YASim/YASim.cxx @@ -1,11 +1,12 @@ -#include <simgear/misc/sg_path.hxx> #include <simgear/debug/logstream.hxx> +#include <simgear/misc/sg_path.hxx> +#include <simgear/scene/model/location.hxx> #include <simgear/xml/easyxml.hxx> + #include <Main/globals.hxx> #include <Main/fg_props.hxx> #include <Model/acmodel.hxx> #include <Model/model.hxx> -#include <Main/location.hxx> #include "FGFDM.hpp" #include "Atmosphere.hpp" diff --git a/src/FDM/YASim/yasim-test.cpp b/src/FDM/YASim/yasim-test.cpp index 4e18b5cdf..5693c898a 100644 --- a/src/FDM/YASim/yasim-test.cpp +++ b/src/FDM/YASim/yasim-test.cpp @@ -1,7 +1,7 @@ #include <stdio.h> +#include <simgear/props/props.hxx> #include <simgear/xml/easyxml.hxx> -#include <simgear/misc/props.hxx> #include "FGFDM.hpp" #include "Airplane.hpp" diff --git a/src/FDM/flight.cxx b/src/FDM/flight.cxx index c7f6b0944..59bc6cbc0 100644 --- a/src/FDM/flight.cxx +++ b/src/FDM/flight.cxx @@ -28,13 +28,13 @@ #include <simgear/constants.h> #include <simgear/debug/logstream.hxx> #include <simgear/math/sg_geodesy.hxx> +#include <simgear/scene/model/location.hxx> #include <simgear/timing/timestamp.hxx> #include <Scenery/scenery.hxx> #include <FDM/LaRCsim/ls_interface.h> #include <Main/globals.hxx> #include <Main/fg_props.hxx> -#include <Main/location.hxx> #include <Model/model.hxx> #include <Model/acmodel.hxx> diff --git a/src/GUI/dialog.hxx b/src/GUI/dialog.hxx index cf0c199f8..a399849ff 100644 --- a/src/GUI/dialog.hxx +++ b/src/GUI/dialog.hxx @@ -10,7 +10,7 @@ #include <plib/pu.h> #include <simgear/compiler.h> // for SG_USING_STD -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include <vector> SG_USING_STD(vector); diff --git a/src/GUI/gui.cxx b/src/GUI/gui.cxx index e853760b1..c4d1a05f2 100644 --- a/src/GUI/gui.cxx +++ b/src/GUI/gui.cxx @@ -34,10 +34,10 @@ # include <windows.h> #endif -#include <simgear/misc/props.hxx> -#include <simgear/misc/props_io.hxx> #include <simgear/misc/exception.hxx> #include <simgear/misc/sg_path.hxx> +#include <simgear/props/props.hxx> +#include <simgear/props/props_io.hxx> #include <plib/pu.h> diff --git a/src/GUI/new_gui.hxx b/src/GUI/new_gui.hxx index 637f2c592..35cc3d831 100644 --- a/src/GUI/new_gui.hxx +++ b/src/GUI/new_gui.hxx @@ -10,7 +10,7 @@ #include <plib/pu.h> #include <simgear/compiler.h> // for SG_USING_STD -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include <vector> SG_USING_STD(vector); diff --git a/src/GUI/prop_picker.cxx b/src/GUI/prop_picker.cxx index 445128d34..20480755f 100755 --- a/src/GUI/prop_picker.cxx +++ b/src/GUI/prop_picker.cxx @@ -35,13 +35,15 @@ # include <config.h> #endif -#include "prop_picker.hxx" -#include <Main/globals.hxx> - #include <simgear/compiler.h> -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include STL_STRING + +#include <Main/globals.hxx> + +#include "prop_picker.hxx" + SG_USING_STD(string); // A local alternative name, for use when a variable called "string" is in scope - e.g. in classes derived from puInput. diff --git a/src/GUI/prop_picker.hxx b/src/GUI/prop_picker.hxx index 16f92aa67..e2c293a74 100755 --- a/src/GUI/prop_picker.hxx +++ b/src/GUI/prop_picker.hxx @@ -7,7 +7,7 @@ #include <stdio.h> #include "gui.h" -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> void prop_pickerInit(); void prop_pickerView( puObject * ); diff --git a/src/Input/input.cxx b/src/Input/input.cxx index a6c578e93..a2419ca9b 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -45,7 +45,7 @@ #include <simgear/constants.h> #include <simgear/debug/logstream.hxx> -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include <Aircraft/aircraft.hxx> #include <Autopilot/auto_gui.hxx> @@ -104,7 +104,7 @@ FGBinding::read (const SGPropertyNode * node) { const SGPropertyNode * conditionNode = node->getChild("condition"); if (conditionNode != 0) - setCondition(fgReadCondition(conditionNode)); + setCondition(fgReadCondition(globals->get_props(), conditionNode)); _command_name = node->getStringValue("command", ""); if (_command_name.empty()) { diff --git a/src/Input/input.hxx b/src/Input/input.hxx index d8a4eae13..2dc81f5a5 100644 --- a/src/Input/input.hxx +++ b/src/Input/input.hxx @@ -33,7 +33,8 @@ #include <simgear/compiler.h> #include <simgear/misc/commands.hxx> -#include <simgear/misc/props.hxx> +#include <simgear/props/condition.hxx> +#include <simgear/props/props.hxx> #include <Main/fgfs.hxx> #include <Main/fg_props.hxx> diff --git a/src/Instrumentation/airspeed_indicator.hxx b/src/Instrumentation/airspeed_indicator.hxx index e416e7395..8f0cfd45d 100644 --- a/src/Instrumentation/airspeed_indicator.hxx +++ b/src/Instrumentation/airspeed_indicator.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> diff --git a/src/Instrumentation/altimeter.hxx b/src/Instrumentation/altimeter.hxx index 439a677d0..0615e021a 100644 --- a/src/Instrumentation/altimeter.hxx +++ b/src/Instrumentation/altimeter.hxx @@ -11,7 +11,7 @@ # error This library requires C++ #endif -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include <Main/fgfs.hxx> diff --git a/src/Instrumentation/attitude_indicator.hxx b/src/Instrumentation/attitude_indicator.hxx index d754e2873..db68dd98b 100644 --- a/src/Instrumentation/attitude_indicator.hxx +++ b/src/Instrumentation/attitude_indicator.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> #include "gyro.hxx" diff --git a/src/Instrumentation/dme.hxx b/src/Instrumentation/dme.hxx index 266c5f6f7..c70c43ab8 100644 --- a/src/Instrumentation/dme.hxx +++ b/src/Instrumentation/dme.hxx @@ -12,7 +12,8 @@ #endif #include <simgear/math/point3d.hxx> -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> + #include <Main/fgfs.hxx> diff --git a/src/Instrumentation/gps.hxx b/src/Instrumentation/gps.hxx index 61b098680..78025aae2 100644 --- a/src/Instrumentation/gps.hxx +++ b/src/Instrumentation/gps.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> diff --git a/src/Instrumentation/heading_indicator.hxx b/src/Instrumentation/heading_indicator.hxx index 90d62104c..908495adc 100644 --- a/src/Instrumentation/heading_indicator.hxx +++ b/src/Instrumentation/heading_indicator.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> #include "gyro.hxx" diff --git a/src/Instrumentation/mag_compass.hxx b/src/Instrumentation/mag_compass.hxx index 61fb00640..f16a22287 100644 --- a/src/Instrumentation/mag_compass.hxx +++ b/src/Instrumentation/mag_compass.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> diff --git a/src/Instrumentation/slip_skid_ball.hxx b/src/Instrumentation/slip_skid_ball.hxx index 14010af02..d3e3e076b 100644 --- a/src/Instrumentation/slip_skid_ball.hxx +++ b/src/Instrumentation/slip_skid_ball.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> #include "gyro.hxx" diff --git a/src/Instrumentation/turn_indicator.hxx b/src/Instrumentation/turn_indicator.hxx index e730f7476..89681cfea 100644 --- a/src/Instrumentation/turn_indicator.hxx +++ b/src/Instrumentation/turn_indicator.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> #include "gyro.hxx" diff --git a/src/Instrumentation/vertical_speed_indicator.hxx b/src/Instrumentation/vertical_speed_indicator.hxx index 876fc5ef4..007d8ace5 100644 --- a/src/Instrumentation/vertical_speed_indicator.hxx +++ b/src/Instrumentation/vertical_speed_indicator.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> diff --git a/src/Main/Makefile.am b/src/Main/Makefile.am index 8c58124db..d47288528 100644 --- a/src/Main/Makefile.am +++ b/src/Main/Makefile.am @@ -54,8 +54,7 @@ fgfs_SOURCES = \ splash.cxx splash.hxx \ util.cxx util.hxx \ viewer.cxx viewer.hxx \ - viewmgr.cxx viewmgr.hxx \ - location.cxx location.hxx + viewmgr.cxx viewmgr.hxx fgfs_LDADD = \ $(top_builddir)/src/Aircraft/libAircraft.a \ @@ -89,8 +88,8 @@ fgfs_LDADD = \ $(top_builddir)/src/Systems/libSystems.a \ $(top_builddir)/src/Time/libTime.a \ $(WEATHER_LIBS) \ - -lsgroute -lsgsky -lsgephem -lsgtiming -lsgio -lsgscreen \ - -lsgmath -lsgbucket -lsgdebug -lsgmagvar -lsgmisc -lsgxml \ + -lsgroute -lsgsky -lsgephem -lsgmodel -lsgtiming -lsgio -lsgscreen \ + -lsgmath -lsgbucket -lsgprops -lsgdebug -lsgmagvar -lsgmisc -lsgxml \ -lsgserial \ $(THREAD_LIBS) \ -lplibpu -lplibfnt -lplibjs -lplibnet -lplibssg -lplibsg -lplibul \ diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index 389c28fc6..6e14ee674 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -8,11 +8,11 @@ #include STL_STRING #include STL_FSTREAM +#include <simgear/sg_inlines.h> #include <simgear/debug/logstream.hxx> #include <simgear/math/sg_random.h> #include <simgear/misc/commands.hxx> -#include <simgear/misc/props.hxx> -#include <simgear/sg_inlines.h> +#include <simgear/props/props.hxx> #include <Cockpit/panel.hxx> #include <Cockpit/panel_io.hxx> @@ -22,7 +22,7 @@ #include <GUI/dialog.hxx> #include <Scenery/tilemgr.hxx> #if defined(HAVE_PLIB_PSL) -#include <Scripting/scriptmgr.hxx> +# include <Scripting/scriptmgr.hxx> #endif #include <Time/tmp.hxx> @@ -196,7 +196,7 @@ do_reinit (const SGPropertyNode * arg) vector<SGPropertyNode_ptr> subsystems = arg->getChildren("subsystem"); if (subsystems.size() == 0) globals->get_subsystem_mgr()->reinit(); - else for (int i = 0; i < subsystems.size(); i++) { + else for ( unsigned int i = 0; i < subsystems.size(); i++ ) { const char * name = subsystems[i]->getStringValue(); FGSubsystem * subsystem = globals->get_subsystem(name); if (subsystem == 0) { @@ -220,7 +220,7 @@ do_suspend (const SGPropertyNode * arg) bool result = true; vector<SGPropertyNode_ptr> subsystems = arg->getChildren("subsystem"); - for (int i = 0; i < subsystems.size(); i++) { + for ( unsigned int i = 0; i < subsystems.size(); i++ ) { const char * name = subsystems[i]->getStringValue(); FGSubsystem * subsystem = globals->get_subsystem(name); if (subsystem == 0) { @@ -244,7 +244,7 @@ do_resume (const SGPropertyNode * arg) bool result = true; vector<SGPropertyNode_ptr> subsystems = arg->getChildren("subsystem"); - for (int i = 0; i < subsystems.size(); i++) { + for ( unsigned int i = 0; i < subsystems.size(); i++ ) { const char * name = subsystems[i]->getStringValue(); FGSubsystem * subsystem = globals->get_subsystem(name); if (subsystem == 0) { diff --git a/src/Main/fg_commands.hxx b/src/Main/fg_commands.hxx index 3fb0af3a0..92a75a8a6 100644 --- a/src/Main/fg_commands.hxx +++ b/src/Main/fg_commands.hxx @@ -17,7 +17,7 @@ #endif #include <simgear/misc/commands.hxx> -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> /** * Initialize the built-in commands. diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index e2e23766e..8f122720a 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -1298,12 +1298,12 @@ SGTime *fgInitTime() { // gear, its initialization call should located in this routine. // Returns non-zero if a problem encountered. bool fgInitSubsystems() { - static const SGPropertyNode *longitude - = fgGetNode("/sim/presets/longitude-deg"); - static const SGPropertyNode *latitude - = fgGetNode("/sim/presets/latitude-deg"); - static const SGPropertyNode *altitude - = fgGetNode("/sim/presets/altitude-ft"); + // static const SGPropertyNode *longitude + // = fgGetNode("/sim/presets/longitude-deg"); + // static const SGPropertyNode *latitude + // = fgGetNode("/sim/presets/latitude-deg"); + // static const SGPropertyNode *altitude + // = fgGetNode("/sim/presets/altitude-ft"); fgLIGHT *l = &cur_light_params; @@ -1669,10 +1669,10 @@ bool fgInitSubsystems() { void fgReInitSubsystems() { - static const SGPropertyNode *longitude - = fgGetNode("/sim/presets/longitude-deg"); - static const SGPropertyNode *latitude - = fgGetNode("/sim/presets/latitude-deg"); + // static const SGPropertyNode *longitude + // = fgGetNode("/sim/presets/longitude-deg"); + // static const SGPropertyNode *latitude + // = fgGetNode("/sim/presets/latitude-deg"); static const SGPropertyNode *altitude = fgGetNode("/sim/presets/altitude-ft"); static const SGPropertyNode *master_freeze diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 8b2f202ae..654a19675 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -857,398 +857,4 @@ fgUntie (const char * name) } - - -//////////////////////////////////////////////////////////////////////// -// Implementation of FGCondition. -//////////////////////////////////////////////////////////////////////// - -FGCondition::FGCondition () -{ -} - -FGCondition::~FGCondition () -{ -} - - - -//////////////////////////////////////////////////////////////////////// -// Implementation of FGPropertyCondition. -//////////////////////////////////////////////////////////////////////// - -FGPropertyCondition::FGPropertyCondition (const char * propname) - : _node(fgGetNode(propname, true)) -{ -} - -FGPropertyCondition::~FGPropertyCondition () -{ -} - - - -//////////////////////////////////////////////////////////////////////// -// Implementation of FGNotCondition. -//////////////////////////////////////////////////////////////////////// - -FGNotCondition::FGNotCondition (FGCondition * condition) - : _condition(condition) -{ -} - -FGNotCondition::~FGNotCondition () -{ - delete _condition; -} - -bool -FGNotCondition::test () const -{ - return !(_condition->test()); -} - - - -//////////////////////////////////////////////////////////////////////// -// Implementation of FGAndCondition. -//////////////////////////////////////////////////////////////////////// - -FGAndCondition::FGAndCondition () -{ -} - -FGAndCondition::~FGAndCondition () -{ - for (unsigned int i = 0; i < _conditions.size(); i++) - delete _conditions[i]; -} - -bool -FGAndCondition::test () const -{ - int nConditions = _conditions.size(); - for (int i = 0; i < nConditions; i++) { - if (!_conditions[i]->test()) - return false; - } - return true; -} - -void -FGAndCondition::addCondition (FGCondition * condition) -{ - _conditions.push_back(condition); -} - - - -//////////////////////////////////////////////////////////////////////// -// Implementation of FGOrCondition. -//////////////////////////////////////////////////////////////////////// - -FGOrCondition::FGOrCondition () -{ -} - -FGOrCondition::~FGOrCondition () -{ - for (unsigned int i = 0; i < _conditions.size(); i++) - delete _conditions[i]; -} - -bool -FGOrCondition::test () const -{ - int nConditions = _conditions.size(); - for (int i = 0; i < nConditions; i++) { - if (_conditions[i]->test()) - return true; - } - return false; -} - -void -FGOrCondition::addCondition (FGCondition * condition) -{ - _conditions.push_back(condition); -} - - - -//////////////////////////////////////////////////////////////////////// -// Implementation of FGComparisonCondition. -//////////////////////////////////////////////////////////////////////// - -static int -doComparison (const SGPropertyNode * left, const SGPropertyNode *right) -{ - switch (left->getType()) { - case SGPropertyNode::BOOL: { - bool v1 = left->getBoolValue(); - bool v2 = right->getBoolValue(); - if (v1 < v2) - return FGComparisonCondition::LESS_THAN; - else if (v1 > v2) - return FGComparisonCondition::GREATER_THAN; - else - return FGComparisonCondition::EQUALS; - break; - } - case SGPropertyNode::INT: { - int v1 = left->getIntValue(); - int v2 = right->getIntValue(); - if (v1 < v2) - return FGComparisonCondition::LESS_THAN; - else if (v1 > v2) - return FGComparisonCondition::GREATER_THAN; - else - return FGComparisonCondition::EQUALS; - break; - } - case SGPropertyNode::LONG: { - long v1 = left->getLongValue(); - long v2 = right->getLongValue(); - if (v1 < v2) - return FGComparisonCondition::LESS_THAN; - else if (v1 > v2) - return FGComparisonCondition::GREATER_THAN; - else - return FGComparisonCondition::EQUALS; - break; - } - case SGPropertyNode::FLOAT: { - float v1 = left->getFloatValue(); - float v2 = right->getFloatValue(); - if (v1 < v2) - return FGComparisonCondition::LESS_THAN; - else if (v1 > v2) - return FGComparisonCondition::GREATER_THAN; - else - return FGComparisonCondition::EQUALS; - break; - } - case SGPropertyNode::DOUBLE: { - double v1 = left->getDoubleValue(); - double v2 = right->getDoubleValue(); - if (v1 < v2) - return FGComparisonCondition::LESS_THAN; - else if (v1 > v2) - return FGComparisonCondition::GREATER_THAN; - else - return FGComparisonCondition::EQUALS; - break; - } - case SGPropertyNode::STRING: - case SGPropertyNode::NONE: - case SGPropertyNode::UNSPECIFIED: { - string v1 = left->getStringValue(); - string v2 = right->getStringValue(); - if (v1 < v2) - return FGComparisonCondition::LESS_THAN; - else if (v1 > v2) - return FGComparisonCondition::GREATER_THAN; - else - return FGComparisonCondition::EQUALS; - break; - } - } - throw sg_exception("Unrecognized node type"); - return 0; -} - - -FGComparisonCondition::FGComparisonCondition (Type type, bool reverse) - : _type(type), - _reverse(reverse), - _left_property(0), - _right_property(0), - _right_value(0) -{ -} - -FGComparisonCondition::~FGComparisonCondition () -{ - delete _right_value; -} - -bool -FGComparisonCondition::test () const -{ - // Always fail if incompletely specified - if (_left_property == 0 || - (_right_property == 0 && _right_value == 0)) - return false; - - // Get LESS_THAN, EQUALS, or GREATER_THAN - int cmp = - doComparison(_left_property, - (_right_property != 0 ? _right_property : _right_value)); - if (!_reverse) - return (cmp == _type); - else - return (cmp != _type); -} - -void -FGComparisonCondition::setLeftProperty (const char * propname) -{ - _left_property = fgGetNode(propname, true); -} - -void -FGComparisonCondition::setRightProperty (const char * propname) -{ - delete _right_value; - _right_value = 0; - _right_property = fgGetNode(propname, true); -} - -void -FGComparisonCondition::setRightValue (const SGPropertyNode *node) -{ - _right_property = 0; - delete _right_value; - _right_value = new SGPropertyNode(*node); -} - - - -//////////////////////////////////////////////////////////////////////// -// Read a condition and use it if necessary. -//////////////////////////////////////////////////////////////////////// - - // Forward declaration -static FGCondition * readCondition (const SGPropertyNode * node); - -static FGCondition * -readPropertyCondition (const SGPropertyNode * node) -{ - return new FGPropertyCondition(node->getStringValue()); -} - -static FGCondition * -readNotCondition (const SGPropertyNode * node) -{ - int nChildren = node->nChildren(); - for (int i = 0; i < nChildren; i++) { - const SGPropertyNode * child = node->getChild(i); - FGCondition * condition = readCondition(child); - if (condition != 0) - return new FGNotCondition(condition); - } - SG_LOG(SG_COCKPIT, SG_ALERT, "Panel: empty 'not' condition"); - return 0; -} - -static FGCondition * -readAndConditions (const SGPropertyNode * node) -{ - FGAndCondition * andCondition = new FGAndCondition; - int nChildren = node->nChildren(); - for (int i = 0; i < nChildren; i++) { - const SGPropertyNode * child = node->getChild(i); - FGCondition * condition = readCondition(child); - if (condition != 0) - andCondition->addCondition(condition); - } - return andCondition; -} - -static FGCondition * -readOrConditions (const SGPropertyNode * node) -{ - FGOrCondition * orCondition = new FGOrCondition; - int nChildren = node->nChildren(); - for (int i = 0; i < nChildren; i++) { - const SGPropertyNode * child = node->getChild(i); - FGCondition * condition = readCondition(child); - if (condition != 0) - orCondition->addCondition(condition); - } - return orCondition; -} - -static FGCondition * -readComparison (const SGPropertyNode * node, - FGComparisonCondition::Type type, - bool reverse) -{ - FGComparisonCondition * condition = new FGComparisonCondition(type, reverse); - condition->setLeftProperty(node->getStringValue("property[0]")); - if (node->hasValue("property[1]")) - condition->setRightProperty(node->getStringValue("property[1]")); - else - condition->setRightValue(node->getChild("value", 0)); - - return condition; -} - -static FGCondition * -readCondition (const SGPropertyNode * node) -{ - const string &name = node->getName(); - if (name == "property") - return readPropertyCondition(node); - else if (name == "not") - return readNotCondition(node); - else if (name == "and") - return readAndConditions(node); - else if (name == "or") - return readOrConditions(node); - else if (name == "less-than") - return readComparison(node, FGComparisonCondition::LESS_THAN, false); - else if (name == "less-than-equals") - return readComparison(node, FGComparisonCondition::GREATER_THAN, true); - else if (name == "greater-than") - return readComparison(node, FGComparisonCondition::GREATER_THAN, false); - else if (name == "greater-than-equals") - return readComparison(node, FGComparisonCondition::LESS_THAN, true); - else if (name == "equals") - return readComparison(node, FGComparisonCondition::EQUALS, false); - else if (name == "not-equals") - return readComparison(node, FGComparisonCondition::EQUALS, true); - else - return 0; -} - - - -//////////////////////////////////////////////////////////////////////// -// Implementation of FGConditional. -//////////////////////////////////////////////////////////////////////// - -FGConditional::FGConditional () - : _condition (0) -{ -} - -FGConditional::~FGConditional () -{ - delete _condition; -} - -void -FGConditional::setCondition (FGCondition * condition) -{ - delete _condition; - _condition = condition; -} - -bool -FGConditional::test () const -{ - return ((_condition == 0) || _condition->test()); -} - - - -// The top-level is always an implicit 'and' group -FGCondition * -fgReadCondition (const SGPropertyNode * node) -{ - return readAndConditions(node); -} - - // end of fg_props.cxx diff --git a/src/Main/fg_props.hxx b/src/Main/fg_props.hxx index 4a5822997..703636a96 100644 --- a/src/Main/fg_props.hxx +++ b/src/Main/fg_props.hxx @@ -7,8 +7,8 @@ #define __FG_PROPS_HXX 1 #include <simgear/debug/logstream.hxx> -#include <simgear/misc/props.hxx> -#include <simgear/misc/props_io.hxx> +#include <simgear/props/props.hxx> +#include <simgear/props/props_io.hxx> #include "globals.hxx" @@ -539,162 +539,5 @@ fgTie (const char * name, T * obj, int index, } - -//////////////////////////////////////////////////////////////////////// -// Conditions. -//////////////////////////////////////////////////////////////////////// - - -/** - * An encoded condition. - * - * This class encodes a single condition of some sort, possibly - * connected with properties. - * - * This class should migrate to somewhere more general. - */ -class FGCondition -{ -public: - FGCondition (); - virtual ~FGCondition (); - virtual bool test () const = 0; -}; - - -/** - * Condition for a single property. - * - * This condition is true only if the property returns a boolean - * true value. - */ -class FGPropertyCondition : public FGCondition -{ -public: - FGPropertyCondition (const char * propname); - virtual ~FGPropertyCondition (); - virtual bool test () const { return _node->getBoolValue(); } -private: - const SGPropertyNode * _node; -}; - - -/** - * Condition for a 'not' operator. - * - * This condition is true only if the child condition is false. - */ -class FGNotCondition : public FGCondition -{ -public: - // transfer pointer ownership - FGNotCondition (FGCondition * condition); - virtual ~FGNotCondition (); - virtual bool test () const; -private: - FGCondition * _condition; -}; - - -/** - * Condition for an 'and' group. - * - * This condition is true only if all of the conditions - * in the group are true. - */ -class FGAndCondition : public FGCondition -{ -public: - FGAndCondition (); - virtual ~FGAndCondition (); - virtual bool test () const; - // transfer pointer ownership - virtual void addCondition (FGCondition * condition); -private: - vector<FGCondition *> _conditions; -}; - - -/** - * Condition for an 'or' group. - * - * This condition is true if at least one of the conditions in the - * group is true. - */ -class FGOrCondition : public FGCondition -{ -public: - FGOrCondition (); - virtual ~FGOrCondition (); - virtual bool test () const; - // transfer pointer ownership - virtual void addCondition (FGCondition * condition); -private: - vector<FGCondition *> _conditions; -}; - - -/** - * Abstract base class for property comparison conditions. - */ -class FGComparisonCondition : public FGCondition -{ -public: - enum Type { - LESS_THAN, - GREATER_THAN, - EQUALS - }; - FGComparisonCondition (Type type, bool reverse = false); - virtual ~FGComparisonCondition (); - virtual bool test () const; - virtual void setLeftProperty (const char * propname); - virtual void setRightProperty (const char * propname); - // will make a local copy - virtual void setRightValue (const SGPropertyNode * value); -private: - Type _type; - bool _reverse; - const SGPropertyNode * _left_property; - const SGPropertyNode * _right_property; - const SGPropertyNode * _right_value; -}; - - -/** - * Base class for a conditional components. - * - * This class manages the conditions and tests; the component should - * invoke the test() method whenever it needs to decide whether to - * active itself, draw itself, and so on. - */ -class FGConditional -{ -public: - FGConditional (); - virtual ~FGConditional (); - // transfer pointer ownership - virtual void setCondition (FGCondition * condition); - virtual const FGCondition * getCondition () const { return _condition; } - virtual bool test () const; -private: - FGCondition * _condition; -}; - - -/** - * Global function to make a condition out of properties. - * - * The top-level is always an implicit 'and' group, whatever the - * node's name (it should usually be "condition"). - * - * @param node The top-level condition node (usually named "condition"). - * @return A pointer to a newly-allocated condition; it is the - * responsibility of the caller to delete the condition when - * it is no longer needed. - */ -FGCondition * fgReadCondition (const SGPropertyNode * node); - - #endif // __FG_PROPS_HXX diff --git a/src/Main/fgfs.hxx b/src/Main/fgfs.hxx index 65472dce8..bc4358931 100644 --- a/src/Main/fgfs.hxx +++ b/src/Main/fgfs.hxx @@ -49,7 +49,7 @@ SG_USING_STD(vector); #include <map> SG_USING_STD(map); -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> diff --git a/src/Main/logger.hxx b/src/Main/logger.hxx index 6b7d95291..4818e44f0 100644 --- a/src/Main/logger.hxx +++ b/src/Main/logger.hxx @@ -20,7 +20,7 @@ #include <simgear/compiler.h> #include <simgear/debug/logstream.hxx> #include <simgear/misc/exception.hxx> -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> SG_USING_STD(ostream); SG_USING_STD(vector); diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 6fd0c837f..da8bfde6e 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -77,6 +77,7 @@ SG_USING_STD(endl); #include <simgear/math/polar3d.hxx> #include <simgear/math/sg_random.h> #include <simgear/misc/sg_path.hxx> +#include <simgear/scene/model/location.hxx> #ifdef FG_USE_CLOUDS_3D # include <simgear/sky/clouds3d/SkySceneLoader.hpp> # include <simgear/sky/clouds3d/SkyUtil.hpp> @@ -105,7 +106,6 @@ SG_USING_STD(endl); #include <Model/loader.hxx> #include <Model/model.hxx> #include <Model/modelmgr.hxx> -#include <Main/location.hxx> #include <Model/panelnode.hxx> #ifdef FG_NETWORK_OLK #include <NetworkOLK/network.h> @@ -445,12 +445,12 @@ void fgRenderFrame() { // Process/manage pending events global_events.update( delta_time_sec ); - static const SGPropertyNode *longitude - = fgGetNode("/position/longitude-deg"); - static const SGPropertyNode *latitude - = fgGetNode("/position/latitude-deg"); - static const SGPropertyNode *altitude - = fgGetNode("/position/altitude-ft"); + // static const SGPropertyNode *longitude + // = fgGetNode("/position/longitude-deg"); + // static const SGPropertyNode *latitude + // = fgGetNode("/position/latitude-deg"); + // static const SGPropertyNode *altitude + // = fgGetNode("/position/altitude-ft"); static const SGPropertyNode *groundlevel_nearplane = fgGetNode("/sim/current-view/ground-level-nearplane-m"); @@ -1277,7 +1277,7 @@ static void fgMainLoop( void ) { visibility_meters ); globals->get_tile_mgr()-> update( acmodel_location, visibility_meters, - acmodel_location->get_absolute_view_pos() ); + acmodel_location->get_absolute_view_pos(globals->get_scenery()->get_center()) ); // save results of update in FGLocation for fdm... if ( globals->get_scenery()->get_cur_elev() > -9990 ) { acmodel_location-> @@ -1955,7 +1955,7 @@ void fgLoadDCS(void) { if ( strcmp(obj_filename,"repeat") != 0) { ship_obj = - globals->get_model_loader()->load_model( obj_filename ); + globals->get_model_loader()->load_model( globals->get_fg_root(), obj_filename, globals->get_props(), globals->get_sim_time_sec() ); } if ( ship_obj != NULL ) { @@ -1976,11 +1976,11 @@ void fgLoadDCS(void) { // temporary hack for deck lights - ultimately should move to PLib (when??) //const char *extn = file_extension ( obj_filename ) ; if ( objc == 1 ){ - ssgVertexArray *lights = new ssgVertexArray( 100 ); + // ssgVertexArray *lights = new ssgVertexArray( 100 ); ssgVertexArray *lightpoints = new ssgVertexArray( 100 ); ssgVertexArray *lightnormals = new ssgVertexArray( 100 ); ssgVertexArray *lightdir = new ssgVertexArray( 100 ); - int ltype[500], light_type; + int ltype[500], light_type = 0; static int ltcount = 0; string token; sgVec3 rway_dir,rway_normal,lightpt; diff --git a/src/Main/viewer.cxx b/src/Main/viewer.cxx index 8fbaea6d4..fd7b13312 100644 --- a/src/Main/viewer.cxx +++ b/src/Main/viewer.cxx @@ -485,7 +485,8 @@ FGViewer::updateFromModelLocation (FGLocation * location) void FGViewer::updateAtModelLocation (FGLocation * location) { - sgCopyMat4(ATLOCAL, location->getCachedTransformMatrix()); + sgCopyMat4(ATLOCAL, + location->getCachedTransformMatrix()); } void @@ -495,7 +496,8 @@ FGViewer::recalcOurOwnLocation (FGLocation * location, double lon_deg, double la // update from our own data... location->setPosition( lon_deg, lat_deg, alt_ft ); location->setOrientation( roll_deg, pitch_deg, heading_deg ); - sgCopyMat4(LOCAL, location->getTransformMatrix()); + sgCopyMat4(LOCAL, + location->getTransformMatrix(globals->get_scenery()->get_center())); } // recalc() is done every time one of the setters is called (making the @@ -519,7 +521,7 @@ FGViewer::recalcLookFrom () { sgVec3 right, forward; - sgVec3 eye_pos; + // sgVec3 eye_pos; sgVec3 position_offset; // eye position offsets (xyz) // LOOKFROM mode... @@ -606,7 +608,9 @@ FGViewer::recalcLookAt () // calculate the "at" target object positon relative to eye or view's tile center... sgdVec3 dVec3; sgdSetVec3(dVec3, _location->get_tile_center()[0], _location->get_tile_center()[1], _location->get_tile_center()[2]); - sgdSubVec3(dVec3, _target_location->get_absolute_view_pos(), dVec3 ); + sgdSubVec3(dVec3, + _target_location->get_absolute_view_pos(globals->get_scenery()->get_center()), + dVec3 ); sgSetVec3(at_pos, dVec3[0], dVec3[1], dVec3[2]); // Update location data for eye... @@ -668,7 +672,8 @@ FGViewer::copyLocationData() // Get our friendly vectors from the eye location... sgCopyVec3(_zero_elev_view_pos, _location->get_zero_elev()); sgCopyVec3(_relative_view_pos, _location->get_view_pos()); - sgdCopyVec3(_absolute_view_pos, _location->get_absolute_view_pos()); + sgdCopyVec3(_absolute_view_pos, + _location->get_absolute_view_pos(globals->get_scenery()->get_center())); sgCopyMat4(UP, _location->getCachedUpMatrix()); sgCopyVec3(_world_up, _location->get_world_up()); // these are the vectors that the sun and moon code like to get... diff --git a/src/Main/viewer.hxx b/src/Main/viewer.hxx index 52cb51f37..291f4a491 100644 --- a/src/Main/viewer.hxx +++ b/src/Main/viewer.hxx @@ -34,13 +34,12 @@ #include <simgear/compiler.h> #include <simgear/constants.h> +#include <simgear/scene/model/location.hxx> #include <plib/sg.h> // plib include #include "fgfs.hxx" -#include <Main/location.hxx> - #define FG_FOV_MIN 0.1 #define FG_FOV_MAX 179.9 diff --git a/src/Model/acmodel.cxx b/src/Model/acmodel.cxx index 786a6ba07..a39b76a3f 100644 --- a/src/Model/acmodel.cxx +++ b/src/Model/acmodel.cxx @@ -54,11 +54,17 @@ FGAircraftModel::init () _aircraft = new FGModelPlacement; string path = fgGetString("/sim/model/path", "Models/Geometry/glider.ac"); try { - _aircraft->init(path); + _aircraft->init( globals->get_fg_root(), + path, + globals->get_props(), + globals->get_sim_time_sec() ); } catch (const sg_exception &ex) { SG_LOG(SG_GENERAL, SG_ALERT, "Failed to load aircraft from " << path); SG_LOG(SG_GENERAL, SG_ALERT, "(Falling back to glider.ac.)"); - _aircraft->init("Models/Geometry/glider.ac"); + _aircraft->init( globals->get_fg_root(), + "Models/Geometry/glider.ac", + globals->get_props(), + globals->get_sim_time_sec() ); } _scene->addKid(_aircraft->getSceneGraph()); _selector->addKid(_aircraft->getSceneGraph()); @@ -94,7 +100,7 @@ FGAircraftModel::update (double dt) _aircraft->setOrientation(fgGetDouble("/orientation/roll-deg"), fgGetDouble("/orientation/pitch-deg"), fgGetDouble("/orientation/heading-deg")); - _aircraft->update(); + _aircraft->update( globals->get_scenery()->get_center() ); } diff --git a/src/Model/loader.cxx b/src/Model/loader.cxx index 5fcd8360e..0902bd8b1 100644 --- a/src/Model/loader.cxx +++ b/src/Model/loader.cxx @@ -5,7 +5,7 @@ #endif #include <simgear/compiler.h> -#include <simgear/misc/props.hxx> +#include <simgear/props/props.hxx> #include "loader.hxx" #include "model.hxx" @@ -61,13 +61,16 @@ FGModelLoader::~FGModelLoader () } ssgEntity * -FGModelLoader::load_model (const string &path) +FGModelLoader::load_model( const string &fg_root, + const string &path, + SGPropertyNode *prop_root, + double sim_time_sec ) { // FIXME: normalize path to // avoid duplicates. std::map<string, ssgBase *>::iterator it = _table.find(path); if (it == _table.end()) { - _table[path] = fgLoad3DModel((char *)path.c_str()); + _table[path] = fgLoad3DModel( fg_root, path, prop_root, sim_time_sec ); it = _table.find(path); it->second->ref(); // add one reference to keep it around } @@ -89,7 +92,7 @@ FGTextureLoader::~FGTextureLoader () } ssgTexture * -FGTextureLoader::load_texture (const string &path) +FGTextureLoader::load_texture( const string &fg_root, const string &path ) { std::map<string, ssgBase *>::iterator it = _table.find(path); if (it == _table.end()) { diff --git a/src/Model/loader.hxx b/src/Model/loader.hxx index 956e6bdcd..6606efb06 100644 --- a/src/Model/loader.hxx +++ b/src/Model/loader.hxx @@ -39,7 +39,10 @@ public: FGModelLoader (); virtual ~FGModelLoader (); - virtual ssgEntity * load_model (const string &path); + virtual ssgEntity * load_model( const string &fg_root, + const string &path, + SGPropertyNode *prop_root, + double sim_time_sec ); }; @@ -52,7 +55,8 @@ public: FGTextureLoader (); virtual ~FGTextureLoader (); - virtual ssgTexture * load_texture (const string &path); + virtual ssgTexture * load_texture( const string &fg_root, + const string &path ); }; #endif diff --git a/src/Model/model.cxx b/src/Model/model.cxx index 8160ccf06..254bc0731 100644 --- a/src/Model/model.cxx +++ b/src/Model/model.cxx @@ -20,11 +20,13 @@ #include <simgear/math/sg_geodesy.hxx> #include <simgear/misc/exception.hxx> #include <simgear/misc/sg_path.hxx> +#include <simgear/props/condition.hxx> +#include <simgear/props/props_io.hxx> +#include <simgear/scene/model/location.hxx> -#include <Main/fg_props.hxx> -#include <Main/globals.hxx> -#include <Main/location.hxx> -#include <Scenery/scenery.hxx> +// #include <Main/fg_props.hxx> +// #include <Main/globals.hxx> +// #include <Scenery/scenery.hxx> #include "model.hxx" #include "panelnode.hxx" @@ -177,7 +179,9 @@ static void make_animation (ssgBranch * model, const char * name, vector<SGPropertyNode_ptr> &name_nodes, - SGPropertyNode_ptr node) + SGPropertyNode *prop_root, + SGPropertyNode_ptr node, + double sim_time_sec ) { Animation * animation = 0; const char * type = node->getStringValue("type", "none"); @@ -188,15 +192,15 @@ make_animation (ssgBranch * model, } else if (!strcmp("billboard", type)) { animation = new BillboardAnimation(node); } else if (!strcmp("select", type)) { - animation = new SelectAnimation(node); + animation = new SelectAnimation(prop_root, node); } else if (!strcmp("spin", type)) { - animation = new SpinAnimation(node); + animation = new SpinAnimation(prop_root, node, sim_time_sec ); } else if (!strcmp("timed", type)) { animation = new TimedAnimation(node); } else if (!strcmp("rotate", type)) { - animation = new RotateAnimation(node); + animation = new RotateAnimation(prop_root, node); } else if (!strcmp("translate", type)) { - animation = new TranslateAnimation(node); + animation = new TranslateAnimation(prop_root, node); } else { animation = new NullAnimation(node); SG_LOG(SG_INPUT, SG_WARN, "Unknown animation type " << type); @@ -221,7 +225,7 @@ make_animation (ssgBranch * model, ssgBranch * branch = animation->getBranch(); splice_branch(branch, object); - for (int i = 1; i < name_nodes.size(); i++) { + for (unsigned int i = 1; i < name_nodes.size(); i++) { const char * name = name_nodes[i]->getStringValue(); object = find_named_node(model, name); if (object == 0) { @@ -246,7 +250,9 @@ make_animation (ssgBranch * model, //////////////////////////////////////////////////////////////////////// ssgBranch * -fgLoad3DModel (const string &path) +fgLoad3DModel( const string &fg_root, const string &path, + SGPropertyNode *prop_root, + double sim_time_sec ) { ssgBranch * model = 0; SGPropertyNode props; @@ -258,7 +264,7 @@ fgLoad3DModel (const string &path) xmlpath = modelpath; } else { - xmlpath = globals->get_fg_root(); + xmlpath = fg_root; xmlpath.append(modelpath.str()); } @@ -313,7 +319,8 @@ fgLoad3DModel (const string &path) const char * name = animation_nodes[i]->getStringValue("name", 0); vector<SGPropertyNode_ptr> name_nodes = animation_nodes[i]->getChildren("object-name"); - make_animation(model, name, name_nodes, animation_nodes[i]); + make_animation( model, name, name_nodes, prop_root, animation_nodes[i], + sim_time_sec); } // Load sub-models @@ -331,7 +338,8 @@ fgLoad3DModel (const string &path) node->getFloatValue("offsets/z-m", 0.0)); align->setTransform(res_matrix); - ssgBranch * kid = fgLoad3DModel(node->getStringValue("path")); + ssgBranch * kid = fgLoad3DModel( fg_root, node->getStringValue("path"), + prop_root, sim_time_sec ); align->addKid(kid); model->addKid(align); } @@ -420,13 +428,14 @@ BillboardAnimation::~BillboardAnimation () // Implementation of SelectAnimation //////////////////////////////////////////////////////////////////////// -SelectAnimation::SelectAnimation (SGPropertyNode_ptr props) +SelectAnimation::SelectAnimation( SGPropertyNode *prop_root, + SGPropertyNode_ptr props ) : Animation(props, new ssgSelector), _condition(0) { SGPropertyNode_ptr node = props->getChild("condition"); if (node != 0) - _condition = fgReadCondition(node); + _condition = fgReadCondition(prop_root, node); } SelectAnimation::~SelectAnimation () @@ -449,12 +458,14 @@ SelectAnimation::update () // Implementation of SpinAnimation //////////////////////////////////////////////////////////////////////// -SpinAnimation::SpinAnimation (SGPropertyNode_ptr props) +SpinAnimation::SpinAnimation( SGPropertyNode *prop_root, + SGPropertyNode_ptr props, + double sim_time_sec ) : Animation(props, new ssgTransform), - _prop(fgGetNode(props->getStringValue("property", "/null"), true)), + _prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)), _factor(props->getDoubleValue("factor", 1.0)), _position_deg(props->getDoubleValue("starting-position-deg", 0)), - _last_time_sec(globals->get_sim_time_sec()) + _last_time_sec( sim_time_sec /* globals->get_sim_time_sec() */ ) { _center[0] = props->getFloatValue("center/x-m", 0); _center[1] = props->getFloatValue("center/y-m", 0); @@ -470,11 +481,10 @@ SpinAnimation::~SpinAnimation () } void -SpinAnimation::update () +SpinAnimation::update( double sim_time_sec ) { - double sim_time = globals->get_sim_time_sec(); - double dt = sim_time - _last_time_sec; - _last_time_sec = sim_time; + double dt = sim_time_sec - _last_time_sec; + _last_time_sec = sim_time_sec; float velocity_rpms = (_prop->getDoubleValue() * _factor / 60.0); _position_deg += (dt * velocity_rpms * 360); @@ -505,9 +515,8 @@ TimedAnimation::~TimedAnimation () } void -TimedAnimation::update () +TimedAnimation::update( double sim_time_sec ) { - float sim_time_sec = globals->get_sim_time_sec(); if ((sim_time_sec - _last_time_sec) >= _duration_sec) { _last_time_sec = sim_time_sec; _step++; @@ -523,9 +532,10 @@ TimedAnimation::update () // Implementation of RotateAnimation //////////////////////////////////////////////////////////////////////// -RotateAnimation::RotateAnimation (SGPropertyNode_ptr props) +RotateAnimation::RotateAnimation( SGPropertyNode *prop_root, + SGPropertyNode_ptr props ) : Animation(props, new ssgTransform), - _prop(fgGetNode(props->getStringValue("property", "/null"), true)), + _prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)), _offset_deg(props->getDoubleValue("offset-deg", 0.0)), _factor(props->getDoubleValue("factor", 1.0)), _table(read_interpolation_table(props)), @@ -550,7 +560,7 @@ RotateAnimation::~RotateAnimation () } void -RotateAnimation::update () +RotateAnimation::update() { if (_table == 0) { _position_deg = _prop->getDoubleValue() * _factor + _offset_deg; @@ -571,9 +581,10 @@ RotateAnimation::update () // Implementation of TranslateAnimation //////////////////////////////////////////////////////////////////////// -TranslateAnimation::TranslateAnimation (SGPropertyNode_ptr props) +TranslateAnimation::TranslateAnimation( SGPropertyNode *prop_root, + SGPropertyNode_ptr props ) : Animation(props, new ssgTransform), - _prop(fgGetNode(props->getStringValue("property", "/null"), true)), + _prop((SGPropertyNode *)prop_root->getNode(props->getStringValue("property", "/null"), true)), _offset_m(props->getDoubleValue("offset-m", 0.0)), _factor(props->getDoubleValue("factor", 1.0)), _table(read_interpolation_table(props)), @@ -634,9 +645,12 @@ FGModelPlacement::~FGModelPlacement () } void -FGModelPlacement::init (const string &path) +FGModelPlacement::init( const string &fg_root, + const string &path, + SGPropertyNode *prop_root, + double sim_time_sec ) { - ssgBranch * model = fgLoad3DModel(path); + ssgBranch * model = fgLoad3DModel( fg_root, path, prop_root, sim_time_sec ); if (model != 0) _position->addKid(model); _selector->addKid(_position); @@ -644,12 +658,12 @@ FGModelPlacement::init (const string &path) } void -FGModelPlacement::update () +FGModelPlacement::update( const Point3D scenery_center ) { _location->setPosition( _lon_deg, _lat_deg, _elev_ft ); _location->setOrientation( _roll_deg, _pitch_deg, _heading_deg ); - sgCopyMat4(POS, _location->getTransformMatrix()); + sgCopyMat4( POS, _location->getTransformMatrix(scenery_center) ); sgVec3 trans; sgCopyVec3(trans, _location->get_view_pos()); diff --git a/src/Model/model.hxx b/src/Model/model.hxx index 313a5d9d3..e3cbe1d56 100644 --- a/src/Model/model.hxx +++ b/src/Model/model.hxx @@ -17,7 +17,8 @@ SG_USING_STD(vector); #include <plib/sg.h> #include <plib/ssg.h> -#include <simgear/misc/props.hxx> +#include <simgear/math/point3d.hxx> +#include <simgear/props/props.hxx> // Don't pull in the headers, since we don't need them here. @@ -51,7 +52,9 @@ class FGLocation; * Subsystems should not normally invoke this function directly; * instead, they should use the FGModelLoader declared in loader.hxx. */ -ssgBranch * fgLoad3DModel (const string &path); +ssgBranch * fgLoad3DModel( const string& fg_root, const string &path, + SGPropertyNode *prop_root, + double sim_time_sec ); @@ -131,7 +134,8 @@ public: class SelectAnimation : public Animation { public: - SelectAnimation (SGPropertyNode_ptr props); + SelectAnimation( SGPropertyNode *prop_root, + SGPropertyNode_ptr props ); virtual ~SelectAnimation (); virtual void update (); private: @@ -147,9 +151,11 @@ private: class SpinAnimation : public Animation { public: - SpinAnimation (SGPropertyNode_ptr props); + SpinAnimation( SGPropertyNode *prop_root, + SGPropertyNode_ptr props, + double sim_time_sec ); virtual ~SpinAnimation (); - virtual void update (); + virtual void update( double sim_time_sec ); private: SGPropertyNode_ptr _prop; double _factor; @@ -169,7 +175,7 @@ class TimedAnimation : public Animation public: TimedAnimation (SGPropertyNode_ptr props); virtual ~TimedAnimation (); - virtual void update (); + virtual void update( double sim_time_sec ); private: double _duration_sec; double _last_time_sec; @@ -185,9 +191,9 @@ private: class RotateAnimation : public Animation { public: - RotateAnimation (SGPropertyNode_ptr props); + RotateAnimation( SGPropertyNode *prop_root, SGPropertyNode_ptr props ); virtual ~RotateAnimation (); - virtual void update (); + virtual void update(); private: SGPropertyNode_ptr _prop; double _offset_deg; @@ -210,7 +216,8 @@ private: class TranslateAnimation : public Animation { public: - TranslateAnimation (SGPropertyNode_ptr props); + TranslateAnimation( SGPropertyNode *prop_root, + SGPropertyNode_ptr props ); virtual ~TranslateAnimation (); virtual void update (); private: @@ -243,8 +250,11 @@ public: FGModelPlacement (); virtual ~FGModelPlacement (); - virtual void init (const string &path); - virtual void update (); + virtual void init( const string &fg_root, + const string &path, + SGPropertyNode *prop_root, + double sim_time_sec ); + virtual void update( const Point3D scenery_center ); virtual ssgEntity * getSceneGraph () { return (ssgEntity *)_selector; } diff --git a/src/Model/modelmgr.cxx b/src/Model/modelmgr.cxx index 29693ecf1..609f7abdf 100644 --- a/src/Model/modelmgr.cxx +++ b/src/Model/modelmgr.cxx @@ -38,7 +38,10 @@ FGModelMgr::init () Instance * instance = new Instance; FGModelPlacement * model = new FGModelPlacement; instance->model = model; - model->init(node->getStringValue("path", "Models/Geometry/glider.ac")); + model->init( globals->get_fg_root(), + node->getStringValue("path", "Models/Geometry/glider.ac"), + globals->get_props(), + globals->get_sim_time_sec() ); // Set position and orientation either // indirectly through property refs @@ -120,7 +123,7 @@ FGModelMgr::update (double dt) if (instance->heading_deg_node != 0) model->setHeadingDeg(instance->heading_deg_node->getDoubleValue()); - instance->model->update(); + instance->model->update( globals->get_scenery()->get_center() ); } } diff --git a/src/Model/panelnode.cxx b/src/Model/panelnode.cxx index b257a3bee..30f2e4a6c 100644 --- a/src/Model/panelnode.cxx +++ b/src/Model/panelnode.cxx @@ -16,18 +16,21 @@ // Static (!) handling for all 3D panels in the program. Very // clumsy. Replace with per-aircraft handling. vector<FGPanelNode*> all_3d_panels; -bool fgHandle3DPanelMouseEvent(int button, int updown, int x, int y) +bool fgHandle3DPanelMouseEvent( int button, int updown, int x, int y ) { - for(int i=0; i<all_3d_panels.size(); i++) - if(all_3d_panels[i]->doMouseAction(button, updown, x, y)) + for ( unsigned int i = 0; i < all_3d_panels.size(); i++ ) { + if ( all_3d_panels[i]->doMouseAction(button, updown, x, y) ) { return true; + } + } return false; } void fgUpdate3DPanels() { - for(int i=0; i<all_3d_panels.size(); i++) + for ( unsigned int i = 0; i < all_3d_panels.size(); i++ ) { all_3d_panels[i]->getPanel()->updateMouseDelay(); + } } FGPanelNode::FGPanelNode(SGPropertyNode* props)