#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/SGMisc.hxx>
+#include <simgear/scene/material/mat.hxx>
#include <simgear/scene/util/SGNodeMasks.hxx>
#include <simgear/scene/util/SGSceneUserData.hxx>
-
-#include <simgear/scene/bvh/BVHNode.hxx>
-#include <simgear/scene/bvh/BVHGroup.hxx>
-#include <simgear/scene/bvh/BVHTransform.hxx>
-#include <simgear/scene/bvh/BVHMotionTransform.hxx>
-#include <simgear/scene/bvh/BVHLineGeometry.hxx>
-#include <simgear/scene/bvh/BVHStaticGeometry.hxx>
-#include <simgear/scene/bvh/BVHStaticData.hxx>
-#include <simgear/scene/bvh/BVHStaticNode.hxx>
-#include <simgear/scene/bvh/BVHStaticTriangle.hxx>
-#include <simgear/scene/bvh/BVHStaticBinary.hxx>
-#include <simgear/scene/bvh/BVHSubTreeCollector.hxx>
-#include <simgear/scene/bvh/BVHLineSegmentVisitor.hxx>
-#include <simgear/scene/bvh/BVHNearestPointVisitor.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
+
+#include <simgear/bvh/BVHNode.hxx>
+#include <simgear/bvh/BVHGroup.hxx>
+#include <simgear/bvh/BVHTransform.hxx>
+#include <simgear/bvh/BVHMotionTransform.hxx>
+#include <simgear/bvh/BVHLineGeometry.hxx>
+#include <simgear/bvh/BVHStaticGeometry.hxx>
+#include <simgear/bvh/BVHStaticData.hxx>
+#include <simgear/bvh/BVHStaticNode.hxx>
+#include <simgear/bvh/BVHStaticTriangle.hxx>
+#include <simgear/bvh/BVHStaticBinary.hxx>
+#include <simgear/bvh/BVHSubTreeCollector.hxx>
+#include <simgear/bvh/BVHLineSegmentVisitor.hxx>
+#include <simgear/bvh/BVHNearestPointVisitor.hxx>
#ifdef GROUNDCACHE_DEBUG
-#include <simgear/scene/bvh/BVHDebugCollectVisitor.hxx>
+#include <simgear/scene/model/BVHDebugCollectVisitor.hxx>
#include <Main/fg_props.hxx>
#endif
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)));
{ return _haveHit; }
double getElevationBelowCache() const
{ return SGGeod::fromCart(_sceneryHit).getElevationM(); }
- const SGMaterial* getMaterialBelowCache() const
+ const simgear::BVHMaterial* getMaterialBelowCache() const
{ return _material; }
private:
simgear::BVHSubTreeCollector mSubTreeCollector;
SGVec3d _sceneryHit;
double _maxDown;
- const SGMaterial* _material;
+ const simgear::BVHMaterial* _material;
bool _haveHit;
};
SGGeod geodPt = SGGeod::fromCart(pt);
// Don't blow away the cache ground_radius and stuff if there's no
// scenery
- if (!globals->get_tile_mgr()->scenery_available(geodPt, rad)) {
+ if (!globals->get_tile_mgr()->schedule_scenery(geodPt, rad, 1.0)) {
SG_LOG(SG_FLIGHT, SG_WARN, "prepare_ground_cache(): scenery_available "
"returns false at " << geodPt << " " << pt << " " << rad);
return false;
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)
return;
leaf.traverse(*this);
}
+ virtual void apply(BVHPageNode& leaf)
+ {
+ if (_foundId)
+ return;
+ leaf.traverse(*this);
+ }
virtual void apply(BVHTransform& transform)
{
if (_foundId)
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()))
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();
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;
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()))
_localBvhTree->accept(wireIntersector);
_wire = wireIntersector.getWire();
- return _wire;
+ return (_wire != NULL);
}
class FGGroundCache::WireFinder : public BVHVisitor {
return;
leaf.traverse(*this);
}
+ virtual void apply(BVHPageNode& leaf)
+ {
+ if (_haveLineSegment)
+ return;
+ leaf.traverse(*this);
+ }
virtual void apply(BVHTransform& transform)
{
if (_haveLineSegment)