]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/groundcache.hxx
Fix line endings
[flightgear.git] / src / FDM / groundcache.hxx
index be4293db58f9cb9f6567fdda1c65e9302393d1d6..f9311c91fa0d0c86accfccdfdc55e837420b7e8d 100644 (file)
@@ -30,6 +30,9 @@
 
 class FGGroundCache {
 public:
+    FGGroundCache();
+    ~FGGroundCache();
+
     //////////////////////////////////////////////////////////////////////////
     // Ground handling routines
     //////////////////////////////////////////////////////////////////////////
@@ -53,17 +56,16 @@ public:
   
 
     // Return the altitude above ground below the wgs84 point pt
-    // Search for the nearest triangle to pt.
+    // Search for highest triangle not higher than pt + max_altoff.
     // Return ground properties like the ground type, the maximum load
     // this kind kind of ground can carry, the friction factor between
     // 0 and 1 which can be used to model lower friction with wet runways
     // and finally the altitude above ground.
-    bool get_agl(double t, const double pt[3],
+    bool get_agl(double t, const double pt[3], double max_altoff,
                  double contact[3], double normal[3], double vel[3],
                  int *type, double *loadCapacity,
                  double *frictionFactor, double *agl);
 
-
     // Return 1 if the hook intersects with a wire.
     // That test is done by checking if the quad spanned by the points pt*
     // intersects with the line representing the wire.
@@ -79,9 +81,36 @@ public:
     void release_wire(void);
 
 private:
-    // Holds the private ground triangle cache ...
-    // The surface cache itself.
-    ssgRoot cache_root;
+    struct Triangle {
+      // The edge vertices.
+      sgdVec3 vertices[3];
+      // The surface normal.
+      sgdVec4 plane;
+      // The bounding shpere.
+      sgdSphere sphere;
+      // The linear and angular velocity.
+      sgdVec3 velocity;
+      sgdVec3 rotation;
+      sgdVec3 rotation_pivot;
+      // Ground type
+      int type;
+    };
+    struct Catapult {
+      sgdVec3 start;
+      sgdVec3 end;
+      sgdVec3 velocity;
+      sgdVec3 rotation;
+      sgdVec3 rotation_pivot;
+    };
+    struct Wire {
+      sgdVec3 ends[2];
+      sgdVec3 velocity;
+      sgdVec3 rotation;
+      sgdVec3 rotation_pivot;
+      int wire_id;
+    };
+
+
     // The center of the cache.
     sgdVec3 cache_center;
     // Approximate ground radius.
@@ -93,6 +122,11 @@ private:
     // The wire identifier to track.
     int wire_id;
 
+    // Containers which hold all the essential information about this cache.
+    std::vector<Triangle> triangles;
+    std::vector<Catapult> catapults;
+    std::vector<Wire> wires;
+
     // The point and radius where the cache is built around.
     // That are the arguments that were given to prepare_ground_cache.
     sgdVec3 reference_wgs84_point;
@@ -101,44 +135,34 @@ private:
 
 
     // Fills the environment cache with everything inside the sphere sp.
-    void cache_fill(ssgBranch *branch, sgMat4 xform,
-                    sgSphere* sp, sgVec3 down, sgSphere* wsp);
+    void cache_fill(ssgBranch *branch, sgdMat4 xform,
+                    sgdSphere* sp, sgdVec3 down, sgdSphere* wsp);
+
+    // compute the ground property of this leaf.
+    void putSurfaceLeafIntoCache(const sgdSphere *sp, const sgdMat4 xform,
+                                 bool sphIsec, sgdVec3 down, ssgLeaf *l);
+
+    void putLineLeafIntoCache(const sgdSphere *wsp, const sgdMat4 xform,
+                              ssgLeaf *l);
 
     // Helper class to hold some properties of the ground triangle.
-    class GroundProperty
-      : public ssgBase {
-    public:
+    struct GroundProperty {
       GroundProperty() : type(0) {}
       int type;
       int wire_id;
-      sgVec3 vel;
+      sgdVec3 vel;
+      sgdVec3 rot;
+      sgdVec3 pivot;
       // not yet implemented ...
 //       double loadCapacity;
     };
 
     // compute the ground property of this leaf.
-    static GroundProperty *extractGroundProperty( ssgLeaf* leaf );
-
-
-    // compute the ground property of this leaf.
-    void putSurfaceLeafIntoCache(const sgSphere *sp, const sgMat4 xform,
-                                 bool sphIsec, sgVec3 down, ssgLeaf *l);
-
-    void putLineLeafIntoCache(const sgSphere *wsp, const sgMat4 xform,
-                              ssgLeaf *l);
-
-    void addAndFlattenLeaf(GLenum ty, ssgLeaf *l, ssgIndexArray *ia,
-                           const sgMat4 xform);
-
+    static GroundProperty extractGroundProperty( ssgLeaf* leaf );
 
-    void extractCacheRelativeVertex(double t, ssgVtxArray *va,
-                                    GroundProperty *gp,
-                                    short i, sgVec3 rel_pos,
-                                    sgdVec3 wgs84_vel);
 
-    void extractWgs84Vertex(double t, ssgVtxArray *va,
-                            GroundProperty *gp, short i,
-                            sgdVec3 wgs84_pos, sgdVec3 wgs84_vel);
+    static void velocityTransformTriangle(double dt, Triangle& dst,
+                                          const Triangle& src);
 };
 
 #endif