]> git.mxchange.org Git - flightgear.git/commitdiff
Push SGMaterial use into these classes that need it.
authorMathias Froehlich <Mathias.Froehlich@web.de>
Mon, 27 Aug 2012 18:51:16 +0000 (20:51 +0200)
committerMathias Froehlich <Mathias.Froehlich@web.de>
Wed, 29 Aug 2012 04:29:29 +0000 (06:29 +0200)
20 files changed:
src/AIModel/AIBallistic.cxx
src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx
src/AIModel/AIEscort.cxx
src/FDM/JSBSim/JSBSim.cxx
src/FDM/YASim/FGGround.cpp
src/FDM/YASim/FGGround.hpp
src/FDM/YASim/Gear.cpp
src/FDM/YASim/Gear.hpp
src/FDM/YASim/Ground.cpp
src/FDM/YASim/Ground.hpp
src/FDM/YASim/Model.cpp
src/FDM/flight.cxx
src/FDM/flight.hxx
src/FDM/groundcache.cxx
src/Instrumentation/agradar.cxx
src/Radio/radio.cxx
src/Scenery/scenery.cxx
src/Scenery/scenery.hxx
src/Scripting/NasalPositioned.cxx

index 6a0565652de84fd6f2b0d49fdb0b6c69a28b6c1b..fc4ea30c19d4a5439a9285101f18d31045a8fb6b 100644 (file)
@@ -498,9 +498,10 @@ void FGAIBallistic::setForcePath(const string& p) {
 }
 
 bool FGAIBallistic::getHtAGL(double start){
-    const SGMaterial* material = 0;
+    const simgear::BVHMaterial* mat = 0;
     if (getGroundElevationM(SGGeod::fromGeodM(pos, start),
-        _elevation_m, &material)) {
+        _elevation_m, &mat)) {
+            const SGMaterial* material = dynamic_cast<const SGMaterial*>(mat);
             _ht_agl_ft = pos.getElevationFt() - _elevation_m * SG_METER_TO_FEET;
 
             if (material) {
index ed6d0a9d9d0c0e4efdfd1acca4b7a8a456fe52ea..a17b9e47602b7ec8d1979f0bbf805d8e2360d448 100644 (file)
@@ -607,7 +607,7 @@ SGVec3d FGAIBase::getCartPos() const {
 }
 
 bool FGAIBase::getGroundElevationM(const SGGeod& pos, double& elev,
-                                   const SGMaterial** material) const {
+                                   const simgear::BVHMaterial** material) const {
     return globals->get_scenery()->get_elevation_m(pos, elev, material,
                                                    _model.get());
 }
index a492b9b2ccaa54b3e70618de5510252b214cd8f6..3a9426140f0d3f6606ce76bb56abfb6af37f12b2 100644 (file)
@@ -38,7 +38,9 @@
 
 using std::string;
 
-class SGMaterial;
+namespace simgear {
+class BVHMaterial;
+}
 class FGAIManager;
 class FGAIFlightPlan;
 class FGFX;
@@ -114,7 +116,7 @@ public:
     SGVec3d getCartPos() const;
 
     bool getGroundElevationM(const SGGeod& pos, double& elev,
-        const SGMaterial** material) const;
+                             const simgear::BVHMaterial** material) const;
 
     double _elevation_m;
 
index 765cac8dbd9e5d9cffded5605df6fbd7d4b69e11..8012ae9230ea2df4b5659bdfd0017ab1a62107fa 100644 (file)
@@ -190,8 +190,9 @@ bool FGAIEscort::getGroundElev(SGGeod inpos) {
 
     double height_m ;
 
-    const SGMaterial* material = 0;
-    if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(inpos, 3000), height_m, &material,0)){
+    const simgear::BVHMaterial* mat = 0;
+    if (globals->get_scenery()->get_elevation_m(SGGeod::fromGeodM(inpos, 3000), height_m, &mat, 0)){
+        const SGMaterial* material = dynamic_cast<const SGMaterial*>(mat);
         _ht_agl_ft = inpos.getElevationFt() - height_m * SG_METER_TO_FEET;
 
         if (material) {
index c716f77344e514f9c624d88a0778db93d095838c..d67e571946bb0e0478fb4bc2f6d12dd5c960344b 100644 (file)
@@ -1330,7 +1330,7 @@ FGJSBsim::get_agl_ft(double t, const double pt[3], double alt_off,
                      double contact[3], double normal[3], double vel[3],
                      double angularVel[3], double *agl)
 {
-   const SGMaterial* material;
+   const simgear::BVHMaterial* material;
    simgear::BVHNode::Id id;
    if (!FGInterface::get_agl_ft(t, pt, alt_off, contact, normal, vel,
                                 angularVel, material, id))
index 7085f5677757d00dc7fd8908e0422491b8d6dafd..a2f787b29e7f3091ae9849700dcabb5f82a2d7ba 100644 (file)
@@ -26,7 +26,7 @@ void FGGround::getGroundPlane(const double pos[3],
 {
     // Return values for the callback.
     double cp[3], dvel[3], dangvel[3];
-    const SGMaterial* material;
+    const simgear::BVHMaterial* material;
     simgear::BVHNode::Id id;
     _iface->get_agl_m(_toff, pos, 2, cp, plane, dvel, dangvel, material, id);
 
@@ -38,7 +38,7 @@ void FGGround::getGroundPlane(const double pos[3],
 
 void FGGround::getGroundPlane(const double pos[3],
                               double plane[4], float vel[3],
-                              const SGMaterial **material)
+                              const simgear::BVHMaterial **material)
 {
     // Return values for the callback.
     double cp[3], dvel[3], dangvel[3];
index 5f5c7e9464045b5a35f1cc439c75690288937071..f3cdadbfbd7cda85975444d3bcdf682ff239e79a 100644 (file)
@@ -4,7 +4,9 @@
 #include "Ground.hpp"
 
 class FGInterface;
-class SGMaterial;
+namespace simgear {
+class BVHMaterial;
+}
 
 namespace yasim {
 
@@ -21,7 +23,7 @@ public:
 
     virtual void getGroundPlane(const double pos[3],
                                 double plane[4], float vel[3],
-                                const SGMaterial **material);
+                                const simgear::BVHMaterial **material);
 
     virtual bool caughtWire(const double pos[4][3]);
 
index aa52295ea092cc8da980b235c127fc0b4d00591a..6276c4448174601cd90529a23535abad6271a50f 100644 (file)
@@ -7,7 +7,8 @@
 #include "BodyEnvironment.hpp"
 #include "RigidBody.hpp"
 
-#include <simgear/scene/material/mat.hxx>
+#include <cfloat>
+#include <simgear/bvh/BVHMaterial.hxx>
 #include <FDM/flight.hxx>
 #include "Gear.hpp"
 namespace yasim {
@@ -146,7 +147,7 @@ void Gear::setInitialLoad(float l)
 
 void Gear::setGlobalGround(double *global_ground, float* global_vel,
                            double globalX, double globalY,
-                           const SGMaterial *material)
+                           const simgear::BVHMaterial *material)
 {
     int i;
     double frictionFactor,rollingFriction,loadCapacity,loadResistance,bumpiness;
index 62da887b82ef63644e9e0751e88490570fe9dca8..8d8cb35442002b4e6a275e8173a12bf81beff022 100644 (file)
@@ -1,7 +1,9 @@
 #ifndef _GEAR_HPP
 #define _GEAR_HPP
 
-class SGMaterial;
+namespace simgear {
+class BVHMaterial;
+}
 
 namespace yasim {
 
@@ -50,7 +52,7 @@ public:
     void setIgnoreWhileSolving(bool c);
     void setGlobalGround(double* global_ground, float* global_vel,
         double globalX, double globalY,
-        const SGMaterial *material);
+                         const simgear::BVHMaterial *material);
     void getPosition(float* out);
     void getCompression(float* out);
     void getGlobalGround(double* global_ground);
index 30d8583a459b5266495f2f9071513d5f33338357..955319e6848988ede9af105728b21f723b66df6f 100644 (file)
@@ -4,7 +4,7 @@
 
 #include "Glue.hpp"
 
-#include <simgear/scene/material/mat.hxx>
+#include <simgear/bvh/BVHMaterial.hxx>
 #include "Ground.hpp"
 namespace yasim {
 
@@ -35,7 +35,7 @@ void Ground::getGroundPlane(const double pos[3],
 
 void Ground::getGroundPlane(const double pos[3],
                             double plane[4], float vel[3],
-                            const SGMaterial **material)
+                            const simgear::BVHMaterial **material)
 {
     getGroundPlane(pos,plane,vel);
 }
index 8b90453572246155dc8edd86a09a714137527cc4..436c6e757b16b231c8f790508c888f1946d944a2 100644 (file)
@@ -1,7 +1,9 @@
 #ifndef _GROUND_HPP
 #define _GROUND_HPP
 
-class SGMaterial;
+namespace simgear {
+class BVHMaterial;
+}
 namespace yasim {
 
 class Ground {
@@ -14,7 +16,7 @@ public:
 
     virtual void getGroundPlane(const double pos[3],
                                 double plane[4], float vel[3],
-                                const SGMaterial **material);
+                                const simgear::BVHMaterial **material);
 
     virtual bool caughtWire(const double pos[4][3]);
 
index b92aea504b051ecd8ef31cb8183ba88a8c387d5b..8f33bdbaf1dc80691386798697f07e9aed92350c 100644 (file)
@@ -326,7 +326,7 @@ void Model::updateGround(State* s)
         // Ask for the ground plane in the global coordinate system
         double global_ground[4];
         float global_vel[3];
-        const SGMaterial* material;
+        const simgear::BVHMaterial* material;
         _ground_cb->getGroundPlane(pt, global_ground, global_vel, &material);
         g->setGlobalGround(global_ground, global_vel, pt[0], pt[1], material);
     }
index 8e1ca2439efbb28d4a632744c4dcec39da9ef39c..9826d641743a2b387f9f214d744e3eca07c772d1 100644 (file)
@@ -693,13 +693,13 @@ bool
 FGInterface::get_agl_m(double t, const double pt[3], double max_altoff,
                        double contact[3], double normal[3],
                        double linearVel[3], double angularVel[3],
-                       SGMaterial const*& material, simgear::BVHNode::Id& id)
+                       simgear::BVHMaterial const*& material, simgear::BVHNode::Id& id)
 {
   SGVec3d pt_m = SGVec3d(pt) - max_altoff*ground_cache.get_down();
   SGVec3d _contact, _normal, _linearVel, _angularVel;
-  const simgear::BVHMaterial* m = 0;
+  material = 0;
   bool ret = ground_cache.get_agl(t, pt_m, _contact, _normal, _linearVel,
-                                  _angularVel, id, m);
+                                  _angularVel, id, material);
   // correct the linear velocity, since the line intersector delivers
   // values for the start point and the get_agl function should
   // traditionally deliver for the contact point
@@ -709,7 +709,6 @@ FGInterface::get_agl_m(double t, const double pt[3], double max_altoff,
   assign(normal, _normal);
   assign(linearVel, _linearVel);
   assign(angularVel, _angularVel);
-  material = dynamic_cast<const SGMaterial*>(m);
   return ret;
 }
 
@@ -717,15 +716,15 @@ bool
 FGInterface::get_agl_ft(double t, const double pt[3], double max_altoff,
                         double contact[3], double normal[3],
                         double linearVel[3], double angularVel[3],
-                        SGMaterial const*& material, simgear::BVHNode::Id& id)
+                        simgear::BVHMaterial const*& material, simgear::BVHNode::Id& id)
 {
   // Convert units and do the real work.
   SGVec3d pt_m = SGVec3d(pt) - max_altoff*ground_cache.get_down();
   pt_m *= SG_FEET_TO_METER;
   SGVec3d _contact, _normal, _linearVel, _angularVel;
-  const simgear::BVHMaterial* m = 0;
+  material = 0;
   bool ret = ground_cache.get_agl(t, pt_m, _contact, _normal, _linearVel,
-                                  _angularVel, id, m);
+                                  _angularVel, id, material);
   // correct the linear velocity, since the line intersector delivers
   // values for the start point and the get_agl function should
   // traditionally deliver for the contact point
@@ -736,7 +735,6 @@ FGInterface::get_agl_ft(double t, const double pt[3], double max_altoff,
   assign( normal, _normal );
   assign( linearVel, SG_METER_TO_FEET*_linearVel );
   assign( angularVel, _angularVel );
-  material = dynamic_cast<const SGMaterial*>(m);
   return ret;
 }
 
@@ -744,19 +742,18 @@ bool
 FGInterface::get_nearest_m(double t, const double pt[3], double maxDist,
                            double contact[3], double normal[3],
                            double linearVel[3], double angularVel[3],
-                           SGMaterial const*& material,
+                           simgear::BVHMaterial const*& material,
                            simgear::BVHNode::Id& id)
 {
   SGVec3d _contact, _linearVel, _angularVel;
-  const simgear::BVHMaterial* m = 0;
+  material = 0;
   if (!ground_cache.get_nearest(t, SGVec3d(pt), maxDist, _contact, _linearVel,
-                                _angularVel, id, m))
+                                _angularVel, id, material))
       return false;
 
   assign(contact, _contact);
   assign(linearVel, _linearVel);
   assign(angularVel, _angularVel);
-  material = dynamic_cast<const SGMaterial*>(m);
   return true;
 }
 
@@ -764,20 +761,19 @@ bool
 FGInterface::get_nearest_ft(double t, const double pt[3], double maxDist,
                             double contact[3], double normal[3],
                             double linearVel[3], double angularVel[3],
-                            SGMaterial const*& material,
+                            simgear::BVHMaterial const*& material,
                             simgear::BVHNode::Id& id)
 {
   SGVec3d _contact, _linearVel, _angularVel;
-  const simgear::BVHMaterial* m = 0;
+  material = 0;
   if (!ground_cache.get_nearest(t, SG_FEET_TO_METER*SGVec3d(pt),
                                 SG_FEET_TO_METER*maxDist, _contact, _linearVel,
-                                _angularVel, id, m))
+                                _angularVel, id, material))
       return false;
 
   assign(contact, SG_METER_TO_FEET*_contact);
   assign(linearVel, SG_METER_TO_FEET*_linearVel);
   assign(angularVel, _angularVel);
-  material = dynamic_cast<const SGMaterial*>(m);
   return true;
 }
 
@@ -831,7 +827,7 @@ FGInterface::get_groundlevel_m(const SGGeod& geod)
   }
   
   double contact[3], normal[3], vel[3], angvel[3];
-  const SGMaterial* material;
+  const simgear::BVHMaterial* material;
   simgear::BVHNode::Id id;
   // Ignore the return value here, since it just tells us if
   // the returns stem from the groundcache or from the coarse
index a2047aef90fe0a49eea5346b1b9fbafdddf64cca..0cd39520b5d9ba03694450f7f458024855468fb2 100644 (file)
@@ -89,7 +89,9 @@ using std::list;
 using std::vector;
 using std::string;
 
-class SGMaterial;
+namespace simgear {
+class BVHMaterial;
+}
 
 /**
  * A little helper class to update the track if
@@ -693,11 +695,11 @@ public:
     // contact point.
     bool get_agl_m(double t, const double pt[3], double max_altoff,
                    double contact[3], double normal[3], double linearVel[3],
-                   double angularVel[3], SGMaterial const*& material,
+                   double angularVel[3], simgear::BVHMaterial const*& material,
                    simgear::BVHNode::Id& id);
     bool get_agl_ft(double t, const double pt[3], double max_altoff,
                     double contact[3], double normal[3], double linearVel[3],
-                    double angularVel[3], SGMaterial const*& material,
+                    double angularVel[3], simgear::BVHMaterial const*& material,
                     simgear::BVHNode::Id& id);
     double get_groundlevel_m(double lat, double lon, double alt);
     double get_groundlevel_m(const SGGeod& geod);
@@ -708,11 +710,11 @@ public:
     // position pt.
     bool get_nearest_m(double t, const double pt[3], double maxDist,
                        double contact[3], double normal[3], double linearVel[3],
-                       double angularVel[3], SGMaterial const*& material,
+                       double angularVel[3], simgear::BVHMaterial const*& material,
                        simgear::BVHNode::Id& id);
     bool get_nearest_ft(double t, const double pt[3], double maxDist,
                         double contact[3], double normal[3],double linearVel[3],
-                        double angularVel[3], SGMaterial const*& material,
+                        double angularVel[3], simgear::BVHMaterial const*& material,
                         simgear::BVHNode::Id& id);
 
 
index fc4fdfacafac249b3494264b0ce85a78e290347e..73f299ea98975b74fca9a26f8108e0fea8d837ee 100644 (file)
@@ -382,10 +382,9 @@ FGGroundCache::prepare_ground_cache(double startSimTime, double endSimTime,
     if (!found_ground) {
         // Ok, still nothing here?? Last resort ...
         double alt = 0;
-        const SGMaterial* m = NULL;
+        _material = 0;
         found_ground = globals->get_scenery()->
-            get_elevation_m(SGGeod::fromGeodM(geodPt, 10000), alt, &m);
-        _material = m;
+            get_elevation_m(SGGeod::fromGeodM(geodPt, 10000), alt, &_material);
         if (found_ground)
             _altitude = alt;
     }
index 23cf6f3ebe750d74c7dc3ed3809025be5800e106..768fdea41d385ecc8f773585b498dfd481c18a29 100644 (file)
@@ -210,9 +210,10 @@ agRadar::setUserVec(double az, double el)
 bool
 agRadar::getMaterial(){
 
-    const SGMaterial* material = 0;
-    if (globals->get_scenery()->get_elevation_m(hitpos, _elevation_m, &material)){
+    const simgear::BVHMaterial* mat = 0;
+    if (globals->get_scenery()->get_elevation_m(hitpos, _elevation_m, &mat)){
         //_ht_agl_ft = pos.getElevationFt() - _elevation_m * SG_METER_TO_FEET;
+        const SGMaterial* material = dynamic_cast<const SGMaterial*>(mat);
         if (material) {
             const std::vector<std::string>& names = material->get_names();
 
index 169cd322f19bb650c25806fde84f76d8fde3d46b..62f233edf6e542e4b975a28ec84e314fb25121f0 100644 (file)
@@ -323,10 +323,12 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i
        while (elevations.size() <= e_size) {
                probe_distance += point_distance;
                SGGeod probe = SGGeod::fromGeoc(center.advanceRadM( course, probe_distance ));
-               const SGMaterial *mat = 0;
+               const simgear::BVHMaterial *material = 0;
                double elevation_m = 0.0;
        
-               if (scenery->get_elevation_m( probe, elevation_m, &mat )) {
+               if (scenery->get_elevation_m( probe, elevation_m, &material )) {
+                        const SGMaterial *mat;
+                        mat = dynamic_cast<const SGMaterial*>(material);
                        if((transmission_type == 3) || (transmission_type == 4)) {
                                elevations.push_back(elevation_m);
                                if(mat) {
index c280def1995d8eeabab90c66e8eb8696b17d0889..4b787ddb3ff45c39d57d529f44e18e0c6fd04112 100644 (file)
@@ -262,7 +262,8 @@ void FGScenery::unbind() {
 
 bool
 FGScenery::get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
-                                double& alt, const SGMaterial** material,
+                                double& alt,
+                                const simgear::BVHMaterial** material,
                                 const osg::Node* butNotFrom)
 {
   SGGeod geod = SGGeod::fromCart(pos);
@@ -272,7 +273,7 @@ FGScenery::get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
 
 bool
 FGScenery::get_elevation_m(const SGGeod& geod, double& alt,
-                           const SGMaterial** material,
+                           const simgear::BVHMaterial** material,
                            const osg::Node* butNotFrom)
 {
   SGVec3d start = SGVec3d::fromGeod(geod);
@@ -291,7 +292,7 @@ FGScenery::get_elevation_m(const SGGeod& geod, double& alt,
   geodEnd = SGGeod::fromCart(intersectVisitor.getLineSegment().getEnd());
   alt = geodEnd.getElevationM();
   if (material)
-      *material = dynamic_cast<const SGMaterial*>(intersectVisitor.getMaterial());
+      *material = intersectVisitor.getMaterial();
 
   return true;
 }
index b83b8adb9079a732141b1389146db78d455ddff6..d53344354ab818d55675b09932af6a13f46c037f 100644 (file)
@@ -38,7 +38,9 @@
 
 #include "SceneryPager.hxx"
 
-class SGMaterial;
+namespace simgear {
+class BVHMaterial;
+}
 
 // Define a structure containing global scenery parameters
 class FGScenery : public SGSubsystem {
@@ -72,7 +74,7 @@ public:
     /// value is undefined. 
     /// All values are meant to be in meters or degrees.
     bool get_elevation_m(const SGGeod& geod, double& alt,
-                         const SGMaterial** material,
+                         const simgear::BVHMaterial** material,
                          const osg::Node* butNotFrom = 0);
 
     /// Compute the elevation of the scenery below the cartesian point pos.
@@ -87,7 +89,8 @@ public:
     /// value is undefined.
     /// All values are meant to be in meters.
     bool get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
-                              double& elevation, const SGMaterial** material,
+                              double& elevation,
+                              const simgear::BVHMaterial** material,
                               const osg::Node* butNotFrom = 0);
 
     /// Compute the nearest intersection point of the line starting from 
index d2bcd625b999e9e14a4bf976b63caeadef611e51..903b0cbb2cdab119cb45aa7fd9663a3ee4b4cd03 100644 (file)
@@ -894,10 +894,11 @@ static naRef f_geodinfo(naContext c, naRef me, int argc, naRef* args)
   double lat = naNumValue(args[0]).num;
   double lon = naNumValue(args[1]).num;
   double elev = argc == 3 ? naNumValue(args[2]).num : 10000;
-  const SGMaterial *mat;
+  const simgear::BVHMaterial *material;
   SGGeod geod = SGGeod::fromDegM(lon, lat, elev);
-  if(!globals->get_scenery()->get_elevation_m(geod, elev, &mat))
+  if(!globals->get_scenery()->get_elevation_m(geod, elev, &material))
     return naNil();
+  const SGMaterial *mat = dynamic_cast<const SGMaterial *>(material);
   naRef vec = naNewVector(c);
   naVec_append(vec, naNum(elev));
   naRef matdata = naNil();