From bb2e5fb2c9ebc58a9f5757d88c2bfede2d5981a0 Mon Sep 17 00:00:00 2001 From: frohlich Date: Mon, 10 Aug 2009 05:21:44 +0000 Subject: [PATCH] Use the 'all but self' capability of the scenery elevaton code instead of playing with node masks. Modified Files: src/AIModel/AIAircraft.cxx src/AIModel/AIBallistic.cxx src/AIModel/AIBase.cxx src/AIModel/AIBase.hxx src/AIModel/AIShip.cxx src/AIModel/AIShip.hxx src/AIModel/AIThermal.cxx src/ATCDCL/AILocalTraffic.cxx --- src/AIModel/AIAircraft.cxx | 2 +- src/AIModel/AIBallistic.cxx | 4 ++-- src/AIModel/AIBase.cxx | 8 ++++++-- src/AIModel/AIBase.hxx | 4 ++++ src/AIModel/AIShip.cxx | 6 ------ src/AIModel/AIShip.hxx | 1 - src/AIModel/AIThermal.cxx | 2 +- src/ATCDCL/AILocalTraffic.cxx | 2 +- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index 7da692069..44a016889 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -412,7 +412,7 @@ void FGAIAircraft::getGroundElev(double dt) { } double alt; - if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(pos, 20000), alt, 0)) + if (getGroundElevationM(SGGeod::fromGeodM(pos, 20000), alt, 0)) tgt_altitude_ft = alt * SG_METER_TO_FEET; } } diff --git a/src/AIModel/AIBallistic.cxx b/src/AIModel/AIBallistic.cxx index 367f2e3f5..1ea75d7f2 100644 --- a/src/AIModel/AIBallistic.cxx +++ b/src/AIModel/AIBallistic.cxx @@ -426,8 +426,8 @@ void FGAIBallistic::setForcePath(const string& p) { bool FGAIBallistic::getHtAGL(){ - if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(pos, 10000), - _elevation_m, &_material)){ + if (getGroundElevationM(SGGeod::fromGeodM(pos, 10000), + _elevation_m, &_material)) { _ht_agl_ft = pos.getElevationFt() - _elevation_m * SG_METER_TO_FEET; if (_material) { const vector& names = _material->get_names(); diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index a63751a1c..0bb374492 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -191,8 +191,6 @@ bool FGAIBase::init(bool search_in_AI_path) { void FGAIBase::initModel(osg::Node *node) { if (model.valid()) { - // Disable altitude computations for general AI models. - model->setNodeMask(model->getNodeMask() & ~SG_NODEMASK_TERRAIN_BIT); fgSetString("/ai/models/model-added", props->getPath()); @@ -452,6 +450,12 @@ SGVec3d FGAIBase::getCartPos() const { return cartPos; } +bool FGAIBase::getGroundElevationM(const SGGeod& pos, double& elev, + const SGMaterial** material) const { + return globals->get_scenery()->get_elevation_m(pos, elev, material, + model.get()); +} + double FGAIBase::_getCartPosX() const { SGVec3d cartPos = getCartPos(); return cartPos.x(); diff --git a/src/AIModel/AIBase.hxx b/src/AIModel/AIBase.hxx index 46d287f73..86b1794a6 100644 --- a/src/AIModel/AIBase.hxx +++ b/src/AIModel/AIBase.hxx @@ -36,6 +36,7 @@ using std::string; using std::list; +class SGMaterial; class FGAIManager; class FGAIFlightPlan; @@ -93,6 +94,9 @@ public: SGVec3d getCartPosAt(const SGVec3d& off) const; SGVec3d getCartPos() const; + bool getGroundElevationM(const SGGeod& pos, double& elev, + const SGMaterial** material) const; + double _getCartPosX() const; double _getCartPosY() const; double _getCartPosZ() const; diff --git a/src/AIModel/AIShip.cxx b/src/AIModel/AIShip.cxx index 5111d9981..4d6b2c3ad 100644 --- a/src/AIModel/AIShip.cxx +++ b/src/AIModel/AIShip.cxx @@ -34,7 +34,6 @@ #include #include #include -#include #include "AIShip.hxx" @@ -118,11 +117,6 @@ bool FGAIShip::init(bool search_in_AI_path) { return FGAIBase::init(search_in_AI_path); } -void FGAIShip::initModel(osg::Node *node) { - FGAIBase::initModel(node); - model->setNodeMask(model->getNodeMask() | SG_NODEMASK_TERRAIN_BIT); -} - void FGAIShip::bind() { FGAIBase::bind(); diff --git a/src/AIModel/AIShip.hxx b/src/AIModel/AIShip.hxx index 491c02489..f4a622310 100644 --- a/src/AIModel/AIShip.hxx +++ b/src/AIModel/AIShip.hxx @@ -37,7 +37,6 @@ public: virtual void readFromScenario(SGPropertyNode* scFileNode); virtual bool init(bool search_in_AI_path=false); - virtual void initModel(osg::Node *node); virtual void bind(); virtual void unbind(); virtual void update(double dt); diff --git a/src/AIModel/AIThermal.cxx b/src/AIModel/AIThermal.cxx index 19d646325..172d1e68a 100644 --- a/src/AIModel/AIThermal.cxx +++ b/src/AIModel/AIThermal.cxx @@ -229,7 +229,7 @@ double user_altitude = manager->get_user_altitude(); // MSL dt_count += dt; if (dt_count >= 10.0 ) { //double alt; - if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(pos, 20000), alt, 0)){ + if (getGroundElevationM(SGGeod::fromGeodM(pos, 20000), alt, 0)) { ground_elev_ft = alt * SG_METER_TO_FEET; do_agl_calc = 0; altitude_agl_ft = height - ground_elev_ft ; diff --git a/src/ATCDCL/AILocalTraffic.cxx b/src/ATCDCL/AILocalTraffic.cxx index 4a5dfaa3b..e38e43149 100644 --- a/src/ATCDCL/AILocalTraffic.cxx +++ b/src/ATCDCL/AILocalTraffic.cxx @@ -1553,7 +1553,7 @@ void FGAILocalTraffic::DoGroundElev() { // FIXME: make shure the pos.lat/pos.lon values are in degrees ... double alt; - if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(_aip.getPosition(), 20000), alt, 0)) + if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(_aip.getPosition(), 20000), alt, 0, _aip.getSceneGraph())) _ground_elevation_m = alt; } -- 2.39.5