]> git.mxchange.org Git - flightgear.git/commitdiff
Use the 'all but self' capability of the scenery elevaton code instead of
authorfrohlich <frohlich>
Mon, 10 Aug 2009 05:21:44 +0000 (05:21 +0000)
committerTim Moore <timoore@redhat.com>
Mon, 10 Aug 2009 21:31:21 +0000 (23:31 +0200)
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
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

index 7da692069455eed8f9a836b1db228f29fa1bbf2d..44a0168899fb55e941b1f4d28a96eed154cd9626 100644 (file)
@@ -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;
     }
 }
index 367f2e3f58c0a502d88caa32c5710ff10221e526..1ea75d7f2c43b2f69b3c0cc79f855955e7278d35 100644 (file)
@@ -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<string>& names = _material->get_names();
index a63751a1c9e0560f319cb4e8ab7211201996b864..0bb37449276bac96bfd04762ddaa704d468e8f9e 100644 (file)
@@ -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();
index 46d287f732778dd4397f07fb6bf7cf6fccba2057..86b1794a6f6d77ac1e14b82809153108ef83014c 100644 (file)
@@ -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;
index 5111d9981547631548796fbc4d714b7befd24d4d..4d6b2c3ad9a84fded1079a6d5b30c5b76273bade 100644 (file)
@@ -34,7 +34,6 @@
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/timing/sg_time.hxx>
 #include <simgear/math/sg_random.h>
-#include <simgear/scene/util/SGNodeMasks.hxx>
 
 #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();
 
index 491c024897eecdf3348f7ea871eb217b35889819..f4a622310c6b5ef3d09a08132245809adc8daea9 100644 (file)
@@ -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);
index 19d64632513f35101bfa290f89443d4ff115a7ca..172d1e68aff1d55f23e334f60035ac52b8ba41bf 100644 (file)
@@ -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 ;
index 4a5dfaa3b15268d2a32f63be3e7b139e8e70141f..e38e4314970c35a6d0847674625b9ee5665aa6bb 100644 (file)
@@ -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;
 }