]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIBase.hxx
Don't duplicate userpos in in AIObjects.
[flightgear.git] / src / AIModel / AIBase.hxx
index b4782eb4374cc6fdc8b34d062227d35f3b9141cd..70e7c97184c834ab0ebbea4ad8349cbf52661647 100644 (file)
 #include <string>
 
 #include <simgear/constants.h>
-#include <simgear/math/SGMath.hxx>
 #include <simgear/scene/model/placement.hxx>
 #include <simgear/scene/model/modellib.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/structure/SGSharedPtr.hxx>
 #include <simgear/structure/SGReferenced.hxx>
+#include <simgear/props/tiedpropertylist.hxx>
 #include <simgear/sg_inlines.h>
 
 #include <simgear/math/sg_geodesy.hxx>
 
 using std::string;
 
-class SGMaterial;
+namespace simgear {
+class BVHMaterial;
+}
 class FGAIManager;
 class FGAIFlightPlan;
 class FGFX;
-class FGNasalModelData;
-class FGAIModelData;   // defined below
+class FGNasalModelDataProxy;
+class FGAIModelData;    // defined below
 
 
 class FGAIBase : public SGReferenced {
@@ -52,7 +54,7 @@ public:
     enum object_type { otNull = 0, otAircraft, otShip, otCarrier, otBallistic,
         otRocket, otStorm, otThermal, otStatic, otWingman, otGroundVehicle,
         otEscort, otMultiplayer,
-        MAX_OBJECTS }; // Needs to be last!!!
+        MAX_OBJECTS };  // Needs to be last!!!
 
     FGAIBase(object_type ot, bool enableHot);
     virtual ~FGAIBase();
@@ -114,10 +116,9 @@ public:
     SGVec3d getCartPos() const;
 
     bool getGroundElevationM(const SGGeod& pos, double& elev,
-        const SGMaterial** material) const;
+                             const simgear::BVHMaterial** material) const;
 
     double _elevation_m;
-    const SGMaterial* _material;
 
     double _getCartPosX() const;
     double _getCartPosY() const;
@@ -139,11 +140,17 @@ public:
     std::string _name;
     string _parent;
 
-    SGGeod userpos;
-
-
 protected:
-
+    /**
+     * Tied-properties helper, record nodes which are tied for easy un-tie-ing
+     */
+    template <typename T>
+    void tie(const char* aRelPath, const SGRawValue<T>& aRawValue)
+    {
+        _tiedProperties.Tie(props->getNode(aRelPath, true), aRawValue);
+    }
+
+    simgear::TiedPropertyList _tiedProperties;
     SGPropertyNode_ptr _selected_ac;
     SGPropertyNode_ptr props;
     SGPropertyNode_ptr trigger_node;
@@ -151,10 +158,10 @@ protected:
     FGAIManager* manager;
 
     // these describe the model's actual state
-    SGGeod pos;        // WGS84 lat & lon in degrees, elev above sea-level in meters
-    double hdg;                // True heading in degrees
-    double roll;       // degrees, left is negative
-    double pitch;      // degrees, nose-down is negative
+    SGGeod pos;         // WGS84 lat & lon in degrees, elev above sea-level in meters
+    double hdg;         // True heading in degrees
+    double roll;        // degrees, left is negative
+    double pitch;       // degrees, nose-down is negative
     double speed;       // knots true airspeed
     double altitude_ft; // feet above sea level
     double vs;          // vertical speed, feet per minute
@@ -186,9 +193,9 @@ protected:
     double x_shift;      // value used by radar display instrument
     double y_shift;      // value used by radar display instrument
     double rotation;     // value used by radar display instrument
-    double ht_diff;             // value used by radar display instrument
+    double ht_diff;      // value used by radar display instrument
 
-    string model_path;    //Path to the 3D model
+    string model_path;   //Path to the 3D model
     SGModelPlacement aip;
 
     bool delete_me;
@@ -219,6 +226,7 @@ protected:
     double UpdateRadar(FGAIManager* manager);
 
     void removeModel();
+    void removeSoundFx();
 
     static int _newAIModelID();
 
@@ -244,7 +252,6 @@ public:
     void _setLongitude( double longitude );
     void _setLatitude ( double latitude );
     void _setSubID( int s );
-    void _setUserPos();
 
     double _getAltitudeAGL(SGGeod inpos, double start);
 
@@ -456,18 +463,17 @@ public:
 
     /** init hook to be called after model is loaded.
      * Not thread-safe. Call from main thread only. */
-    void init(void);
+    void init(void) { _initialized = true; }
 
     bool needInitilization(void) { return _ready && !_initialized;}
     bool isInitialized(void) { return _initialized;}
     inline std::string& get_sound_path() { return _fxpath;}
 
 private:
-    FGNasalModelData *_nasal;
-    SGPropertyNode_ptr _prop;
-    std::string _path, _fxpath;
+    FGNasalModelDataProxy *_nasal;
+    std::string _fxpath;
     bool _ready;
     bool _initialized;
 };
 
-#endif // _FG_AIBASE_HXX
+#endif // _FG_AIBASE_HXX