Added prelimnary work on PolytopeIntersector.
This commit is contained in:
@@ -142,6 +142,63 @@ class OSGUTIL_EXPORT LineSegmentIntersector : public Intersector
|
||||
|
||||
};
|
||||
|
||||
/** Concrent class for implementing polytope intersections with the scene graph.
|
||||
* To be used in conjunction with IntersectionVisitor. */
|
||||
class OSGUTIL_EXPORT PolytopeIntersector : public Intersector
|
||||
{
|
||||
public:
|
||||
|
||||
PolytopeIntersector(const osg::Polytope& polytope, PolytopeIntersector* parent=0);
|
||||
|
||||
PolytopeIntersector(CoordinateFrame cf, const osg::Polytope& polytope, PolytopeIntersector* parent=0);
|
||||
|
||||
struct Intersection
|
||||
{
|
||||
Intersection() {}
|
||||
|
||||
bool operator < (const Intersection& rhs) const
|
||||
{
|
||||
if (nodePath < rhs.nodePath) return true;
|
||||
if (rhs.nodePath < nodePath ) return false;
|
||||
return (drawable < rhs.drawable);
|
||||
}
|
||||
|
||||
osg::NodePath nodePath;
|
||||
osg::ref_ptr<osg::Drawable> drawable;
|
||||
};
|
||||
|
||||
typedef std::set<Intersection> Intersections;
|
||||
|
||||
inline void insertIntersection(const Intersection& intersection) { getIntersections().insert(intersection); }
|
||||
|
||||
inline Intersections& getIntersections() { return _parent ? _parent->_intersections : _intersections; }
|
||||
|
||||
inline Intersection getFirstIntersection() { Intersections& intersections = getIntersections(); return intersections.empty() ? Intersection() : *(intersections.begin()); }
|
||||
|
||||
public:
|
||||
|
||||
virtual Intersector* clone(osgUtil::IntersectionVisitor& iv);
|
||||
|
||||
virtual bool enter(const osg::Node& node);
|
||||
|
||||
virtual void leave();
|
||||
|
||||
virtual void intersect(osgUtil::IntersectionVisitor& iv, osg::Drawable* drawable);
|
||||
|
||||
virtual void reset();
|
||||
|
||||
virtual bool containsIntersections() { return !_intersections.empty(); }
|
||||
|
||||
protected:
|
||||
|
||||
PolytopeIntersector* _parent;
|
||||
|
||||
osg::Polytope _polytope;
|
||||
|
||||
Intersections _intersections;
|
||||
|
||||
};
|
||||
|
||||
/** Concrent class for passing multiple intersectors through the scene graph.
|
||||
* To be used in conjunction with IntersectionVisitor. */
|
||||
class OSGUTIL_EXPORT IntersectorGroup : public Intersector
|
||||
|
||||
Reference in New Issue
Block a user