#include <osgViewer/Viewer>
#include <simgear/constants.h>
+#include <simgear/sg_inlines.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/scene/tgdb/userdata.hxx>
#include <simgear/scene/material/matlib.hxx>
+#include <simgear/scene/material/mat.hxx>
#include <simgear/scene/util/SGNodeMasks.hxx>
+#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/SGSceneUserData.hxx>
#include <simgear/scene/model/CheckSceneryVisitor.hxx>
-#include <simgear/scene/bvh/BVHNode.hxx>
-#include <simgear/scene/bvh/BVHLineSegmentVisitor.hxx>
+#include <simgear/bvh/BVHNode.hxx>
+#include <simgear/bvh/BVHLineSegmentVisitor.hxx>
-#include <Main/renderer.hxx>
+#include <Viewer/renderer.hxx>
#include <Main/fg_props.hxx>
#include "tilemgr.hxx"
{ return _haveHit; }
const SGLineSegmentd& getLineSegment() const
{ return _lineSegment; }
- const SGMaterial* getMaterial() const
+ const simgear::BVHMaterial* getMaterial() const
{ return _material; }
virtual void apply(osg::Node& node)
SGLineSegmentd lineSegment = _lineSegment;
bool haveHit = _haveHit;
- const SGMaterial* material = _material;
+ const simgear::BVHMaterial* material = _material;
_haveHit = false;
_lineSegment = lineSegment.transform(SGMatrixd(inverseMatrix.ptr()));
SGLineSegmentd _lineSegment;
const osg::Node* _skipNode;
- const SGMaterial* _material;
+ const simgear::BVHMaterial* _material;
bool _haveHit;
};
FGScenery::FGScenery()
{
SG_LOG( SG_TERRAIN, SG_INFO, "Initializing scenery subsystem" );
+ // keep reference to pager singleton, so it cannot be destroyed while FGScenery lives
+ _pager = FGScenery::getPagerSingleton();
}
FGScenery::~FGScenery() {
}
-void FGScenery::update(double dt) {
+void FGScenery::update(double dt)
+{
+ SG_UNUSED(dt);
+ // nothing here, don't call again
+ suspend();
}
bool
FGScenery::get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
- double& alt, const SGMaterial** material,
+ double& alt,
+ const simgear::BVHMaterial** material,
const osg::Node* butNotFrom)
{
SGGeod geod = SGGeod::fromCart(pos);
bool
FGScenery::get_elevation_m(const SGGeod& geod, double& alt,
- const SGMaterial** material,
+ const simgear::BVHMaterial** material,
const osg::Node* butNotFrom)
{
SGVec3d start = SGVec3d::fromGeod(geod);
return false;
geodEnd = SGGeod::fromCart(intersectVisitor.getLineSegment().getEnd());
- alt = geod.getElevationM();
+ alt = geodEnd.getElevationM();
if (material)
*material = intersectVisitor.getMaterial();
SGVec3f p = SGVec3f::fromGeod(SGGeod::fromGeodM(position, elev));
osg::FrameStamp* framestamp
= globals->get_renderer()->getViewer()->getFrameStamp();
- simgear::CheckSceneryVisitor csnv(getPagerSingleton(), toOsg(p), range_m, framestamp);
+ simgear::CheckSceneryVisitor csnv(_pager, toOsg(p), range_m, framestamp);
// currently the PagedLODs will not be loaded by the DatabasePager
// while the splashscreen is there, so CheckSceneryVisitor force-loads
// missing objects in the main thread