X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2Fgroundcache.hxx;h=9319666a6ba83508f9f1c364ab8d9e624ba740ed;hb=69baf3a9d6adb645325e7bfc0305b09604379d9f;hp=c548679a22e85789cef4e3f79673f1a711043419;hpb=55a978f2a82e0f21735aea2307a5a278dd3a8aed;p=flightgear.git diff --git a/src/FDM/groundcache.hxx b/src/FDM/groundcache.hxx index c548679a2..9319666a6 100644 --- a/src/FDM/groundcache.hxx +++ b/src/FDM/groundcache.hxx @@ -23,19 +23,23 @@ #ifndef _GROUNDCACHE_HXX #define _GROUNDCACHE_HXX -#include -#include - #include #include #include #include -#include +#include #include -class SGMaterial; +// #define GROUNDCACHE_DEBUG +#ifdef GROUNDCACHE_DEBUG +#include +#include +#include +#endif + namespace simgear { class BVHLineGeometry; +class BVHMaterial; } class FGGroundCache { @@ -50,8 +54,8 @@ public: // Prepare the ground cache for the wgs84 position pt_*. // That is take all vertices in the ball with radius rad around the // position given by the pt_* and store them in a local scene graph. - bool prepare_ground_cache(double ref_time, const SGVec3d& pt, - double rad); + bool prepare_ground_cache(double startSimTime, double endSimTime, + const SGVec3d& pt, double rad); // Returns true if the cache is valid. // Also the reference time, point and radius values where the cache @@ -62,6 +66,12 @@ public: const SGVec3d& get_down() const { return down; } + // The time offset that originates from a simtime different than zero + // at initialization time of the fdm. + double get_cache_time_offset() const + { return cache_time_offset; } + void set_cache_time_offset(double time_offset) + { cache_time_offset = time_offset; } bool get_body(double t, SGMatrixd& bodyToWorld, SGVec3d& linearVel, SGVec3d& angularVel, simgear::BVHNode::Id id); @@ -79,11 +89,13 @@ public: // 0 and 1 which can be used to model lower friction with wet runways. bool get_agl(double t, const SGVec3d& pt, SGVec3d& contact, SGVec3d& normal, SGVec3d& linearVel, SGVec3d& angularVel, - simgear::BVHNode::Id& id, const SGMaterial*& material); + simgear::BVHNode::Id& id, + const simgear::BVHMaterial*& material); bool get_nearest(double t, const SGVec3d& pt, double maxDist, SGVec3d& contact, SGVec3d& linearVel, SGVec3d& angularVel, - simgear::BVHNode::Id& id, const SGMaterial*& material); + simgear::BVHNode::Id& id, + const simgear::BVHMaterial*& material); // Return 1 if the hook intersects with a wire. // That test is done by checking if the quad spanned by the points pt* @@ -110,10 +122,12 @@ private: // In case the aircraft is too high above ground. double _altitude; // the simgear material reference, contains friction coeficients ... - const SGMaterial* _material; + const simgear::BVHMaterial* _material; // The time reference for later call to intersection test routines. // Is required since we will have moving triangles in carriers. double cache_ref_time; + // The time the cache was initialized. + double cache_time_offset; // The wire to track. const simgear::BVHLineGeometry* _wire; @@ -125,6 +139,15 @@ private: bool found_ground; SGSharedPtr _localBvhTree; + +#ifdef GROUNDCACHE_DEBUG + SGTimeStamp _lookupTime; + unsigned _lookupCount; + SGTimeStamp _buildTime; + unsigned _buildCount; + + osg::ref_ptr _group; +#endif }; #endif