Added optional control of whether to use KdTrees for intersections

This commit is contained in:
Robert Osfield
2008-07-08 17:35:10 +00:00
parent 134c86c2d5
commit 2851429333
3 changed files with 19 additions and 10 deletions

View File

@@ -46,11 +46,12 @@ class Intersector : public osg::Referenced
_coordinateFrame(cf),
_disabledCount(0) {}
void setCoordinateFrame(CoordinateFrame cf) { _coordinateFrame = cf; }
CoordinateFrame getCoordinateFrame() const { return _coordinateFrame; }
virtual Intersector* clone(osgUtil::IntersectionVisitor& iv) = 0;
virtual bool enter(const osg::Node& node) = 0;
@@ -72,7 +73,7 @@ class Intersector : public osg::Referenced
protected:
CoordinateFrame _coordinateFrame;
unsigned int _disabledCount;
unsigned int _disabledCount;
};
@@ -138,6 +139,7 @@ class OSGUTIL_EXPORT IntersectionVisitor : public osg::NodeVisitor
virtual void reset();
/** Set the intersector that will be used to intersect with the scene, and to store any hits that occur.*/
void setIntersector(Intersector* intersector);
@@ -148,6 +150,13 @@ class OSGUTIL_EXPORT IntersectionVisitor : public osg::NodeVisitor
const Intersector* getIntersector() const { return _intersectorStack.empty() ? 0 : _intersectorStack.front().get(); }
/** Set whether the intersectors should use KdTrees when they are found on the scene graph.*/
void setUseKdTreeWhenAvailable(bool useKdTrees) { _useKdTreesWhenAvailable; }
/** Set whether the intersectors should use KdTrees.*/
bool getUseKdTreeWhenAvailable() const { return _useKdTreesWhenAvailable; }
/** Set the read callback.*/
void setReadCallback(ReadCallback* rc) { _readCallback = rc; }
@@ -201,6 +210,8 @@ class OSGUTIL_EXPORT IntersectionVisitor : public osg::NodeVisitor
typedef std::list< osg::ref_ptr<Intersector> > IntersectorStack;
IntersectorStack _intersectorStack;
bool _useKdTreesWhenAvailable;
osg::ref_ptr<ReadCallback> _readCallback;