X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2Fgroundcache.cxx;h=0b341159aadd04bae91e51e22971dc989d2fd461;hb=2314ccfe13e5e175763000e4c8ba86be79aa3a97;hp=21d2816d6fef4baa8579441f76805efec933b565;hpb=8a087582bcf6bda954dee70ed1f48fe64a09aac2;p=flightgear.git diff --git a/src/FDM/groundcache.cxx b/src/FDM/groundcache.cxx index 21d2816d6..0b341159a 100644 --- a/src/FDM/groundcache.cxx +++ b/src/FDM/groundcache.cxx @@ -41,26 +41,27 @@ #include #include #include +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef GROUNDCACHE_DEBUG -#include +#include #include
#endif @@ -149,7 +150,7 @@ public: SGVec3d down = _down; double radius = _radius; bool haveHit = _haveHit; - const SGMaterial* material = _material; + const simgear::BVHMaterial* material = _material; _haveHit = false; _center = toSG(inverseMatrix.preMult(toOsg(_center))); @@ -275,7 +276,7 @@ public: { return _haveHit; } double getElevationBelowCache() const { return SGGeod::fromCart(_sceneryHit).getElevationM(); } - const SGMaterial* getMaterialBelowCache() const + const simgear::BVHMaterial* getMaterialBelowCache() const { return _material; } private: @@ -288,7 +289,7 @@ private: simgear::BVHSubTreeCollector mSubTreeCollector; SGVec3d _sceneryHit; double _maxDown; - const SGMaterial* _material; + const simgear::BVHMaterial* _material; bool _haveHit; }; @@ -381,6 +382,7 @@ FGGroundCache::prepare_ground_cache(double startSimTime, double endSimTime, if (!found_ground) { // Ok, still nothing here?? Last resort ... double alt = 0; + _material = 0; found_ground = globals->get_scenery()-> get_elevation_m(SGGeod::fromGeodM(geodPt, 10000), alt, &_material); if (found_ground) @@ -456,6 +458,12 @@ public: return; leaf.traverse(*this); } + virtual void apply(BVHPageNode& leaf) + { + if (_foundId) + return; + leaf.traverse(*this); + } virtual void apply(BVHTransform& transform) { if (_foundId) @@ -553,6 +561,12 @@ public: return; leaf.traverse(*this); } + virtual void apply(BVHPageNode& leaf) + { + if (!intersects(_sphere, leaf.getBoundingSphere())) + return; + leaf.traverse(*this); + } virtual void apply(BVHTransform& transform) { if (!intersects(_sphere, transform.getBoundingSphere())) @@ -678,7 +692,7 @@ FGGroundCache::get_cat(double t, const SGVec3d& pt, bool FGGroundCache::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) { #ifdef GROUNDCACHE_DEBUG SGTimeStamp t0 = SGTimeStamp::now(); @@ -731,7 +745,7 @@ bool FGGroundCache::get_nearest(double t, const SGVec3d& pt, double maxDist, SGVec3d& contact, SGVec3d& linearVel, SGVec3d& angularVel, simgear::BVHNode::Id& id, - const SGMaterial*& material) + const simgear::BVHMaterial*& material) { if (!_localBvhTree) return false; @@ -787,6 +801,13 @@ public: leaf.traverse(*this); } + virtual void apply(BVHPageNode& leaf) + { + if (!_intersects(leaf.getBoundingSphere())) + return; + + leaf.traverse(*this); + } virtual void apply(BVHTransform& transform) { if (!_intersects(transform.getBoundingSphere())) @@ -900,7 +921,7 @@ bool FGGroundCache::caught_wire(double t, const SGVec3d pt[4]) _localBvhTree->accept(wireIntersector); _wire = wireIntersector.getWire(); - return _wire; + return (_wire != NULL); } class FGGroundCache::WireFinder : public BVHVisitor { @@ -920,6 +941,12 @@ public: return; leaf.traverse(*this); } + virtual void apply(BVHPageNode& leaf) + { + if (_haveLineSegment) + return; + leaf.traverse(*this); + } virtual void apply(BVHTransform& transform) { if (_haveLineSegment)